Skip to content

Commit

Permalink
Merge branch 'release/0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
chelout committed Apr 3, 2018
2 parents ecde1ba + 84c73ec commit 88d4c92
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 13 deletions.
42 changes: 42 additions & 0 deletions src/Actions/ManagesFunnels.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace Chelout\PhpSdk\Actions;

use Chelout\PhpSdk\Resources\Funnel;
use Chelout\PhpSdk\Resources\ApiResourceCollection;

trait ManagesFunnels
{
public function funnels(): ApiResourceCollection
{
$response = $this->get('funnels');

return new ApiResourceCollection($response, Funnel::class);
}

public function createFunnel(array $data): Funnel
{
$response = $this->post('funnels', $data);

return new Funnel($response);
}

public function funnel(int $id): Funnel
{
$response = $this->get("funnels/{$id}");

return new Funnel($response);
}

public function updateFunnel(int $id, array $data): Funnel
{
$response = $this->put("funnels/{$id}", $data);

return new Funnel($response);
}

public function deleteFunnel(int $id)
{
$this->delete("funnels/{$id}");
}
}
24 changes: 12 additions & 12 deletions src/Actions/ManagesStatuses.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,43 @@

trait ManagesStatuses
{
public function statuses(): ApiResourceCollection
public function statuses(int $funnelId): ApiResourceCollection
{
$response = $this->get('statuses');
$response = $this->get("funnels/{$funnelId}/statuses");

return new ApiResourceCollection($response, Status::class);
}

public function createStatus(array $data): Status
public function createStatus(int $funnelId, array $data): Status
{
$response = $this->post('statuses', $data);
$response = $this->post("funnels/{$funnelId}/statuses", $data);

return new Status($response);
}

public function status(int $id): Status
public function status(int $funnelId, int $statusId): Status
{
$response = $this->get("statuses/{$id}");
$response = $this->get("funnels/{$funnelId}/statuses/{$statusId}");

return new Status($response);
}

public function updateStatus(int $id, array $data): Status
public function updateStatus(int $funnelId, int $statusId, array $data): Status
{
$response = $this->put("statuses/{$id}", $data);
$response = $this->put("funnels/{$funnelId}/statuses/{$statusId}", $data);

return new Status($response);
}

public function updateStatusPriority(int $id, array $data): Status
public function updateStatusPriority(int $funnelId, int $statusId, array $data): Status
{
$response = $this->patch("statuses/{$id}/priority", $data);
$response = $this->patch("funnels/{$funnelId}/statuses/{$statusId}/priority", $data);

return new Status($response);
}

public function deleteStatus(int $id)
public function deleteStatus(int $funnelId, int $statusId)
{
$this->delete("statuses/{$id}");
$this->delete("funnels/{$funnelId}/statuses/{$statusId}");
}
}
4 changes: 3 additions & 1 deletion src/Ozla.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class Ozla
Actions\ManagesUsers,
Actions\ManagesCompanies,
Actions\ManagesContragents,
Actions\ManagesFunnels,
Actions\ManagesStatusColors,
Actions\ManagesStatusTypes,
Actions\ManagesStatuses,
Expand Down Expand Up @@ -40,7 +41,8 @@ public function __construct(string $domain, string $apiKey, Client $client = nul
$this->apiKey = $apiKey;

$this->client = $client ?: new Client([
'base_uri' => 'https://' . $this->domain . '.ozla.ru/api/v1/',
// 'base_uri' => 'https://' . $this->domain . '.ozla.ru/api/v1/',
'base_uri' => 'http://' . $this->domain . '.ozla.test/api/v1/',
'http_errors' => false,
'headers' => [
'Authorization' => 'Bearer ' . $this->apiKey,
Expand Down
7 changes: 7 additions & 0 deletions src/Resources/Deals/Status.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ class Status extends ApiResource
*/
public $name;

/**
* Status funnel id.
*
* @var int
*/
public $funnel_id;

/**
* Status type id.
*
Expand Down
13 changes: 13 additions & 0 deletions src/Resources/Funnel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Chelout\PhpSdk\Resources;

class Funnel extends ApiResource
{
/**
* Funnel name.
*
* @var string
*/
public $name;
}

0 comments on commit 88d4c92

Please sign in to comment.