Skip to content

Commit

Permalink
🚧 Start implementing Invoice API
Browse files Browse the repository at this point in the history
  • Loading branch information
tgeorgel committed Apr 19, 2023
1 parent a31a430 commit f98417d
Show file tree
Hide file tree
Showing 4 changed files with 145 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -450,9 +450,10 @@ $contactsApi->delete(123)->json();
| **Catalog** | Units ||
| **Catalog** | Taxes ||
| **Invoicing** | Accounting | 🅾️ |
| **Invoicing** | Rate Categories ||
| **Invoicing** | Purchase (OCR) | 🅾️ |
| **Invoicing** | Payments | 🅾️ |
| **Invoicing** | Invoices | 🅾️ |
| **Invoicing** | Invoices | 🆚️ |
| **Invoicing** | Credit Notes | 🅾️ |
| **Account** | Currencies | 🅾️ |
| **Account** | Custom Fields | 🅾️ |
Expand Down
65 changes: 65 additions & 0 deletions src/Api/InvoicesApi.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

namespace Bluerock\Sellsy\Api;

use Bluerock\Sellsy\Entities\Invoice;
use Bluerock\Sellsy\Collections\InvoiceCollection;
use Bluerock\Sellsy\Core\Response;

/**
* The API client for the `rate-categories` namespace.
*
* @package bluerock/sellsy-client
* @author Thomas <thomas@bluerocktel.com>
* @version 1.1
* @access public
* @see https://api.sellsy.com/doc/v2/#tag/Invoices
*/
class InvoicesApi extends AbstractApi
{
/**
* @inheritdoc
*/
public function __construct()
{
parent::__construct();

$this->entity = Invoice::class;
$this->collection = InvoiceCollection::class;
}

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

return $this->prepareResponse($response);
}

/**
* Show a single invoice by id.
*
* @param string $id The invoice id to retrieve.
* @param array $query Query parameters.
*
* @return \Bluerock\Sellsy\Core\Response
* @see https://api.sellsy.com/doc/v2/#operation/get-invoice
*/
public function show(string $id, array $query = []): Response
{
$response = $this->connection
->request("invoices/{$id}")
->get($query);

return $this->prepareResponse($response);
}
}
52 changes: 52 additions & 0 deletions src/Entities/Invoice.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

namespace Bluerock\Sellsy\Entities;

use Bluerock\Sellsy\Entities\Entity;
use Bluerock\Sellsy\Entities\InvoiceAmounts;

/**
* The Invoice Entity.
*
* @package bluerock/sellsy-client
* @author Thomas <thomas@bluerocktel.com>
* @version 1.1
* @access public
*/
class Invoice extends Entity
{
/**
* <READONLY> Invoice ID from Sellsy.
*/
public ?int $id;

/**
* <READONLY> Invoice number from Sellsy.
*/
public ?string $number;

/**
* Invoice status.
*/
public ?string $status;

/**
* Invoice date.
*/
public ?string $date;

/**
* Invoice due date.
*/
public ?string $due_date;

/**
* Invoice amounts.
*/
public ?InvoiceAmounts $amounts;

/**
* Rate category currency.
*/
public string $currency = 'EUR';
}
26 changes: 26 additions & 0 deletions src/Entities/InvoiceAmounts.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace Bluerock\Sellsy\Entities;

use Bluerock\Sellsy\Entities\Entity;

/**
* The InvoiceAmounts Entity.
* Numbers are formatted as a string to avoid floating point precision issues.
*
* @package bluerock/sellsy-client
* @author Thomas <thomas@bluerocktel.com>
* @version 1.1
* @access public
*/
class InvoiceAmounts extends Entity
{
public string $total_raw_excl_tax = "0";
public string $total_after_discount_excl_tax = "0";
public string $total_packaging = "0";
public string $total_shipping = "0";
public string $total_excl_tax = "0";
public string $total_incl_tax = "0";
public string $total_remaining_due_incl_tax = "0";
public string $total_primes_incl_tax = "0";
}

0 comments on commit f98417d

Please sign in to comment.