-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #96 from turbo124/main
Update for all endpoints
- Loading branch information
Showing
10 changed files
with
628 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) 2022. 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 BankIntegrations extends BaseEntity | ||
{ | ||
|
||
protected InvoiceNinja $ninja; | ||
|
||
protected string $uri = "/api/v1/bank_integrations"; | ||
|
||
public function __construct(InvoiceNinja $ninja) | ||
{ | ||
$this->ninja = $ninja; | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) 2022. 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 BankTransactions extends BaseEntity | ||
{ | ||
|
||
protected InvoiceNinja $ninja; | ||
|
||
protected string $uri = "/api/v1/bank_transactions"; | ||
|
||
public function __construct(InvoiceNinja $ninja) | ||
{ | ||
$this->ninja = $ninja; | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) 2022. 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 PurchaseOrders extends BaseEntity | ||
{ | ||
|
||
protected InvoiceNinja $ninja; | ||
|
||
protected string $uri = "/api/v1/purchase_orders"; | ||
|
||
public function __construct(InvoiceNinja $ninja) | ||
{ | ||
$this->ninja = $ninja; | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) 2022. 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 Subscriptions extends BaseEntity | ||
{ | ||
|
||
protected InvoiceNinja $ninja; | ||
|
||
protected string $uri = "/api/v1/subscriptions"; | ||
|
||
public function __construct(InvoiceNinja $ninja) | ||
{ | ||
$this->ninja = $ninja; | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?php | ||
/** | ||
* Invoice Ninja (https://invoiceninja.com). | ||
* | ||
* @link https://github.com/invoiceninja/sdk-php source repository | ||
* | ||
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com) | ||
* | ||
* @license https://opensource.org/licenses/MIT | ||
*/ | ||
|
||
namespace InvoiceNinja\Sdk\Tests; | ||
|
||
use InvoiceNinja\Sdk\InvoiceNinja; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class BankIntegrationsTest extends TestCase | ||
{ | ||
protected string $token = "company-token-test"; | ||
protected string $url = "http://ninja.test:8000"; | ||
|
||
|
||
|
||
public function setUp() :void | ||
{ | ||
parent::setUp(); | ||
$this->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); | ||
|
||
$integration = $ninja->bank_integrations->create(['bank_account_name' => $this->faker->firstName]); | ||
|
||
$this->assertTrue(is_array($integration)); | ||
|
||
$ninja = new InvoiceNinja($this->token); | ||
$ninja->setUrl($this->url); | ||
|
||
$bank_integrations = $ninja->bank_integrations->get($integration['data']['id']); | ||
|
||
$this->assertTrue(is_array($bank_integrations)); | ||
|
||
} | ||
|
||
|
||
public function testBankIntegrationPut() | ||
{ | ||
|
||
$ninja = new InvoiceNinja($this->token); | ||
$ninja->setUrl($this->url); | ||
|
||
$integration = $ninja->bank_integrations->create(['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)); | ||
|
||
} | ||
|
||
|
||
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)); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<?php | ||
/** | ||
* Invoice Ninja (https://invoiceninja.com). | ||
* | ||
* @link https://github.com/invoiceninja/sdk-php source repository | ||
* | ||
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com) | ||
* | ||
* @license https://opensource.org/licenses/MIT | ||
*/ | ||
|
||
namespace InvoiceNinja\Sdk\Tests; | ||
|
||
use InvoiceNinja\Sdk\InvoiceNinja; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class BankTransactionsTest extends TestCase | ||
{ | ||
protected string $token = "company-token-test"; | ||
protected string $url = "http://ninja.test:8000"; | ||
|
||
|
||
|
||
public function setUp() :void | ||
{ | ||
parent::setUp(); | ||
$this->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]); | ||
|
||
$transactions = $ninja->bank_transactions->create(['bank_integration_id' => $bank_integrations['data']['id'], 'name' => $this->faker->firstName]); | ||
|
||
$this->assertTrue(is_array($transactions)); | ||
|
||
} | ||
|
||
public function testTransactionGet() | ||
{ | ||
|
||
$ninja = new InvoiceNinja($this->token); | ||
$ninja->setUrl($this->url); | ||
|
||
$bank_integrations = $ninja->bank_integrations->create(['bank_account_name' => $this->faker->firstName]); | ||
|
||
$transaction = $ninja->bank_transactions->create(['bank_integration_id' => $bank_integrations['data']['id'],'name' => $this->faker->firstName]); | ||
|
||
$this->assertTrue(is_array($transaction)); | ||
|
||
$ninja = new InvoiceNinja($this->token); | ||
$ninja->setUrl($this->url); | ||
|
||
$transactions = $ninja->bank_transactions->get($transaction['data']['id']); | ||
|
||
$this->assertTrue(is_array($transactions)); | ||
|
||
} | ||
|
||
|
||
public function testTransactionPut() | ||
{ | ||
|
||
$ninja = new InvoiceNinja($this->token); | ||
$ninja->setUrl($this->url); | ||
|
||
$bank_integrations = $ninja->bank_integrations->create(['bank_account_name' => $this->faker->firstName]); | ||
|
||
$transaction = $ninja->bank_transactions->create(['bank_integration_id' => $bank_integrations['data']['id'], 'name' => $this->faker->firstName]); | ||
|
||
$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($transactions)); | ||
|
||
} | ||
|
||
|
||
public function testTransactionPost() | ||
{ | ||
|
||
$ninja = new InvoiceNinja($this->token); | ||
$ninja->setUrl($this->url); | ||
|
||
$bank_integrations = $ninja->bank_integrations->create(['bank_account_name' => $this->faker->firstName]); | ||
|
||
$transactions = $ninja->bank_transactions->create(['bank_integration_id' => $bank_integrations['data']['id'], 'name' => $this->faker->firstName]); | ||
|
||
$this->assertTrue(is_array($transactions)); | ||
|
||
} | ||
} |
Oops, something went wrong.