-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
520 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
<?php | ||
|
||
namespace Bluerock\Sellsy\Api; | ||
|
||
use Illuminate\Support\Arr; | ||
use Bluerock\Sellsy\Core\Response; | ||
use Bluerock\Sellsy\Entities\PhoneCall; | ||
use Bluerock\Sellsy\Collections\PhoneCallCollection; | ||
|
||
/** | ||
* The API client for the `phone-calls` namespace. | ||
* | ||
* @package bluerock/sellsy-client | ||
* @author Thomas <thomas@bluerocktel.com> | ||
* @version 1.2.1 | ||
* @access public | ||
* @see https://api.sellsy.com/doc/v2/#tag/PhoneCalls | ||
*/ | ||
class PhoneCallsApi extends AbstractApi | ||
{ | ||
/** | ||
* @inheritdoc | ||
*/ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
|
||
$this->entity = PhoneCall::class; | ||
$this->collection = PhoneCallCollection::class; | ||
} | ||
|
||
/** | ||
* List all phone calls. | ||
* | ||
* @param array $query Query parameters. | ||
* | ||
* @return \Bluerock\Sellsy\Core\Response | ||
* @see https://api.sellsy.com/doc/v2/#operation/get-phone-calls | ||
*/ | ||
public function index(array $query = []): Response | ||
{ | ||
$response = $this->connection | ||
->request('phone-calls') | ||
->get($query); | ||
|
||
return $this->prepareResponse($response); | ||
} | ||
|
||
/** | ||
* Show a single phone call by id. | ||
* | ||
* @param string $id The phone call id to retrieve. | ||
* @param array $query Query parameters. | ||
* | ||
* @return \Bluerock\Sellsy\Core\Response | ||
* @see https://api.sellsy.com/doc/v2/#operation/get-phone-call | ||
*/ | ||
public function show(string $id, array $query = []): Response | ||
{ | ||
$response = $this->connection | ||
->request("phone-calls/{$id}") | ||
->get($query); | ||
|
||
return $this->prepareResponse($response); | ||
} | ||
|
||
/** | ||
* Store (create) an phone call. | ||
* | ||
* @param PhoneCall $phoneCall The phone call entity to store. | ||
* @param array $query Query parameters. | ||
* | ||
* @return \Bluerock\Sellsy\Core\Response | ||
* @see https://api.sellsy.com/doc/v2/#operation/create-phone-call | ||
*/ | ||
public function store(PhoneCall $phoneCall, array $query = []): Response | ||
{ | ||
$body = $phoneCall->except('id') | ||
->except('owner') | ||
->except('result') | ||
->toArray(); | ||
|
||
$result = $phoneCall->result ? $phoneCall->result->id : null; | ||
|
||
$response = $this->connection | ||
->request('phone-calls') | ||
->post(array_filter($body + compact('result')) + $query); | ||
|
||
return $this->prepareResponse($response); | ||
} | ||
|
||
/** | ||
* Update an existing phone call. | ||
* | ||
* @param PhoneCall $phoneCall The phone call entity to store. | ||
* @param array $query Query parameters. | ||
* | ||
* @return \Bluerock\Sellsy\Core\Response | ||
* @see https://api.sellsy.com/doc/v2/#operation/update-phone-call | ||
*/ | ||
public function update(PhoneCall $phoneCall, array $query = []): Response | ||
{ | ||
$body = $phoneCall->except('id') | ||
->except('owner') | ||
->except('result') | ||
->toArray(); | ||
|
||
$result = $phoneCall->result ? $phoneCall->result->id : null; | ||
|
||
$response = $this->connection | ||
->request("phone-calls/{$phoneCall->id}") | ||
->put(array_filter($body + compact('result')) + $query); | ||
|
||
return $this->prepareResponse($response); | ||
} | ||
|
||
/** | ||
* Delete an existing phone call. | ||
* | ||
* @param int $id The phone call id to be deleted. | ||
* | ||
* @return \Bluerock\Sellsy\Core\Response | ||
* @see https://api.sellsy.com/doc/v2/#operation/delete-phone-call | ||
*/ | ||
public function destroy(int $id): Response | ||
{ | ||
$response = $this->connection | ||
->request("phone-calls/{$id}") | ||
->delete(); | ||
|
||
return $this->prepareResponse($response); | ||
} | ||
|
||
/** | ||
* Search phone calls with some filters. | ||
* | ||
* @param array $query Query parameters. | ||
* @param array $filters Filters to use. | ||
* | ||
* @return \Bluerock\Sellsy\Core\Response | ||
* @see https://api.sellsy.com/doc/v2/#operation/search-phone-calls | ||
*/ | ||
public function search(array $query = [], array $filters = []): Response | ||
{ | ||
$response = $this->connection | ||
->request('phone-calls/search' . '?' . Arr::query($query)) | ||
->post( | ||
compact('filters') | ||
); | ||
|
||
return $this->prepareResponse($response); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
<?php | ||
|
||
namespace Bluerock\Sellsy\Api; | ||
|
||
use Illuminate\Support\Arr; | ||
use Bluerock\Sellsy\Core\Response; | ||
use Bluerock\Sellsy\Entities\StaffMember; | ||
use Bluerock\Sellsy\Collections\StaffMemberCollection; | ||
|
||
/** | ||
* The API client for the `staffs` namespace. | ||
* | ||
* @package bluerock/sellsy-client | ||
* @author Thomas <thomas@bluerocktel.com> | ||
* @version 1.2.1 | ||
* @access public | ||
* @see https://api.sellsy.com/doc/v2/#tag/StaffMembers | ||
*/ | ||
class StaffsApi extends AbstractApi | ||
{ | ||
/** | ||
* @inheritdoc | ||
*/ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
|
||
$this->entity = StaffMember::class; | ||
$this->collection = StaffMemberCollection::class; | ||
} | ||
|
||
/** | ||
* List all staff members. | ||
* | ||
* @param array $query Query parameters. | ||
* | ||
* @return \Bluerock\Sellsy\Core\Response | ||
* @see https://api.sellsy.com/doc/v2/#operation/get-staffs | ||
*/ | ||
public function index(array $query = []): Response | ||
{ | ||
$response = $this->connection | ||
->request('staffs') | ||
->get($query); | ||
|
||
return $this->prepareResponse($response); | ||
} | ||
|
||
/** | ||
* Show a single staff member by id. | ||
* | ||
* @param string $id The staff member id to retrieve. | ||
* @param array $query Query parameters. | ||
* | ||
* @return \Bluerock\Sellsy\Core\Response | ||
* @see https://api.sellsy.com/doc/v2/#operation/get-staff | ||
*/ | ||
public function show(string $id, array $query = []): Response | ||
{ | ||
$response = $this->connection | ||
->request("staffs/{$id}") | ||
->get($query); | ||
|
||
return $this->prepareResponse($response); | ||
} | ||
|
||
/** | ||
* Store (create) an staff member. | ||
* | ||
* @param StaffMember $staff The staff member entity to store. | ||
* @param array $query Query parameters. | ||
* | ||
* @return \Bluerock\Sellsy\Core\Response | ||
* @see https://api.sellsy.com/doc/v2/#operation/create-staff | ||
*/ | ||
public function store(StaffMember $staff, array $query = []): Response | ||
{ | ||
$body = $staff->except('id') | ||
->except('owner') | ||
->toArray(); | ||
|
||
$response = $this->connection | ||
->request('staffs') | ||
->post(array_filter($body) + $query); | ||
|
||
return $this->prepareResponse($response); | ||
} | ||
|
||
/** | ||
* Update an existing staff member. | ||
* | ||
* @param StaffMember $staff The staff member entity to store. | ||
* @param array $query Query parameters. | ||
* | ||
* @return \Bluerock\Sellsy\Core\Response | ||
* @see https://api.sellsy.com/doc/v2/#operation/update-staff | ||
*/ | ||
public function update(StaffMember $staff, array $query = []): Response | ||
{ | ||
$body = $staff->except('id') | ||
->except('owner') | ||
->toArray(); | ||
|
||
$response = $this->connection | ||
->request("staffs/{$staff->id}") | ||
->put(array_filter($body) + $query); | ||
|
||
return $this->prepareResponse($response); | ||
} | ||
|
||
/** | ||
* Delete an existing staff member. | ||
* | ||
* @param int $id The staff member id to be deleted. | ||
* | ||
* @return \Bluerock\Sellsy\Core\Response | ||
* @see https://api.sellsy.com/doc/v2/#operation/delete-staff | ||
*/ | ||
public function destroy(int $id): Response | ||
{ | ||
$response = $this->connection | ||
->request("staffs/{$id}") | ||
->delete(); | ||
|
||
return $this->prepareResponse($response); | ||
} | ||
|
||
/** | ||
* Search staff members with some filters. | ||
* | ||
* @param array $query Query parameters. | ||
* @param array $filters Filters to use. | ||
* | ||
* @return \Bluerock\Sellsy\Core\Response | ||
* @see https://api.sellsy.com/doc/v2/#operation/search-staffs | ||
*/ | ||
public function search(array $query = [], array $filters = []): Response | ||
{ | ||
$response = $this->connection | ||
->request('staffs/search' . '?' . Arr::query($query)) | ||
->post( | ||
compact('filters') | ||
); | ||
|
||
return $this->prepareResponse($response); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace Bluerock\Sellsy\Collections; | ||
|
||
use Bluerock\Sellsy\Entities\PhoneCall; | ||
use Bluerock\Sellsy\Contracts\EntityCollectionContract; | ||
use Spatie\DataTransferObject\DataTransferObjectCollection; | ||
|
||
/** | ||
* The PhoneCall Entity collection. | ||
* | ||
* @package bluerock/sellsy-client | ||
* @author Thomas <thomas@bluerocktel.com> | ||
* @version 1.2.1 | ||
* @access public | ||
* | ||
* @method \Bluerock\Sellsy\Entities\PhoneCall current | ||
*/ | ||
class PhoneCallCollection extends DataTransferObjectCollection implements EntityCollectionContract | ||
{ | ||
public static function create(array $data): PhoneCallCollection | ||
{ | ||
return new static(PhoneCall::arrayOf($data)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace Bluerock\Sellsy\Collections; | ||
|
||
use Bluerock\Sellsy\Entities\StaffMember; | ||
use Bluerock\Sellsy\Contracts\EntityCollectionContract; | ||
use Spatie\DataTransferObject\DataTransferObjectCollection; | ||
|
||
/** | ||
* The StaffMember Entity collection. | ||
* | ||
* @package bluerock/sellsy-client | ||
* @author Thomas <thomas@bluerocktel.com> | ||
* @version 1.2.1 | ||
* @access public | ||
* | ||
* @method \Bluerock\Sellsy\Entities\StaffMember current | ||
*/ | ||
class StaffMemberCollection extends DataTransferObjectCollection implements EntityCollectionContract | ||
{ | ||
public static function create(array $data): StaffMemberCollection | ||
{ | ||
return new static(StaffMember::arrayOf($data)); | ||
} | ||
} |
Oops, something went wrong.