diff --git a/README.md b/README.md index 86ce0e8..1286a06 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/Endpoints/BaseEntity.php b/src/Endpoints/BaseEntity.php index c2313ee..017330e 100644 --- a/src/Endpoints/BaseEntity.php +++ b/src/Endpoints/BaseEntity.php @@ -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); + } + } diff --git a/src/Endpoints/Clients.php b/src/Endpoints/Clients.php index a2e368e..711b8a9 100644 --- a/src/Endpoints/Clients.php +++ b/src/Endpoints/Clients.php @@ -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); - } } diff --git a/src/Endpoints/Companies.php b/src/Endpoints/Companies.php new file mode 100644 index 0000000..1a6eef0 --- /dev/null +++ b/src/Endpoints/Companies.php @@ -0,0 +1,57 @@ +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); + } +} + diff --git a/src/Endpoints/Credits.php b/src/Endpoints/Credits.php new file mode 100644 index 0000000..9bc20a3 --- /dev/null +++ b/src/Endpoints/Credits.php @@ -0,0 +1,30 @@ +ninja = $ninja; + } + +} + diff --git a/src/Endpoints/Expenses.php b/src/Endpoints/Expenses.php new file mode 100644 index 0000000..81fa79e --- /dev/null +++ b/src/Endpoints/Expenses.php @@ -0,0 +1,30 @@ +ninja = $ninja; + } + +} + diff --git a/src/Endpoints/Invoices.php b/src/Endpoints/Invoices.php index 85dab5f..ea34477 100644 --- a/src/Endpoints/Invoices.php +++ b/src/Endpoints/Invoices.php @@ -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); - } } diff --git a/src/Endpoints/Payments.php b/src/Endpoints/Payments.php index 4bfe1dd..4178087 100644 --- a/src/Endpoints/Payments.php +++ b/src/Endpoints/Payments.php @@ -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); - } } diff --git a/src/Endpoints/Products.php b/src/Endpoints/Products.php index d2d5e70..1342569 100644 --- a/src/Endpoints/Products.php +++ b/src/Endpoints/Products.php @@ -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); - } } diff --git a/src/Endpoints/Projects.php b/src/Endpoints/Projects.php new file mode 100644 index 0000000..c90e5f8 --- /dev/null +++ b/src/Endpoints/Projects.php @@ -0,0 +1,30 @@ +ninja = $ninja; + } + +} + diff --git a/src/Endpoints/Quotes.php b/src/Endpoints/Quotes.php index c83a5fd..9981f0e 100644 --- a/src/Endpoints/Quotes.php +++ b/src/Endpoints/Quotes.php @@ -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); - } } diff --git a/src/Endpoints/RecurringInvoices.php b/src/Endpoints/RecurringInvoices.php new file mode 100644 index 0000000..0c21429 --- /dev/null +++ b/src/Endpoints/RecurringInvoices.php @@ -0,0 +1,30 @@ +ninja = $ninja; + } + +} + diff --git a/src/Endpoints/Tasks.php b/src/Endpoints/Tasks.php new file mode 100644 index 0000000..63ab401 --- /dev/null +++ b/src/Endpoints/Tasks.php @@ -0,0 +1,30 @@ +ninja = $ninja; + } + +} + diff --git a/src/Endpoints/TaxRates.php b/src/Endpoints/TaxRates.php index 5da4380..d1e64c9 100644 --- a/src/Endpoints/TaxRates.php +++ b/src/Endpoints/TaxRates.php @@ -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 $tax_rate_id, array $search = []) - { - $query = ['query' => $search]; - - return $this->ninja->send("GET", "{$this->uri}/{$tax_rate_id}", $query); - } - - public function update(string $tax_rate_id, array $tax_rate) - { - $query = ['form_params' => $tax_rate]; - - return $this->ninja->send("PUT", "{$this->uri}/{$tax_rate_id}", $query); - } - - public function create(array $tax_rate, array $includes = []) - { - $query = ['form_params' => $tax_rate, 'query' => $includes]; - - return $this->ninja->send("POST", "{$this->uri}", $query); - } } diff --git a/src/Endpoints/Vendors.php b/src/Endpoints/Vendors.php new file mode 100644 index 0000000..ffaf13e --- /dev/null +++ b/src/Endpoints/Vendors.php @@ -0,0 +1,30 @@ +ninja = $ninja; + } + +} + diff --git a/src/InvoiceNinja.php b/src/InvoiceNinja.php index 0edd08b..ea3e262 100644 --- a/src/InvoiceNinja.php +++ b/src/InvoiceNinja.php @@ -15,12 +15,19 @@ use GuzzleHttp\Exception\GuzzleException; use GuzzleHttp\Exception\RequestException; use InvoiceNinja\Sdk\Endpoints\Clients; +use InvoiceNinja\Sdk\Endpoints\Companies; +use InvoiceNinja\Sdk\Endpoints\Credits; +use InvoiceNinja\Sdk\Endpoints\Expenses; use InvoiceNinja\Sdk\Endpoints\Invoices; use InvoiceNinja\Sdk\Endpoints\Payments; use InvoiceNinja\Sdk\Endpoints\Products; +use InvoiceNinja\Sdk\Endpoints\Projects; use InvoiceNinja\Sdk\Endpoints\Quotes; +use InvoiceNinja\Sdk\Endpoints\RecurringInvoices; use InvoiceNinja\Sdk\Endpoints\Statics; +use InvoiceNinja\Sdk\Endpoints\Tasks; use InvoiceNinja\Sdk\Endpoints\TaxRates; +use InvoiceNinja\Sdk\Endpoints\Vendors; use InvoiceNinja\Sdk\Exceptions\ApiException; class InvoiceNinja @@ -48,6 +55,20 @@ class InvoiceNinja public Statics $statics; + public Expenses $expense; + + public RecurringInvoices $recurring_invoices; + + public Credits $credits; + + public Projects $projects; + + public Tasks $tasks; + + public Vendors $vendors; + + public Companies $companies; + /** * @param string $token * @return void @@ -68,7 +89,14 @@ private function initialize() $this->payments = new Payments($this); $this->tax_rates = new TaxRates($this); $this->statics = new Statics($this); - + $this->expenses = new Expenses($this); + $this->recurring_invoices = new RecurringInvoices($this); + $this->credits = new Credits($this); + $this->projects = new Projects($this); + $this->tasks = new Tasks($this); + $this->vendors = new Vendors($this); + $this->companies = new Companies($this); + return $this; } /** @@ -82,6 +110,18 @@ public function setUrl(string $url) return $this; } + public function setToken($token) + { + $this->token = $token; + + return $this; + } + + public function getToken() + { + return $this->token; + } + /** @return string */ private function getUrl() :string { @@ -120,7 +160,7 @@ public function addHeader(array $headers) private function buildHeaders() :array { $headers = [ - 'X-API-TOKEN' => $this->token, + 'X-API-TOKEN' => $this->getToken(), 'X-Requested-With' => 'XMLHttpRequest', ]; @@ -130,7 +170,10 @@ private function buildHeaders() :array /** @return Client */ private function httpClient() { - $this->httpClient = new \GuzzleHttp\Client(['headers' => $this->buildHeaders()]); + $this->httpClient = new \GuzzleHttp\Client([ + 'verify' => false, + 'headers' => $this->buildHeaders() + ]); return $this; } diff --git a/tests/BulkActionsTest.php b/tests/BulkActionsTest.php index dc49f6a..86ac574 100644 --- a/tests/BulkActionsTest.php +++ b/tests/BulkActionsTest.php @@ -17,7 +17,7 @@ class BulkActionsTest extends TestCase { protected string $token = "company-token-test"; - protected string $url = "http://ninja.test:8000"; + protected string $url = "https://ninja.test"; public function testArchive() { diff --git a/tests/ClientsTest.php b/tests/ClientsTest.php index ff398f7..68b3132 100644 --- a/tests/ClientsTest.php +++ b/tests/ClientsTest.php @@ -17,7 +17,7 @@ class ClientsTest extends TestCase { protected string $token = "company-token-test"; - protected string $url = "http://ninja.test:8000"; + protected string $url = "https://ninja.test"; public function testClients() { diff --git a/tests/CompaniesTest.php b/tests/CompaniesTest.php new file mode 100644 index 0000000..c3489ac --- /dev/null +++ b/tests/CompaniesTest.php @@ -0,0 +1,79 @@ +token); + $ninja->setUrl($this->url); + + $companies = $ninja->companies->all(); + + $this->assertTrue(is_array($companies)); + + } + + public function testCompanyGet() + { + + $ninja = new InvoiceNinja($this->token); + $ninja->setUrl($this->url); + + $company = $ninja->companies->create([], ['include' => 'company,company.tokens']); + $token = $company['data'][0]['company']['tokens'][0]['token']; + $ninja->setToken($token); + + $companies = $ninja->companies->get($company['data'][0]['company']['id']); + + $this->assertTrue(is_array($companies)); + + } + + + public function testCompanyPut() + { + + $ninja = new InvoiceNinja($this->token); + $ninja->setUrl($this->url); + + $company = $ninja->companies->create([], ['include' => 'company,company.tokens']); + $token = $company['data'][0]['company']['tokens'][0]['token']; + $ninja->setToken($token); + + $companies = $ninja->companies->update($company['data'][0]['company']['id'], ['industry_id' => '1']); + + $this->assertTrue(is_array($companies)); + + } + + + public function testCompanyPost() + { + + $ninja = new InvoiceNinja($this->token); + $ninja->setUrl($this->url); + + $companies = $ninja->companies->create([], ['include' => 'company']); + + $this->assertTrue(is_array($companies)); + + } +} \ No newline at end of file diff --git a/tests/CreditsTest.php b/tests/CreditsTest.php new file mode 100644 index 0000000..3d321f3 --- /dev/null +++ b/tests/CreditsTest.php @@ -0,0 +1,83 @@ +token); + $ninja->setUrl($this->url); + + $client = $ninja->clients->create(['name' => 'Brand spanking new client']); + + $credit = $ninja->credits->create(['client_id' => $client['data']['id']]); + + $credits = $ninja->credits->all(); + + $this->assertTrue(is_array($credits)); + + } + + public function testCreditGet() + { + + $ninja = new InvoiceNinja($this->token); + $ninja->setUrl($this->url); + + $client = $ninja->clients->create(['name' => 'Brand spanking new client']); + + $credit = $ninja->credits->create(['client_id' => $client['data']['id']]); + + $credits = $ninja->credits->get($credit['data']['id']); + + $this->assertTrue(is_array($credits)); + + } + + + public function testCreditPut() + { + + $ninja = new InvoiceNinja($this->token); + $ninja->setUrl($this->url); + + $client = $ninja->clients->create(['name' => 'Brand spanking new client']); + + $credit = $ninja->credits->create(['client_id' => $client['data']['id']]); + + $credits = $ninja->credits->update($credit['data']['id'], ['discount' => '10']); + + $this->assertTrue(is_array($credits)); + + } + + + public function testCreditPost() + { + + $ninja = new InvoiceNinja($this->token); + $ninja->setUrl($this->url); + + $credits = $ninja->credits->create(['client_id' => '7LDdwRb1YK']); + + $this->assertTrue(is_array($credits)); + + } +} \ No newline at end of file diff --git a/tests/ExpensesTest.php b/tests/ExpensesTest.php new file mode 100644 index 0000000..a0eba98 --- /dev/null +++ b/tests/ExpensesTest.php @@ -0,0 +1,79 @@ +token); + $ninja->setUrl($this->url); + + $expenses = $ninja->expenses->all(); + + $this->assertTrue(is_array($expenses)); + + } + + public function testExpenseGet() + { + + $ninja = new InvoiceNinja($this->token); + $ninja->setUrl($this->url); + + $client = $ninja->clients->create(['name' => 'Brand spanking new clients']); + $expense = $ninja->expenses->create(['client_id' => $client['data']['id']]); + + $expenses = $ninja->expenses->get($expense['data']['id']); + + $this->assertTrue(is_array($expenses)); + + } + + + public function testExpensePut() + { + + $ninja = new InvoiceNinja($this->token); + $ninja->setUrl($this->url); + + + $clients = $ninja->clients->create(['name' => 'Brand spanking new client']); + $expense = $ninja->expenses->create(['client_id' => $clients['data']['id']]); + + $expenses = $ninja->expenses->update($expense['data']['id'], ['amount' => '10']); + + $this->assertTrue(is_array($expenses)); + + } + + + public function testExpensePost() + { + + $ninja = new InvoiceNinja($this->token); + $ninja->setUrl($this->url); + $client = $ninja->clients->create(['name' => 'Brand spanking new client']); + + $expenses = $ninja->expenses->create(['client_id' => $client['data']['id']]); + + $this->assertTrue(is_array($expenses)); + + } +} \ No newline at end of file diff --git a/tests/InvoicesTest.php b/tests/InvoicesTest.php index 6d13274..174fba8 100644 --- a/tests/InvoicesTest.php +++ b/tests/InvoicesTest.php @@ -17,7 +17,7 @@ class InvoicesTest extends TestCase { protected string $token = "company-token-test"; - protected string $url = "http://ninja.test:8000"; + protected string $url = "https://ninja.test"; public function testInvoices() { diff --git a/tests/PaymentsTest.php b/tests/PaymentsTest.php index f3ffd4f..b2f109a 100644 --- a/tests/PaymentsTest.php +++ b/tests/PaymentsTest.php @@ -17,7 +17,7 @@ class PaymentsTest extends TestCase { protected string $token = "company-token-test"; - protected string $url = "http://ninja.test:8000"; + protected string $url = "https://ninja.test"; public function testPayments() { diff --git a/tests/ProductsTest.php b/tests/ProductsTest.php index 9d35c28..cbf6724 100644 --- a/tests/ProductsTest.php +++ b/tests/ProductsTest.php @@ -17,7 +17,7 @@ class ProductsTest extends TestCase { protected string $token = "company-token-test"; - protected string $url = "http://ninja.test:8000"; + protected string $url = "https://ninja.test"; public function testProducts() { diff --git a/tests/ProjectsTest.php b/tests/ProjectsTest.php new file mode 100644 index 0000000..3803205 --- /dev/null +++ b/tests/ProjectsTest.php @@ -0,0 +1,77 @@ +token); + $ninja->setUrl($this->url); + + $projects = $ninja->projects->all(); + + $this->assertTrue(is_array($projects)); + + } + + public function testProjectGet() + { + + $ninja = new InvoiceNinja($this->token); + $ninja->setUrl($this->url); + + $client = $ninja->clients->create(['name' => 'Brand spanking new client']); + $product = $ninja->projects->create(['name' => 'Project', 'client_id' => $client['data']['id']]); + + $projects = $ninja->projects->get($product['data']['id']); + + $this->assertTrue(is_array($projects)); + + } + + + public function testProjectPut() + { + + $ninja = new InvoiceNinja($this->token); + $ninja->setUrl($this->url); + + $client = $ninja->clients->create(['name' => 'Brand spanking new client']); + $product = $ninja->projects->create(['name' => 'Project', 'client_id' => $client['data']['id']]); + + $projects = $ninja->projects->update($product['data']['id'], ['name' => 'Project 2']); + + $this->assertTrue(is_array($projects)); + + } + + + public function testProjectPost() + { + + $ninja = new InvoiceNinja($this->token); + $ninja->setUrl($this->url); + + $client = $ninja->clients->create(['name' => 'Brand spanking new client']); + $projects = $ninja->projects->create(['name' => 'Project', 'client_id' => $client['data']['id']]); + $this->assertTrue(is_array($projects)); + + } +} \ No newline at end of file diff --git a/tests/QuotesTest.php b/tests/QuotesTest.php index a1cb7fd..2d5123f 100644 --- a/tests/QuotesTest.php +++ b/tests/QuotesTest.php @@ -17,7 +17,7 @@ class QuotesTest extends TestCase { protected string $token = "company-token-test"; - protected string $url = "http://ninja.test:8000"; + protected string $url = "https://ninja.test"; public function testQuotes() { diff --git a/tests/RecurringInvoicesTest.php b/tests/RecurringInvoicesTest.php new file mode 100644 index 0000000..a192023 --- /dev/null +++ b/tests/RecurringInvoicesTest.php @@ -0,0 +1,84 @@ +token); + $ninja->setUrl($this->url); + + $client = $ninja->clients->create(['name' => 'Brand spanking new client']); + + $invoice = $ninja->recurring_invoices->create(['frequency_id'=>1,'client_id' => $client['data']['id']]); + + $invoices = $ninja->recurring_invoices->all(); + + $this->assertTrue(is_array($invoices)); + + } + + public function testInvoiceGet() + { + + $ninja = new InvoiceNinja($this->token); + $ninja->setUrl($this->url); + + $client = $ninja->clients->create(['name' => 'Brand spanking new client']); + + $invoice = $ninja->recurring_invoices->create(['frequency_id'=>1,'client_id' => $client['data']['id']]); + + $invoices = $ninja->recurring_invoices->get($invoice['data']['id']); + + $this->assertTrue(is_array($invoices)); + + } + + + public function testInvoicePut() + { + + $ninja = new InvoiceNinja($this->token); + $ninja->setUrl($this->url); + + $client = $ninja->clients->create(['name' => 'Brand spanking new client']); + + $invoice = $ninja->recurring_invoices->create(['frequency_id'=>1,'client_id' => $client['data']['id']]); + + $invoices = $ninja->recurring_invoices->update($invoice['data']['id'], ['discount' => '10']); + + $this->assertTrue(is_array($invoices)); + + } + + + public function testInvoicePost() + { + + $ninja = new InvoiceNinja($this->token); + $ninja->setUrl($this->url); + + $client = $ninja->clients->create(['name' => 'Brand spanking new client']); + $invoices = $ninja->recurring_invoices->create(['frequency_id'=>1,'client_id' => $client['data']['id']]); + + $this->assertTrue(is_array($invoices)); + + } +} \ No newline at end of file diff --git a/tests/StaticsTest.php b/tests/StaticsTest.php index bd458c6..089d11c 100644 --- a/tests/StaticsTest.php +++ b/tests/StaticsTest.php @@ -18,7 +18,7 @@ class StaticsTest extends TestCase { protected string $token = "company-token-test"; - protected string $url = "http://ninja.test:8000"; + protected string $url = "https://ninja.test"; public function testGetCurrencies() { diff --git a/tests/TasksTest.php b/tests/TasksTest.php new file mode 100644 index 0000000..594b0bb --- /dev/null +++ b/tests/TasksTest.php @@ -0,0 +1,77 @@ +token); + $ninja->setUrl($this->url); + + $taks = $ninja->tasks->all(); + + $this->assertTrue(is_array($taks)); + + } + + public function testTaskGet() + { + + $ninja = new InvoiceNinja($this->token); + $ninja->setUrl($this->url); + + $client = $ninja->clients->create(['name' => 'Brand spanking new client']); + $task = $ninja->tasks->create(['name' => 'Project', 'client_id' => $client['data']['id']]); + + $taks = $ninja->tasks->get($task['data']['id']); + + $this->assertTrue(is_array($taks)); + + } + + + public function testTaskPut() + { + + $ninja = new InvoiceNinja($this->token); + $ninja->setUrl($this->url); + + $client = $ninja->clients->create(['name' => 'Brand spanking new client']); + $task = $ninja->tasks->create(['name' => 'Project', 'client_id' => $client['data']['id']]); + + $taks = $ninja->tasks->update($task['data']['id'], ['name' => 'Project 2']); + + $this->assertTrue(is_array($taks)); + + } + + + public function testTaskPost() + { + + $ninja = new InvoiceNinja($this->token); + $ninja->setUrl($this->url); + + $client = $ninja->clients->create(['name' => 'Brand spanking new client']); + $taks = $ninja->tasks->create(['name' => 'Project', 'client_id' => $client['data']['id']]); + $this->assertTrue(is_array($taks)); + + } +} \ No newline at end of file diff --git a/tests/TaxRatesTest.php b/tests/TaxRatesTest.php index aa2f715..4cc3668 100644 --- a/tests/TaxRatesTest.php +++ b/tests/TaxRatesTest.php @@ -17,7 +17,7 @@ class TaxRatesTest extends TestCase { protected string $token = "company-token-test"; - protected string $url = "http://ninja.test:8000"; + protected string $url = "https://ninja.test"; public $faker; diff --git a/tests/VendorsTest.php b/tests/VendorsTest.php new file mode 100644 index 0000000..c732e2c --- /dev/null +++ b/tests/VendorsTest.php @@ -0,0 +1,83 @@ +token); + $ninja->setUrl($this->url); + + $vendors = $ninja->vendors->create(['name' => 'Brand spanking new vendor']); + + $this->assertTrue(is_array($vendors)); + + $vendors = $ninja->vendors->all(['balance' => '0:gt']); + + $this->assertTrue(is_array($vendors)); + + } + + public function testVendorGet() + { + + $ninja = new InvoiceNinja($this->token); + $ninja->setUrl($this->url); + + $vendor = $ninja->vendors->create(['name' => 'Brand spanking new vendor']); + + $this->assertTrue(is_array($vendor)); + + $ninja = new InvoiceNinja($this->token); + $ninja->setUrl($this->url); + + $vendors = $ninja->vendors->get($vendor['data']['id']); + + $this->assertTrue(is_array($vendors)); + + } + + + public function testVendorPut() + { + + $ninja = new InvoiceNinja($this->token); + $ninja->setUrl($this->url); + + $vendor = $ninja->vendors->create(['name' => 'Brand spanking new vendor']); + + $vendors = $ninja->vendors->update($vendor['data']['id'], ['name' => 'A new vendor name updated']); + + $this->assertTrue(is_array($vendors)); + + } + + + public function testVendorPost() + { + + $ninja = new InvoiceNinja($this->token); + $ninja->setUrl($this->url); + + $vendors = $ninja->vendors->create(['name' => 'Brand spanking new vendor']); + + $this->assertTrue(is_array($vendors)); + + } +} \ No newline at end of file