From 824e35aef76d1588e9e3be0acb2409d9a2e68b8f Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 19 Dec 2022 13:56:13 +1100 Subject: [PATCH 1/3] Add Purchase Orders and Subscriptions to SDK --- README.md | 3 + src/Endpoints/PurchaseOrders.php | 30 +++++ src/Endpoints/Subscriptions.php | 30 +++++ src/InvoiceNinja.php | 8 ++ tests/PurchaseOrdersTest.php | 218 +++++++++++++++++++++++++++++++ tests/SubscriptionsTest.php | 87 ++++++++++++ 6 files changed, 376 insertions(+) create mode 100644 src/Endpoints/PurchaseOrders.php create mode 100644 src/Endpoints/Subscriptions.php create mode 100644 tests/PurchaseOrdersTest.php create mode 100644 tests/SubscriptionsTest.php diff --git a/README.md b/README.md index 386fcf4..b26df7c 100644 --- a/README.md +++ b/README.md @@ -27,12 +27,15 @@ $invoices = $ninja->invoices->all(); - TaxRates - Statics - Expenses +- Expense Categories - Recurring Invoices - Credits - Projects - Tasks - Vendors - Companies +- Subscriptions +- Purchase Orders ### Retrieving Models diff --git a/src/Endpoints/PurchaseOrders.php b/src/Endpoints/PurchaseOrders.php new file mode 100644 index 0000000..c91dfb4 --- /dev/null +++ b/src/Endpoints/PurchaseOrders.php @@ -0,0 +1,30 @@ +ninja = $ninja; + } + +} + diff --git a/src/Endpoints/Subscriptions.php b/src/Endpoints/Subscriptions.php new file mode 100644 index 0000000..145fc54 --- /dev/null +++ b/src/Endpoints/Subscriptions.php @@ -0,0 +1,30 @@ +ninja = $ninja; + } + +} + diff --git a/src/InvoiceNinja.php b/src/InvoiceNinja.php index bd01ba0..c3e09df 100644 --- a/src/InvoiceNinja.php +++ b/src/InvoiceNinja.php @@ -24,9 +24,11 @@ use InvoiceNinja\Sdk\Endpoints\Payments; use InvoiceNinja\Sdk\Endpoints\Products; use InvoiceNinja\Sdk\Endpoints\Projects; +use InvoiceNinja\Sdk\Endpoints\PurchaseOrders; use InvoiceNinja\Sdk\Endpoints\Quotes; use InvoiceNinja\Sdk\Endpoints\RecurringInvoices; use InvoiceNinja\Sdk\Endpoints\Statics; +use InvoiceNinja\Sdk\Endpoints\Subscriptions; use InvoiceNinja\Sdk\Endpoints\Tasks; use InvoiceNinja\Sdk\Endpoints\TaxRates; use InvoiceNinja\Sdk\Endpoints\Vendors; @@ -77,6 +79,10 @@ class InvoiceNinja public GroupSettings $group_settings; + public Subscriptions $subscriptions; + + public PurchaseOrders $purchase_orders; + /** * @param string $token * @return void @@ -109,6 +115,8 @@ private function initialize() $this->companies = new Companies($this); $this->expense_categories = new ExpenseCategories($this); $this->group_settings = new GroupSettings($this); + $this->subscriptions = new Subscriptions($this); + $this->purchase_orders = new PurchaseOrders($this); return $this; } diff --git a/tests/PurchaseOrdersTest.php b/tests/PurchaseOrdersTest.php new file mode 100644 index 0000000..5774cb5 --- /dev/null +++ b/tests/PurchaseOrdersTest.php @@ -0,0 +1,218 @@ +token); + $ninja->setUrl($this->url); + + $client = $ninja->vendors->create(['name' => 'Brand spanking new client']); + + $invoice = $ninja->purchase_orders->create(['vendor_id' => $client['data']['id']]); + + $purchase_orders = $ninja->purchase_orders->all(); + + $this->assertTrue(is_array($purchase_orders)); + + } + + public function testPurchaseOrderGet() + { + + $ninja = new InvoiceNinja($this->token); + $ninja->setUrl($this->url); + + $client = $ninja->vendors->create(['name' => 'Brand spanking new client']); + + $invoice = $ninja->purchase_orders->create(['vendor_id' => $client['data']['id']]); + + $purchase_orders = $ninja->purchase_orders->get($invoice['data']['id']); + + $this->assertTrue(is_array($purchase_orders)); + + } + + + public function testPurchaseOrderPut() + { + + $ninja = new InvoiceNinja($this->token); + $ninja->setUrl($this->url); + + $client = $ninja->vendors->create(['name' => 'Brand spanking new client']); + + $invoice = $ninja->purchase_orders->create(['vendor_id' => $client['data']['id']]); + + $purchase_orders = $ninja->purchase_orders->update($invoice['data']['id'], ['discount' => '10']); + + $this->assertTrue(is_array($purchase_orders)); + + } + + + public function testPurchaseOrderPost() + { + + $ninja = new InvoiceNinja($this->token); + $ninja->setUrl($this->url); + + $client = $ninja->vendors->create(['name' => 'Brand spanking new client']); + + $purchase_orders = $ninja->purchase_orders->create(['vendor_id' => $client['data']['id']]); + + $this->assertTrue(is_array($purchase_orders)); + + } + + + public function testPurchaseOrderPostWithItems() + { + + $ninja = new InvoiceNinja($this->token); + $ninja->setUrl($this->url); + + $client = $ninja->vendors->create(['name' => 'Brand spanking new client']); + + $invoice = [ + 'vendor_id' => $client['data']['id'], + 'line_items' => [ + [ + 'product_key' => 'test', + 'notes' => 'description', + 'quantity' => 1, + 'cost' => 10 + ] + ], + ]; + + $invoice = $ninja->purchase_orders->create($invoice); + + $this->assertTrue(is_array($invoice)); + $this->assertEquals(10, $invoice['data']['amount']); + + + } + + public function testPurchaseOrderPostWithMultiItems() + { + + $ninja = new InvoiceNinja($this->token); + $ninja->setUrl($this->url); + + $client = $ninja->vendors->create(['name' => 'Brand spanking new client']); + + $invoice = [ + 'vendor_id' => $client['data']['id'], + 'line_items' => [ + [ + 'product_key' => 'test', + 'notes' => 'description', + 'quantity' => 1, + 'cost' => 10 + ], + [ + 'product_key' => 'test', + 'notes' => 'description', + 'quantity' => 1, + 'cost' => 10 + ], + ], + ]; + + $invoice = $ninja->purchase_orders->create($invoice); + + $this->assertTrue(is_array($invoice)); + $this->assertEquals(20, $invoice['data']['amount']); + + + } + + public function testPurchaseOrderPostWithMultiItemsMarkSent() + { + + $ninja = new InvoiceNinja($this->token); + $ninja->setUrl($this->url); + + $client = $ninja->vendors->create(['name' => 'Brand spanking new client']); + + $invoice = [ + 'vendor_id' => $client['data']['id'], + 'line_items' => [ + [ + 'product_key' => 'test', + 'notes' => 'description', + 'quantity' => 1, + 'cost' => 10 + ], + [ + 'product_key' => 'test', + 'notes' => 'description', + 'quantity' => 1, + 'cost' => 10 + ], + ], + ]; + + $invoice = $ninja->purchase_orders->create($invoice, ['mark_sent' => "true"]); + + $this->assertTrue(is_array($invoice)); + + $this->assertEquals(20, $invoice['data']['amount']); + $this->assertEquals(20, $invoice['data']['balance']); + + } + + public function testDownloadPurchaseOrder() + { + + $ninja = new InvoiceNinja($this->token); + $ninja->setUrl($this->url); + + $client = $ninja->vendors->create(['name' => 'Brand spanking new client']); + + $invoice = [ + 'vendor_id' => $client['data']['id'], + 'line_items' => [ + [ + 'product_key' => 'test', + 'notes' => 'description', + 'quantity' => 1, + 'cost' => 10 + ], + [ + 'product_key' => 'test', + 'notes' => 'description', + 'quantity' => 1, + 'cost' => 10 + ], + ], + ]; + + $invoice = $ninja->purchase_orders->create($invoice, ['mark_sent' => "true"]); + + $download = $ninja->purchase_orders->download([$invoice['data']['id']]); + + $this->assertNotNull($download); + + } + +} \ No newline at end of file diff --git a/tests/SubscriptionsTest.php b/tests/SubscriptionsTest.php new file mode 100644 index 0000000..66ce642 --- /dev/null +++ b/tests/SubscriptionsTest.php @@ -0,0 +1,87 @@ +faker = \Faker\Factory::create(); + } + + public function testSubscriptions() + { + $ninja = new InvoiceNinja($this->token); + $ninja->setUrl($this->url); + + $subscriptions = $ninja->subscriptions->create(['name' => $this->faker->firstName]); + + $this->assertTrue(is_array($subscriptions)); + + } + + public function testSubscriptionGet() + { + + $ninja = new InvoiceNinja($this->token); + $ninja->setUrl($this->url); + + $subscription = $ninja->subscriptions->create(['name' => $this->faker->firstName]); + + $this->assertTrue(is_array($subscription)); + + $ninja = new InvoiceNinja($this->token); + $ninja->setUrl($this->url); + + $subscriptions = $ninja->subscriptions->get($subscription['data']['id']); + + $this->assertTrue(is_array($subscriptions)); + + } + + + public function testSubscriptionPut() + { + + $ninja = new InvoiceNinja($this->token); + $ninja->setUrl($this->url); + + $subscription = $ninja->subscriptions->create(['name' => $this->faker->firstName]); + + $subscriptions = $ninja->subscriptions->update($subscription['data']['id'], ['name' => $this->faker->firstName]); + + $this->assertTrue(is_array($subscriptions)); + + } + + + public function testSubscriptionPost() + { + + $ninja = new InvoiceNinja($this->token); + $ninja->setUrl($this->url); + + $subscriptions = $ninja->subscriptions->create(['name' => $this->faker->firstName]); + + $this->assertTrue(is_array($subscriptions)); + + } +} \ No newline at end of file From 074591aaf8d9994fc7268d1bcd8b69f18dfe45c1 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 19 Dec 2022 14:17:52 +1100 Subject: [PATCH 2/3] Bank integrations and Bank Transactions --- src/Endpoints/BankIntegrations.php | 30 ++++++++++ src/Endpoints/BankTransactions.php | 30 ++++++++++ src/InvoiceNinja.php | 8 +++ tests/BankIntegrationsTest.php | 87 +++++++++++++++++++++++++++ tests/BankTransactionsTest.php | 95 ++++++++++++++++++++++++++++++ 5 files changed, 250 insertions(+) create mode 100644 src/Endpoints/BankIntegrations.php create mode 100644 src/Endpoints/BankTransactions.php create mode 100644 tests/BankIntegrationsTest.php create mode 100644 tests/BankTransactionsTest.php diff --git a/src/Endpoints/BankIntegrations.php b/src/Endpoints/BankIntegrations.php new file mode 100644 index 0000000..ac36baf --- /dev/null +++ b/src/Endpoints/BankIntegrations.php @@ -0,0 +1,30 @@ +ninja = $ninja; + } + +} + diff --git a/src/Endpoints/BankTransactions.php b/src/Endpoints/BankTransactions.php new file mode 100644 index 0000000..0a8560c --- /dev/null +++ b/src/Endpoints/BankTransactions.php @@ -0,0 +1,30 @@ +ninja = $ninja; + } + +} + diff --git a/src/InvoiceNinja.php b/src/InvoiceNinja.php index c3e09df..94b3384 100644 --- a/src/InvoiceNinja.php +++ b/src/InvoiceNinja.php @@ -14,6 +14,8 @@ use GuzzleHttp\Client; use GuzzleHttp\Exception\GuzzleException; use GuzzleHttp\Exception\RequestException; +use InvoiceNinja\Sdk\Endpoints\BankIntegrations; +use InvoiceNinja\Sdk\Endpoints\BankTransactions; use InvoiceNinja\Sdk\Endpoints\Clients; use InvoiceNinja\Sdk\Endpoints\Companies; use InvoiceNinja\Sdk\Endpoints\Credits; @@ -82,6 +84,10 @@ class InvoiceNinja public Subscriptions $subscriptions; public PurchaseOrders $purchase_orders; + + public BankTransactions $bank_transactions; + + public BankIntegrations $bank_integrations; /** * @param string $token @@ -117,6 +123,8 @@ private function initialize() $this->group_settings = new GroupSettings($this); $this->subscriptions = new Subscriptions($this); $this->purchase_orders = new PurchaseOrders($this); + $this->bank_transactions = new BankTransactions($this); + $this->bank_integrations = new BankIntegrations($this); return $this; } diff --git a/tests/BankIntegrationsTest.php b/tests/BankIntegrationsTest.php new file mode 100644 index 0000000..1034604 --- /dev/null +++ b/tests/BankIntegrationsTest.php @@ -0,0 +1,87 @@ +faker = \Faker\Factory::create(); + } + + public function testBankIntegrations() + { + $ninja = new InvoiceNinja($this->token); + $ninja->setUrl($this->url); + + $bank_integrations = $ninja->bank_integrations->create(['bank_account_name' => $this->faker->firstName]); + + $this->assertTrue(is_array($bank_integrations)); + + } + + public function testBankIntegrationGet() + { + + $ninja = new InvoiceNinja($this->token); + $ninja->setUrl($this->url); + + $subscription = $ninja->bank_integrations->create(['bank_account_name' => $this->faker->firstName]); + + $this->assertTrue(is_array($subscription)); + + $ninja = new InvoiceNinja($this->token); + $ninja->setUrl($this->url); + + $bank_integrations = $ninja->bank_integrations->get($subscription['data']['id']); + + $this->assertTrue(is_array($bank_integrations)); + + } + + + public function testBankIntegrationPut() + { + + $ninja = new InvoiceNinja($this->token); + $ninja->setUrl($this->url); + + $subscription = $ninja->bank_integrations->create(['bank_account_name' => $this->faker->firstName]); + + $bank_integrations = $ninja->bank_integrations->update($subscription['data']['id'], ['bank_account_name' => $this->faker->firstName]); + + $this->assertTrue(is_array($bank_integrations)); + + } + + + public function testBankIntegrationPost() + { + + $ninja = new InvoiceNinja($this->token); + $ninja->setUrl($this->url); + + $bank_integrations = $ninja->bank_integrations->create(['bank_account_name' => $this->faker->firstName]); + + $this->assertTrue(is_array($bank_integrations)); + + } +} \ No newline at end of file diff --git a/tests/BankTransactionsTest.php b/tests/BankTransactionsTest.php new file mode 100644 index 0000000..74c9275 --- /dev/null +++ b/tests/BankTransactionsTest.php @@ -0,0 +1,95 @@ +faker = \Faker\Factory::create(); + } + + public function testBankTransactions() + { + $ninja = new InvoiceNinja($this->token); + $ninja->setUrl($this->url); + + $bank_integrations = $ninja->bank_integrations->create(['bank_account_name' => $this->faker->firstName]); + + $subscriptions = $ninja->bank_transactions->create(['bank_integration_id' => $bank_integrations['data']['id'], 'name' => $this->faker->firstName]); + + $this->assertTrue(is_array($subscriptions)); + + } + + public function testSubscriptionGet() + { + + $ninja = new InvoiceNinja($this->token); + $ninja->setUrl($this->url); + + $bank_integrations = $ninja->bank_integrations->create(['bank_account_name' => $this->faker->firstName]); + + $subscription = $ninja->bank_transactions->create(['bank_integration_id' => $bank_integrations['data']['id'],'name' => $this->faker->firstName]); + + $this->assertTrue(is_array($subscription)); + + $ninja = new InvoiceNinja($this->token); + $ninja->setUrl($this->url); + + $subscriptions = $ninja->bank_transactions->get($subscription['data']['id']); + + $this->assertTrue(is_array($subscriptions)); + + } + + + public function testSubscriptionPut() + { + + $ninja = new InvoiceNinja($this->token); + $ninja->setUrl($this->url); + + $bank_integrations = $ninja->bank_integrations->create(['bank_account_name' => $this->faker->firstName]); + + $subscription = $ninja->bank_transactions->create(['bank_integration_id' => $bank_integrations['data']['id'], 'name' => $this->faker->firstName]); + + $subscriptions = $ninja->bank_transactions->update($subscription['data']['id'], ['bank_integration_id' => $bank_integrations['data']['id'], 'name' => $this->faker->firstName, 'date' => '2022-10-10', 'amount' => 100]); + + $this->assertTrue(is_array($subscriptions)); + + } + + + public function testSubscriptionPost() + { + + $ninja = new InvoiceNinja($this->token); + $ninja->setUrl($this->url); + + $bank_integrations = $ninja->bank_integrations->create(['bank_account_name' => $this->faker->firstName]); + + $subscriptions = $ninja->bank_transactions->create(['bank_integration_id' => $bank_integrations['data']['id'], 'name' => $this->faker->firstName]); + + $this->assertTrue(is_array($subscriptions)); + + } +} \ No newline at end of file From bb508f05ea89c9d6235d3070d63a681c13971a48 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 19 Dec 2022 14:21:47 +1100 Subject: [PATCH 3/3] Tests for all endpoints --- README.md | 2 ++ tests/BankIntegrationsTest.php | 10 +++---- tests/BankTransactionsTest.php | 28 ++++++++++---------- tests/PurchaseOrdersTest.php | 48 +++++++++++++++++----------------- 4 files changed, 45 insertions(+), 43 deletions(-) diff --git a/README.md b/README.md index b26df7c..eec5e3d 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,8 @@ $invoices = $ninja->invoices->all(); - Companies - Subscriptions - Purchase Orders +- Bank Integrations +- Bank Transactions ### Retrieving Models diff --git a/tests/BankIntegrationsTest.php b/tests/BankIntegrationsTest.php index 1034604..ac55c44 100644 --- a/tests/BankIntegrationsTest.php +++ b/tests/BankIntegrationsTest.php @@ -44,14 +44,14 @@ public function testBankIntegrationGet() $ninja = new InvoiceNinja($this->token); $ninja->setUrl($this->url); - $subscription = $ninja->bank_integrations->create(['bank_account_name' => $this->faker->firstName]); + $integration = $ninja->bank_integrations->create(['bank_account_name' => $this->faker->firstName]); - $this->assertTrue(is_array($subscription)); + $this->assertTrue(is_array($integration)); $ninja = new InvoiceNinja($this->token); $ninja->setUrl($this->url); - $bank_integrations = $ninja->bank_integrations->get($subscription['data']['id']); + $bank_integrations = $ninja->bank_integrations->get($integration['data']['id']); $this->assertTrue(is_array($bank_integrations)); @@ -64,9 +64,9 @@ public function testBankIntegrationPut() $ninja = new InvoiceNinja($this->token); $ninja->setUrl($this->url); - $subscription = $ninja->bank_integrations->create(['bank_account_name' => $this->faker->firstName]); + $integration = $ninja->bank_integrations->create(['bank_account_name' => $this->faker->firstName]); - $bank_integrations = $ninja->bank_integrations->update($subscription['data']['id'], ['bank_account_name' => $this->faker->firstName]); + $bank_integrations = $ninja->bank_integrations->update($integration['data']['id'], ['bank_account_name' => $this->faker->firstName]); $this->assertTrue(is_array($bank_integrations)); diff --git a/tests/BankTransactionsTest.php b/tests/BankTransactionsTest.php index 74c9275..af5a767 100644 --- a/tests/BankTransactionsTest.php +++ b/tests/BankTransactionsTest.php @@ -34,13 +34,13 @@ public function testBankTransactions() $bank_integrations = $ninja->bank_integrations->create(['bank_account_name' => $this->faker->firstName]); - $subscriptions = $ninja->bank_transactions->create(['bank_integration_id' => $bank_integrations['data']['id'], 'name' => $this->faker->firstName]); + $transactions = $ninja->bank_transactions->create(['bank_integration_id' => $bank_integrations['data']['id'], 'name' => $this->faker->firstName]); - $this->assertTrue(is_array($subscriptions)); + $this->assertTrue(is_array($transactions)); } - public function testSubscriptionGet() + public function testTransactionGet() { $ninja = new InvoiceNinja($this->token); @@ -48,21 +48,21 @@ public function testSubscriptionGet() $bank_integrations = $ninja->bank_integrations->create(['bank_account_name' => $this->faker->firstName]); - $subscription = $ninja->bank_transactions->create(['bank_integration_id' => $bank_integrations['data']['id'],'name' => $this->faker->firstName]); + $transaction = $ninja->bank_transactions->create(['bank_integration_id' => $bank_integrations['data']['id'],'name' => $this->faker->firstName]); - $this->assertTrue(is_array($subscription)); + $this->assertTrue(is_array($transaction)); $ninja = new InvoiceNinja($this->token); $ninja->setUrl($this->url); - $subscriptions = $ninja->bank_transactions->get($subscription['data']['id']); + $transactions = $ninja->bank_transactions->get($transaction['data']['id']); - $this->assertTrue(is_array($subscriptions)); + $this->assertTrue(is_array($transactions)); } - public function testSubscriptionPut() + public function testTransactionPut() { $ninja = new InvoiceNinja($this->token); @@ -70,16 +70,16 @@ public function testSubscriptionPut() $bank_integrations = $ninja->bank_integrations->create(['bank_account_name' => $this->faker->firstName]); - $subscription = $ninja->bank_transactions->create(['bank_integration_id' => $bank_integrations['data']['id'], 'name' => $this->faker->firstName]); + $transaction = $ninja->bank_transactions->create(['bank_integration_id' => $bank_integrations['data']['id'], 'name' => $this->faker->firstName]); - $subscriptions = $ninja->bank_transactions->update($subscription['data']['id'], ['bank_integration_id' => $bank_integrations['data']['id'], 'name' => $this->faker->firstName, 'date' => '2022-10-10', 'amount' => 100]); + $transactions = $ninja->bank_transactions->update($transaction['data']['id'], ['bank_integration_id' => $bank_integrations['data']['id'], 'name' => $this->faker->firstName, 'date' => '2022-10-10', 'amount' => 100]); - $this->assertTrue(is_array($subscriptions)); + $this->assertTrue(is_array($transactions)); } - public function testSubscriptionPost() + public function testTransactionPost() { $ninja = new InvoiceNinja($this->token); @@ -87,9 +87,9 @@ public function testSubscriptionPost() $bank_integrations = $ninja->bank_integrations->create(['bank_account_name' => $this->faker->firstName]); - $subscriptions = $ninja->bank_transactions->create(['bank_integration_id' => $bank_integrations['data']['id'], 'name' => $this->faker->firstName]); + $transactions = $ninja->bank_transactions->create(['bank_integration_id' => $bank_integrations['data']['id'], 'name' => $this->faker->firstName]); - $this->assertTrue(is_array($subscriptions)); + $this->assertTrue(is_array($transactions)); } } \ No newline at end of file diff --git a/tests/PurchaseOrdersTest.php b/tests/PurchaseOrdersTest.php index 5774cb5..697fcae 100644 --- a/tests/PurchaseOrdersTest.php +++ b/tests/PurchaseOrdersTest.php @@ -1,10 +1,10 @@ vendors->create(['name' => 'Brand spanking new client']); - $invoice = $ninja->purchase_orders->create(['vendor_id' => $client['data']['id']]); + $purchase_order = $ninja->purchase_orders->create(['vendor_id' => $client['data']['id']]); $purchase_orders = $ninja->purchase_orders->all(); @@ -43,9 +43,9 @@ public function testPurchaseOrderGet() $client = $ninja->vendors->create(['name' => 'Brand spanking new client']); - $invoice = $ninja->purchase_orders->create(['vendor_id' => $client['data']['id']]); + $purchase_order = $ninja->purchase_orders->create(['vendor_id' => $client['data']['id']]); - $purchase_orders = $ninja->purchase_orders->get($invoice['data']['id']); + $purchase_orders = $ninja->purchase_orders->get($purchase_order['data']['id']); $this->assertTrue(is_array($purchase_orders)); @@ -60,9 +60,9 @@ public function testPurchaseOrderPut() $client = $ninja->vendors->create(['name' => 'Brand spanking new client']); - $invoice = $ninja->purchase_orders->create(['vendor_id' => $client['data']['id']]); + $purchase_order = $ninja->purchase_orders->create(['vendor_id' => $client['data']['id']]); - $purchase_orders = $ninja->purchase_orders->update($invoice['data']['id'], ['discount' => '10']); + $purchase_orders = $ninja->purchase_orders->update($purchase_order['data']['id'], ['discount' => '10']); $this->assertTrue(is_array($purchase_orders)); @@ -92,7 +92,7 @@ public function testPurchaseOrderPostWithItems() $client = $ninja->vendors->create(['name' => 'Brand spanking new client']); - $invoice = [ + $purchase_order = [ 'vendor_id' => $client['data']['id'], 'line_items' => [ [ @@ -104,10 +104,10 @@ public function testPurchaseOrderPostWithItems() ], ]; - $invoice = $ninja->purchase_orders->create($invoice); + $purchase_order = $ninja->purchase_orders->create($purchase_order); - $this->assertTrue(is_array($invoice)); - $this->assertEquals(10, $invoice['data']['amount']); + $this->assertTrue(is_array($purchase_order)); + $this->assertEquals(10, $purchase_order['data']['amount']); } @@ -120,7 +120,7 @@ public function testPurchaseOrderPostWithMultiItems() $client = $ninja->vendors->create(['name' => 'Brand spanking new client']); - $invoice = [ + $purchase_order = [ 'vendor_id' => $client['data']['id'], 'line_items' => [ [ @@ -138,10 +138,10 @@ public function testPurchaseOrderPostWithMultiItems() ], ]; - $invoice = $ninja->purchase_orders->create($invoice); + $purchase_order = $ninja->purchase_orders->create($purchase_order); - $this->assertTrue(is_array($invoice)); - $this->assertEquals(20, $invoice['data']['amount']); + $this->assertTrue(is_array($purchase_order)); + $this->assertEquals(20, $purchase_order['data']['amount']); } @@ -154,7 +154,7 @@ public function testPurchaseOrderPostWithMultiItemsMarkSent() $client = $ninja->vendors->create(['name' => 'Brand spanking new client']); - $invoice = [ + $purchase_order = [ 'vendor_id' => $client['data']['id'], 'line_items' => [ [ @@ -172,12 +172,12 @@ public function testPurchaseOrderPostWithMultiItemsMarkSent() ], ]; - $invoice = $ninja->purchase_orders->create($invoice, ['mark_sent' => "true"]); + $purchase_order = $ninja->purchase_orders->create($purchase_order, ['mark_sent' => "true"]); - $this->assertTrue(is_array($invoice)); + $this->assertTrue(is_array($purchase_order)); - $this->assertEquals(20, $invoice['data']['amount']); - $this->assertEquals(20, $invoice['data']['balance']); + $this->assertEquals(20, $purchase_order['data']['amount']); + $this->assertEquals(20, $purchase_order['data']['balance']); } @@ -189,7 +189,7 @@ public function testDownloadPurchaseOrder() $client = $ninja->vendors->create(['name' => 'Brand spanking new client']); - $invoice = [ + $purchase_order = [ 'vendor_id' => $client['data']['id'], 'line_items' => [ [ @@ -207,9 +207,9 @@ public function testDownloadPurchaseOrder() ], ]; - $invoice = $ninja->purchase_orders->create($invoice, ['mark_sent' => "true"]); + $purchase_order = $ninja->purchase_orders->create($purchase_order, ['mark_sent' => "true"]); - $download = $ninja->purchase_orders->download([$invoice['data']['id']]); + $download = $ninja->purchase_orders->download([$purchase_order['data']['id']]); $this->assertNotNull($download);