Skip to content

Commit

Permalink
✨ Introduce Unit api endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
tgeorgel committed Oct 7, 2022
1 parent e0d683b commit 371e7fa
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 12 deletions.
6 changes: 1 addition & 5 deletions src/Api/CompaniesApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* @author Thomas <[email protected]>
* @version 1.0
* @access public
* @see https://api.sellsy.com/doc/v2/#tag/Companies
*/
class CompaniesApi extends AbstractApi
{
Expand All @@ -26,7 +27,6 @@ public function __construct()
$this->collection = CompanyCollection::class;
}


/**
* List all companies.
*
Expand All @@ -47,7 +47,6 @@ public function index(array $query = []): self
return $this;
}


/**
* Show a single company by id.
*
Expand All @@ -69,7 +68,6 @@ public function show(string $id, array $query = []): self
return $this;
}


/**
* Store (create) an company.
*
Expand All @@ -95,7 +93,6 @@ public function store(Company $company, array $query = []): self
return $this;
}


/**
* Update an existing company.
*
Expand All @@ -121,7 +118,6 @@ public function update(Company $company, array $query = []): self
return $this;
}


/**
* Delete an existing company.
*
Expand Down
6 changes: 1 addition & 5 deletions src/Api/ContactsApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* @author Thomas <[email protected]>
* @version 1.0
* @access public
* @see https://api.sellsy.com/doc/v2/#tag/Contacts
*/
class ContactsApi extends AbstractApi
{
Expand All @@ -26,7 +27,6 @@ public function __construct()
$this->collection = ContactCollection::class;
}


/**
* List all contacts.
*
Expand All @@ -47,7 +47,6 @@ public function index(array $query = []): self
return $this;
}


/**
* Show a single contact by id.
*
Expand All @@ -69,7 +68,6 @@ public function show(string $id, array $query = []): self
return $this;
}


/**
* Store (create) an contact.
*
Expand All @@ -95,7 +93,6 @@ public function store(Contact $contact, array $query = []): self
return $this;
}


/**
* Update an existing contact.
*
Expand All @@ -121,7 +118,6 @@ public function update(Contact $contact, array $query = []): self
return $this;
}


/**
* Delete an existing contact.
*
Expand Down
4 changes: 2 additions & 2 deletions src/Api/TaxesApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
use Bluerock\Sellsy\Collections\TaxCollection;

/**
* The API client for the `companies` namespace.
* The API client for the `taxes` namespace.
*
* @package sellsy-connector
* @author Thomas <[email protected]>
* @version 1.0
* @access public
* @see https://api.sellsy.com/doc/v2/#tag/Taxes
*/
class TaxesApi extends AbstractApi
{
Expand All @@ -26,7 +27,6 @@ public function __construct()
$this->collection = TaxCollection::class;
}


/**
* List all taxes.
*
Expand Down
49 changes: 49 additions & 0 deletions src/Api/UnitsApi.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace Bluerock\Sellsy\Api;

use Bluerock\Sellsy\Entities\Unit;
use Bluerock\Sellsy\Collections\UnitCollection;

/**
* The API client for the `units` namespace.
*
* @package sellsy-connector
* @author Thomas <[email protected]>
* @version 1.1
* @access public
* @see https://api.sellsy.com/doc/v2/#tag/Units
*/
class UnitsApi extends AbstractApi
{
/**
* @inheritdoc
*/
public function __construct()
{
parent::__construct();

$this->entity = Unit::class;
$this->collection = UnitCollection::class;
}

/**
* List all units.
*
* @param array $query Query parameters.
*
* @return \Illuminate\Http\Client\Response
* @see https://api.sellsy.com/doc/v2/#operation/get-units
*/
public function index(array $query = []): self
{
$response = $this->connection
->request('units')
->get($query);

$this->response = $response;
$this->response->throw();

return $this;
}
}
25 changes: 25 additions & 0 deletions src/Collections/UnitCollection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace Bluerock\Sellsy\Collections;

use Bluerock\Sellsy\Entities\Unit;
use Bluerock\Sellsy\Contracts\EntityCollectionContract;
use Spatie\DataTransferObject\DataTransferObjectCollection;

/**
* The Unit Entity collection.
*
* @package sellsy-connector
* @author Thomas <[email protected]>
* @version 1.0
* @access public
*
* @method \Bluerock\Sellsy\Entities\Unit current
*/
class UnitCollection extends DataTransferObjectCollection implements EntityCollectionContract
{
public static function create(array $data): UnitCollection
{
return new static(Unit::arrayOf($data));
}
}
27 changes: 27 additions & 0 deletions src/Entities/Unit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace Bluerock\Sellsy\Entities;

use Bluerock\Sellsy\Contracts\EntityContract;
use Spatie\DataTransferObject\FlexibleDataTransferObject;

/**
* The Tax Entity.
*
* @package sellsy-connector
* @author Thomas <[email protected]>
* @version 1.0
* @access public
*/
class Unit extends FlexibleDataTransferObject implements EntityContract
{
/**
* <READONLY> Tax class ID from Sellsy.
*/
public int $id;

/**
* Tax class label.
*/
public ?string $label;
}

0 comments on commit 371e7fa

Please sign in to comment.