From 52eb321f738cf5b87ae59fd033b82bb4e89c153f Mon Sep 17 00:00:00 2001 From: marcorivm Date: Fri, 17 Jun 2022 17:11:45 -0500 Subject: [PATCH] Add Customer, InvoiceItem and Invoice repositories Signed-off-by: marcorivm --- src/Connector.php | 33 +++++++++ src/Repositories/CustomerRepository.php | 57 +++++++++++++++ src/Repositories/InvoiceItemRepository.php | 67 ++++++++++++++++++ src/Repositories/InvoiceRepository.php | 80 ++++++++++++++++++++++ 4 files changed, 237 insertions(+) create mode 100644 src/Repositories/CustomerRepository.php create mode 100644 src/Repositories/InvoiceItemRepository.php create mode 100644 src/Repositories/InvoiceRepository.php diff --git a/src/Connector.php b/src/Connector.php index 9c85501..8d0a44d 100644 --- a/src/Connector.php +++ b/src/Connector.php @@ -88,6 +88,17 @@ public function charges(): Repositories\ChargeRepository ); } + /** + * @return Repositories\CustomerRepository + */ + public function customers(): Repositories\CustomerRepository + { + return new Repositories\CustomerRepository( + app(Client::class), + $this->accountId() + ); + } + /** * @return Repositories\EventRepository */ @@ -99,6 +110,28 @@ public function events(): Repositories\EventRepository ); } + /** + * @return Repositories\InvoiceRepository + */ + public function invoices(): Repositories\InvoiceRepository + { + return new Repositories\InvoiceRepository( + app(Client::class), + $this->accountId() + ); + } + + /** + * @return Repositories\InvoiceItemRepository + */ + public function invoiceItems(): Repositories\InvoiceItemRepository + { + return new Repositories\InvoiceItemRepository( + app(Client::class), + $this->accountId() + ); + } + /** * Create a payment intents client for the provided account. * diff --git a/src/Repositories/CustomerRepository.php b/src/Repositories/CustomerRepository.php new file mode 100644 index 0000000..101a659 --- /dev/null +++ b/src/Repositories/CustomerRepository.php @@ -0,0 +1,57 @@ +params($params); + + return $this->send( + 'create', + $this->params ?: null, + $this->options ?: null + ); + } + + /** + * @inheritDoc + */ + protected function fqn(): string + { + return Customer::class; + } +} diff --git a/src/Repositories/InvoiceItemRepository.php b/src/Repositories/InvoiceItemRepository.php new file mode 100644 index 0000000..7a054a2 --- /dev/null +++ b/src/Repositories/InvoiceItemRepository.php @@ -0,0 +1,67 @@ +params($params)->params( + compact('customer') + ); + + return $this->send( + 'create', + $this->params ?: null, + $this->options ?: null + ); + } + + /** + * @inheritDoc + */ + protected function fqn(): string + { + return InvoiceItem::class; + } +} diff --git a/src/Repositories/InvoiceRepository.php b/src/Repositories/InvoiceRepository.php new file mode 100644 index 0000000..08d65db --- /dev/null +++ b/src/Repositories/InvoiceRepository.php @@ -0,0 +1,80 @@ +params($params)->params( + compact('customer') + ); + + return $this->send( + 'create', + $this->params ?: null, + $this->options ?: null + ); + } + + /** + * Send an invoice to the customer. + * + * @param iterable|array $params + * additional optional parameters. + * @return Invoice + */ + public function sendInvoice(iterable $params = []): Invoice + { + $this->params($params); + + return $this->send( + 'sendInvoice', + $this->params ?: null, + $this->options ?: null + ); + } + + /** + * @inheritDoc + */ + protected function fqn(): string + { + return Invoice::class; + } +}