Skip to content

Commit

Permalink
Merge pull request #68 from turbo124/main
Browse files Browse the repository at this point in the history
Add all entities to SDK
  • Loading branch information
turbo124 authored Sep 16, 2021
2 parents 41942c0 + f00ce59 commit 61c9cf3
Show file tree
Hide file tree
Showing 31 changed files with 891 additions and 204 deletions.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,19 @@ $invoices = $ninja->invoices->all();
### Supports

- Clients
- Invoices/Quotes
- Invoices
- Quotes
- Products
- Payments
- TaxRates
- Statics
- Expenses
- Recurring Invoices
- Credits
- Projects
- Tasks
- Vendors
- Companies

### Retrieving Models

Expand Down
28 changes: 28 additions & 0 deletions src/Endpoints/BaseEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,33 @@ public function restore(array $entity_array)
return $this->bulk("restore", $entity_array);
}

public function all(array $search = [])
{
$query = ['query' => $search];

return $this->ninja->send("GET", "{$this->uri}", $query);
}

public function get(string $entity_id, array $search = [])
{
$query = ['query' => $search];

return $this->ninja->send("GET", "{$this->uri}/{$entity_id}", $query);
}

public function update(string $entity_id, array $entity)
{
$query = ['form_params' => $entity];

return $this->ninja->send("PUT", "{$this->uri}/{$entity_id}", $query);
}

public function create(array $entity, array $includes = [])
{
$query = ['form_params' => $entity, 'query' => $includes];

return $this->ninja->send("POST", "{$this->uri}", $query);
}

}

32 changes: 0 additions & 32 deletions src/Endpoints/Clients.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,37 +26,5 @@ public function __construct(InvoiceNinja $ninja)
$this->ninja = $ninja;
}

/**
* @param array $search
* @return void
* @throws GuzzleException
*/
public function all(array $search = [])
{
$query = ['query' => $search];

return $this->ninja->send("GET", "{$this->uri}", $query);
}

public function get(string $client_id, array $search = [])
{
$query = ['query' => $search];

return $this->ninja->send("GET", "{$this->uri}/{$client_id}", $query);
}

public function update(string $client_id, array $client)
{
$query = ['form_params' => $client];

return $this->ninja->send("PUT", "{$this->uri}/{$client_id}", $query);
}

public function create(array $client, array $includes = [])
{
$query = ['form_params' => $client, 'query' => $includes];

return $this->ninja->send("POST", "{$this->uri}", $query);
}
}

57 changes: 57 additions & 0 deletions src/Endpoints/Companies.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/sdk-php source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/MIT
*/

namespace InvoiceNinja\Sdk\Endpoints;

use GuzzleHttp\Exception\GuzzleException;
use InvoiceNinja\Sdk\InvoiceNinja;

class Companies
{

protected InvoiceNinja $ninja;

protected string $uri = "/api/v1/companies";

public function __construct(InvoiceNinja $ninja)
{
$this->ninja = $ninja;
}

public function all(array $search = [])
{
$query = ['query' => $search];

return $this->ninja->send("GET", "{$this->uri}", $query);
}

public function get(string $entity_id, array $search = [])
{
$query = ['query' => $search];

return $this->ninja->send("GET", "{$this->uri}/{$entity_id}", $query);
}

public function update(string $entity_id, array $entity)
{
$query = ['form_params' => $entity];

return $this->ninja->send("PUT", "{$this->uri}/{$entity_id}", $query);
}

public function create(array $entity, array $includes = [])
{
$query = ['form_params' => $entity, 'query' => $includes];

return $this->ninja->send("POST", "{$this->uri}", $query);
}
}

30 changes: 30 additions & 0 deletions src/Endpoints/Credits.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/sdk-php source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/MIT
*/

namespace InvoiceNinja\Sdk\Endpoints;

use GuzzleHttp\Exception\GuzzleException;
use InvoiceNinja\Sdk\InvoiceNinja;

class Credits extends BaseEntity
{

protected InvoiceNinja $ninja;

protected string $uri = "/api/v1/credits";

public function __construct(InvoiceNinja $ninja)
{
$this->ninja = $ninja;
}

}

30 changes: 30 additions & 0 deletions src/Endpoints/Expenses.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/sdk-php source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/MIT
*/

namespace InvoiceNinja\Sdk\Endpoints;

use GuzzleHttp\Exception\GuzzleException;
use InvoiceNinja\Sdk\InvoiceNinja;

class Expenses extends BaseEntity
{

protected InvoiceNinja $ninja;

protected string $uri = "/api/v1/expenses";

public function __construct(InvoiceNinja $ninja)
{
$this->ninja = $ninja;
}

}

32 changes: 0 additions & 32 deletions src/Endpoints/Invoices.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,37 +26,5 @@ public function __construct(InvoiceNinja $ninja)
$this->ninja = $ninja;
}

/**
* @param array $search
* @return void
* @throws GuzzleException
*/
public function all(array $search = [])
{
$query = ['query' => $search];

return $this->ninja->send("GET", "{$this->uri}", $query);
}

public function get(string $invoice_id, array $search = [])
{
$query = ['query' => $search];

return $this->ninja->send("GET", "{$this->uri}/{$invoice_id}", $query);
}

public function update(string $invoice_id, array $invoices)
{
$query = ['form_params' => $invoices];

return $this->ninja->send("PUT", "{$this->uri}/{$invoice_id}", $query);
}

public function create(array $invoices, array $includes = [])
{
$query = ['form_params' => $invoices, 'query' => $includes];

return $this->ninja->send("POST", "{$this->uri}", $query);
}
}

32 changes: 0 additions & 32 deletions src/Endpoints/Payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,37 +26,5 @@ public function __construct(InvoiceNinja $ninja)
$this->ninja = $ninja;
}

/**
* @param array $search
* @return void
* @throws GuzzleException
*/
public function all(array $search = [])
{
$query = ['query' => $search];

return $this->ninja->send("GET", "{$this->uri}", $query);
}

public function get(string $payment_id, array $search = [])
{
$query = ['query' => $search];

return $this->ninja->send("GET", "{$this->uri}/{$payment_id}", $query);
}

public function update(string $payment_id, array $payment)
{
$query = ['form_params' => $payment];

return $this->ninja->send("PUT", "{$this->uri}/{$payment_id}", $query);
}

public function create(array $payment, array $includes = [])
{
$query = ['form_params' => $payment, 'query' => $includes];

return $this->ninja->send("POST", "{$this->uri}", $query);
}
}

32 changes: 0 additions & 32 deletions src/Endpoints/Products.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,37 +26,5 @@ public function __construct(InvoiceNinja $ninja)
$this->ninja = $ninja;
}

/**
* @param array $search
* @return void
* @throws GuzzleException
*/
public function all(array $search = [])
{
$query = ['query' => $search];

return $this->ninja->send("GET", "{$this->uri}", $query);
}

public function get(string $product_id, array $search = [])
{
$query = ['query' => $search];

return $this->ninja->send("GET", "{$this->uri}/{$product_id}", $query);
}

public function update(string $product_id, array $product)
{
$query = ['form_params' => $product];

return $this->ninja->send("PUT", "{$this->uri}/{$product_id}", $query);
}

public function create(array $product, array $includes = [])
{
$query = ['form_params' => $product, 'query' => $includes];

return $this->ninja->send("POST", "{$this->uri}", $query);
}
}

30 changes: 30 additions & 0 deletions src/Endpoints/Projects.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/sdk-php source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/MIT
*/

namespace InvoiceNinja\Sdk\Endpoints;

use GuzzleHttp\Exception\GuzzleException;
use InvoiceNinja\Sdk\InvoiceNinja;

class Projects extends BaseEntity
{

protected InvoiceNinja $ninja;

protected string $uri = "/api/v1/projects";

public function __construct(InvoiceNinja $ninja)
{
$this->ninja = $ninja;
}

}

32 changes: 0 additions & 32 deletions src/Endpoints/Quotes.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,37 +26,5 @@ public function __construct(InvoiceNinja $ninja)
$this->ninja = $ninja;
}

/**
* @param array $search
* @return void
* @throws GuzzleException
*/
public function all(array $search = [])
{
$query = ['query' => $search];

return $this->ninja->send("GET", "{$this->uri}", $query);
}

public function get(string $quote_id, array $search = [])
{
$query = ['query' => $search];

return $this->ninja->send("GET", "{$this->uri}/{$quote_id}", $query);
}

public function update(string $quote_id, array $quote)
{
$query = ['form_params' => $quote];

return $this->ninja->send("PUT", "{$this->uri}/{$quote_id}", $query);
}

public function create(array $entity, array $includes = [])
{
$query = ['form_params' => $entity, 'query' => $includes];

return $this->ninja->send("POST", "{$this->uri}", $query);
}
}

Loading

0 comments on commit 61c9cf3

Please sign in to comment.