From ae3fb8451a93b0e0c98e01715aa51bc859ce35d3 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 16 Sep 2021 17:05:19 +1000 Subject: [PATCH] Docs for SDK --- README.md | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 81 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4bb36d2..679dd6d 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,37 @@ Retrieve all clients $clients = $ninja->clients->all(); ``` +You can perform complex filtering on the ->all() method. + +Query parameters can be chained together to form complex queries. The current supported values are: + +**per_page**: The number of clients per page you want returned +**page**: The page number +**include**: A comma separated list of relations to include ie. contacts,documents,gateway_tokens +**balance**: A query to return clients with a balance using an operator and value + - ie ?balance=lt:10 Returns clients with a balance less than 10 + - available operators lt, lte, gt, gte, eq +**between_balance**: Returns clients with a balance between two values + - ie ?between_balance=10:20 - Returns clients with a balance between 10 and 20 +**email**: Returns clients with a contacts.email field equal to an email +**id_number**: Search by id_number +**number**: Search by number +**filter**: Search across multiple columns (name, id_number, first_name, last_name, email, custom_value1, custom_value2, custom_value3, custom_value4) +**created_at**: Search by created at (Unix timestamp) +**is_deleted**: Search using is_deleted boolean flag + +For example, + +```php +$clients = $ninja->clients->all([ + 'balance' => 'lt:10', // get all clients with a balance less than 10 + 'per_page' => 10, // return 10 results per page + 'page' => 2, // paginate to page 2 + 'include' => 'documents', // include the documents relationship +]); + +``` + Retrieve a client by its primary key. ```php $client = $ninja->clients->get("CLIENT_HASHED_ID"); @@ -59,7 +90,54 @@ Create an invoice $client = $ninja->invoices->create(['client_id' => CLIENT_HASHED_ID]); ``` -Download an invoice PDF + +When creating an invoice, you can perform actions on the invoice in a single call, for example, say you wish to create an invoice and also apply a payment to the invoice: + +```php + $invoice = $ninja->invoices->create(['client_id'=> 'CLIENT_HASHED_ID'], ['mark_paid' => true]); +``` + +Or if you wish to apply a partial payment + +```php + $invoice = $ninja->invoices->create(['client_id'=> 'CLIENT_HASHED_ID'], ['amount_paid' => 10]); +``` + +Or you may want to automatically send and charge the invoice **note requires a payment method on file** +```php + $invoice = $ninja->invoices->create(['client_id'=> 'CLIENT_HASHED_ID'], ['auto_bill' => true, 'send_email' => true]); +``` + + +### Bulk actions + +You can perform bulk actions against one or many entities. For example if you wish to batch archive a range of invoice you would do + +```php + $bulk = $ninja->invoices->archive(["hash_1","hash_2"]); +``` + +You can access the raw bulk method using the following: + +```php +$bulk = $ninja->invoices->bulk("archive", ["hash_1","hash_2"]); +``` + +If you wanted to download a invoice PDF ```php - $pdf = $invoice->download(); -``` \ No newline at end of file + $pdf = $ninja->invoices->bulk("download", ["hash_1"]); +``` + +The following are a list of available bulk actions for invoices: + ++ mark_sent ++ download ++ restore ++ archive ++ delete ++ mark_paid ++ clone_to_quote ++ clone_to_invoice ++ cancel ++ reverse ++ email \ No newline at end of file