@@ -32,6 +32,37 @@ Retrieve all clients
3232 $clients = $ninja->clients->all();
3333```
3434
35+ You can perform complex filtering on the ->all() method.
36+
37+ Query parameters can be chained together to form complex queries. The current supported values are:
38+
39+ ** per_page** : The number of clients per page you want returned
40+ ** page** : The page number
41+ ** include** : A comma separated list of relations to include ie. contacts,documents,gateway_tokens
42+ ** balance** : A query to return clients with a balance using an operator and value
43+ - ie ?balance=lt:10 Returns clients with a balance less than 10
44+ - available operators lt, lte, gt, gte, eq
45+ ** between_balance** : Returns clients with a balance between two values
46+ - ie ?between_balance=10:20 - Returns clients with a balance between 10 and 20
47+ ** email** : Returns clients with a contacts.email field equal to an email
48+ ** id_number** : Search by id_number
49+ ** number** : Search by number
50+ ** filter** : Search across multiple columns (name, id_number, first_name, last_name, email, custom_value1, custom_value2, custom_value3, custom_value4)
51+ ** created_at** : Search by created at (Unix timestamp)
52+ ** is_deleted** : Search using is_deleted boolean flag
53+
54+ For example,
55+
56+ ``` php
57+ $clients = $ninja->clients->all([
58+ 'balance' => 'lt:10', // get all clients with a balance less than 10
59+ 'per_page' => 10, // return 10 results per page
60+ 'page' => 2, // paginate to page 2
61+ 'include' => 'documents', // include the documents relationship
62+ ]);
63+
64+ ```
65+
3566Retrieve a client by its primary key.
3667``` php
3768 $client = $ninja->clients->get("CLIENT_HASHED_ID");
@@ -59,7 +90,54 @@ Create an invoice
5990 $client = $ninja->invoices->create(['client_id' => CLIENT_HASHED_ID]);
6091
6192```
62- Download an invoice PDF
93+
94+ 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:
95+
96+ ``` php
97+ $invoice = $ninja->invoices->create(['client_id'=> 'CLIENT_HASHED_ID'], ['mark_paid' => true]);
98+ ```
99+
100+ Or if you wish to apply a partial payment
101+
102+ ``` php
103+ $invoice = $ninja->invoices->create(['client_id'=> 'CLIENT_HASHED_ID'], ['amount_paid' => 10]);
104+ ```
105+
106+ Or you may want to automatically send and charge the invoice ** note requires a payment method on file**
107+ ``` php
108+ $invoice = $ninja->invoices->create(['client_id'=> 'CLIENT_HASHED_ID'], ['auto_bill' => true, 'send_email' => true]);
109+ ```
110+
111+
112+ ### Bulk actions
113+
114+ 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
115+
116+ ``` php
117+ $bulk = $ninja->invoices->archive(["hash_1","hash_2"]);
118+ ```
119+
120+ You can access the raw bulk method using the following:
121+
122+ ``` php
123+ $bulk = $ninja->invoices->bulk("archive", ["hash_1","hash_2"]);
124+ ```
125+
126+ If you wanted to download a invoice PDF
63127``` php
64- $pdf = $invoice->download();
65- ```
128+ $pdf = $ninja->invoices->bulk("download", ["hash_1"]);
129+ ```
130+
131+ The following are a list of available bulk actions for invoices:
132+
133+ + mark_sent
134+ + download
135+ + restore
136+ + archive
137+ + delete
138+ + mark_paid
139+ + clone_to_quote
140+ + clone_to_invoice
141+ + cancel
142+ + reverse
143+ + email
0 commit comments