From b667c9283ad71b8cc7007ffa85686101b5f3e659 Mon Sep 17 00:00:00 2001 From: Richard Pettifer <129283710+rpettifer@users.noreply.github.com> Date: Mon, 17 Jun 2024 15:14:23 +0100 Subject: [PATCH 1/3] Update Xero.php --- src/Xero.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Xero.php b/src/Xero.php index c10d889..57d428c 100755 --- a/src/Xero.php +++ b/src/Xero.php @@ -4,6 +4,7 @@ use Dcblogdev\Xero\Models\XeroToken; use Dcblogdev\Xero\Resources\Contacts; +use Dcblogdev\Xero\Resources\CreditNotes; use Dcblogdev\Xero\Resources\Invoices; use Dcblogdev\Xero\Resources\Webhooks; use Exception; @@ -42,6 +43,11 @@ public function contacts(): Contacts return new Contacts(); } + public function creditnotes(): CreditNotes + { + return new CreditNotes(); + } + public function invoices(): Invoices { return new Invoices(); From ab75bd3652b78eb4649acc8287fde50b6b9e5101 Mon Sep 17 00:00:00 2001 From: Richard Pettifer <129283710+rpettifer@users.noreply.github.com> Date: Mon, 17 Jun 2024 15:14:40 +0100 Subject: [PATCH 2/3] Add files via upload --- src/Resources/CreditNotes.php | 53 +++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/Resources/CreditNotes.php diff --git a/src/Resources/CreditNotes.php b/src/Resources/CreditNotes.php new file mode 100644 index 0000000..68c3ec1 --- /dev/null +++ b/src/Resources/CreditNotes.php @@ -0,0 +1,53 @@ +queryString[$key] = $value; + + return $this; + } + + public function get(): array + { + $queryString = $this->formatQueryStrings($this->queryString); + + $result = parent::get('CreditNotes?'.$queryString); + + return $result['body']['CreditNotes']; + } + + public function find(string $contactId): array + { + $result = parent::get('CreditNotes/'.$contactId); + + return $result['body']['CreditNotes'][0]; + } + + public function update(string $contactId, array $data): array + { + $result = $this->post('CreditNotes/'.$contactId, $data); + + return $result['body']['CreditNotes'][0]; + } + + public function store(array $data): array + { + $result = $this->post('CreditNotes', $data); + + return $result['body']['CreditNotes'][0]; + } +} From eb17681ed83c7f88abc0803035ce1354c0383d83 Mon Sep 17 00:00:00 2001 From: Richard Pettifer Date: Mon, 17 Jun 2024 15:22:24 +0100 Subject: [PATCH 3/3] Added CreditNotesTest --- tests/Resources/CreditNotesTest.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 tests/Resources/CreditNotesTest.php diff --git a/tests/Resources/CreditNotesTest.php b/tests/Resources/CreditNotesTest.php new file mode 100644 index 0000000..c616981 --- /dev/null +++ b/tests/Resources/CreditNotesTest.php @@ -0,0 +1,17 @@ +filter('bogus', 1) + ->get(); +})->throws(InvalidArgumentException::class, "Filter option 'bogus' is not valid."); + +test('filter returns object', function(){ + + $filter = (new CreditNotes())->filter('ids', '1234'); + + expect($filter)->toBeObject(); +}); \ No newline at end of file