Skip to content

Commit 6763344

Browse files
authored
Merge pull request ej2#89 from sidecars/grantmcconnaughey-patch-1
Add syntax highlighting to README
2 parents c673a5c + 4caead8 commit 6763344

File tree

1 file changed

+96
-100
lines changed

1 file changed

+96
-100
lines changed

README.rst

Lines changed: 96 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -20,53 +20,54 @@ With quickbooks-cli
2020
-------------------
2121

2222
::
23+
2324
quickbooks-cli [-h] [-s] [-p PORT] consumer_key consumer_secret
2425

2526
Manually
2627
--------
2728

2829
1. Create the Authorization URL for your application:
2930

30-
::
31+
.. code-block:: python
3132
32-
from quickbooks import QuickBooks
33+
from quickbooks import QuickBooks
3334
34-
client = QuickBooks(
35-
sandbox=True,
36-
consumer_key=QUICKBOOKS_CLIENT_KEY,
37-
consumer_secret=QUICKBOOKS_CLIENT_SECRET,
38-
callback_url=CALLBACK_URL
39-
)
35+
client = QuickBooks(
36+
sandbox=True,
37+
consumer_key=QUICKBOOKS_CLIENT_KEY,
38+
consumer_secret=QUICKBOOKS_CLIENT_SECRET,
39+
callback_url=CALLBACK_URL
40+
)
4041
41-
authorize_url = client.get_authorize_url()
42-
request_token = client.request_token
43-
request_token_secret = client.request_token_secret
42+
authorize_url = client.get_authorize_url()
43+
request_token = client.request_token
44+
request_token_secret = client.request_token_secret
4445
45-
Store the ``authorize_url``, ``request_token``, and ``request_token_secret``
46-
for use in the Callback method.
46+
Store the ``authorize_url``, ``request_token``, and ``request_token_secret``
47+
for use in the Callback method.
4748

4849
2. Handle the callback:
4950

50-
::
51+
.. code-block:: python
5152
52-
client = QuickBooks(
53-
sandbox=True,
54-
consumer_key=QUICKBOOKS_CLIENT_KEY,
55-
consumer_secret=QUICKBOOKS_CLIENT_SECRET
56-
)
53+
client = QuickBooks(
54+
sandbox=True,
55+
consumer_key=QUICKBOOKS_CLIENT_KEY,
56+
consumer_secret=QUICKBOOKS_CLIENT_SECRET
57+
)
5758
58-
client.authorize_url = authorize_url
59-
client.request_token = request_token
60-
client.request_token_secret = request_token_secret
61-
client.set_up_service()
59+
client.authorize_url = authorize_url
60+
client.request_token = request_token
61+
client.request_token_secret = request_token_secret
62+
client.set_up_service()
6263
63-
client.get_access_tokens(request.GET['oauth_verifier'])
64+
client.get_access_tokens(request.GET['oauth_verifier'])
6465
65-
realm_id = request.GET['realmId']
66-
access_token = client.access_token
67-
access_token_secret = client.access_token_secret
66+
realm_id = request.GET['realmId']
67+
access_token = client.access_token
68+
access_token_secret = client.access_token_secret
6869
69-
Store ``realm_id``, ``access_token``, and ``access_token_secret`` for later use.
70+
Store ``realm_id``, ``access_token``, and ``access_token_secret`` for later use.
7071

7172
Accessing the API
7273
-----------------
@@ -75,9 +76,9 @@ Create the QuickBooks client object before you make any calls to QBO. Setup the
7576
connection using the stored ``access_token`` and the
7677
``access_token_secret`` and ``realm_id``:
7778

78-
::
79+
.. code-block:: python
7980
80-
from quickbooks import QuickBooks
81+
from quickbooks import QuickBooks
8182
8283
client = QuickBooks(
8384
sandbox=True,
@@ -91,7 +92,7 @@ connection using the stored ``access_token`` and the
9192
If you need to access a minor version (See `Minor versions`_ for
9293
details) pass in minorversion when setting up the client:
9394

94-
::
95+
.. code-block:: python
9596
9697
client = QuickBooks(
9798
sandbox=True,
@@ -105,90 +106,89 @@ details) pass in minorversion when setting up the client:
105106
106107
You can disconnect the current Quickbooks Account like so (See `Disconnect documentation`_ for full details):
107108

108-
::
109+
.. code-block:: python
109110
110-
client.disconnect_account()
111+
client.disconnect_account()
111112
112113
If your consumer_key never changes you can enable the client to stay running:
113114

114-
::
115+
.. code-block:: python
115116
116-
QuickBooks.enable_global()
117+
QuickBooks.enable_global()
117118
118119
You can disable the global client like so:
119120

120-
::
121+
.. code-block:: python
121122
122-
QuickBooks.disable_global()
123+
QuickBooks.disable_global()
123124
124125
125126
List of objects:
126127

127-
::
128-
128+
.. code-block:: python
129129
130-
from quickbooks.objects.customer
131-
import Customer customers = Customer.all(qb=client)
130+
from quickbooks.objects.customer import Customer
131+
customers = Customer.all(qb=client)
132132
133133
**Note:** The maximum number of entities that can be returned in a
134134
response is 1000. If the result size is not specified, the default
135135
number is 100. (See `Intuit developer guide`_ for details)
136136

137137
Filtered list of objects:
138138

139-
::
139+
.. code-block:: python
140140
141141
customers = Customer.filter(Active=True, FamilyName="Smith", qb=client)
142142
143143
Filtered list of objects with paging:
144144

145-
::
145+
.. code-block:: python
146146
147147
customers = Customer.filter(start_position=1, max_results=25, Active=True, FamilyName="Smith", qb=client)
148148
149149
List Filtered by values in list:
150150

151-
::
151+
.. code-block:: python
152152
153153
customer_names = ['Customer1', 'Customer2', 'Customer3']
154154
customers = Customer.choose(customer_names, field="DisplayName", qb=client)
155155
156-
List with custom Where Clause (do not include the WHERE):
156+
List with custom Where Clause (do not include the ``"WHERE"``):
157157

158-
::
158+
.. code-block:: python
159159
160160
customers = Customer.where("Active = True AND CompanyName LIKE 'S%'", qb=client)
161161
162162
List with custom Where Clause and paging:
163163

164-
::
164+
.. code-block:: python
165165
166166
customers = Customer.where("CompanyName LIKE 'S%'", start_position=1, max_results=25, qb=client)
167167
168168
Filtering a list with a custom query (See `Intuit developer guide`_ for
169169
supported SQL statements):
170170

171-
::
171+
.. code-block:: python
172172
173-
customer = Customer.query("SELECT * FROM Customer WHERE Active = True", qb=client)
173+
customers = Customer.query("SELECT * FROM Customer WHERE Active = True", qb=client)
174174
175175
Filtering a list with a custom query with paging:
176176

177-
::
177+
.. code-block:: python
178178
179-
customer = Customer.query("SELECT * FROM Customer WHERE Active = True STARTPOSITION 1 MAXRESULTS 25", qb=client)
179+
customers = Customer.query("SELECT * FROM Customer WHERE Active = True STARTPOSITION 1 MAXRESULTS 25", qb=client)
180180
181181
Get single object by Id and update:
182182

183-
::
183+
.. code-block:: python
184184
185185
customer = Customer.get(1, qb=client)
186186
customer.CompanyName = "New Test Company Name"
187187
customer.save(qb=client)
188188
189189
Create new object:
190190

191-
::
191+
.. code-block:: python
192192
193193
customer = Customer()
194194
customer.CompanyName = "Test Company"
@@ -203,7 +203,7 @@ full details).
203203

204204
Batch create a list of objects:
205205

206-
::
206+
.. code-block:: python
207207
208208
from quickbooks.batch import batch_create
209209
@@ -221,58 +221,57 @@ Batch create a list of objects:
221221
222222
Batch update a list of objects:
223223

224-
::
224+
.. code-block:: python
225225
226-
from quickbooks.batch import batch_update
226+
from quickbooks.batch import batch_update
227227
228-
customers = Customer.filter(Active=True)
228+
customers = Customer.filter(Active=True)
229229
230-
# Update customer records
230+
# Update customer records
231231
232-
results = batch_update(customers, qb=client)
232+
results = batch_update(customers, qb=client)
233233
234234
Batch delete a list of objects:
235235

236-
::
237-
238-
from quickbooks.batch import batch_delete
236+
.. code-block:: python
239237
240-
customers = Customer.filter(Active=False)
241-
results = batch_delete(customers, qb=client)
238+
from quickbooks.batch import batch_delete
242239
240+
customers = Customer.filter(Active=False)
241+
results = batch_delete(customers, qb=client)
243242
244243
Review results for batch operation:
245244

246-
::
245+
.. code-block:: python
247246
248-
# successes is a list of objects that were successfully updated
249-
for obj in results.successes:
250-
print "Updated " + obj.DisplayName
247+
# successes is a list of objects that were successfully updated
248+
for obj in results.successes:
249+
print "Updated " + obj.DisplayName
251250
252-
# faults contains list of failed operations and associated errors
253-
for fault in results.faults:
254-
print "Operation failed on " + fault.original_object.DisplayName
255-
256-
for error in fault.Error:
257-
print "Error " + error.Message
251+
# faults contains list of failed operations and associated errors
252+
for fault in results.faults:
253+
print "Operation failed on " + fault.original_object.DisplayName
254+
255+
for error in fault.Error:
256+
print "Error " + error.Message
258257
259258
Change Data Capture
260259
-----------------------
261260
Change Data Capture returns a list of objects that have changed since a given time (see `Change data capture`_ for more
262261
details):
263262

264-
::
263+
.. code-block:: python
265264
266265
from quickbooks.cdc import change_data_capture
267266
from quickbooks.objects import Invoice
268267
269268
cdc_response = change_data_capture([Invoice], "2017-01-01T00:00:00", qb=client)
270269
for invoice in cdc_response.Invoice:
271-
# Do something with the invoice
270+
# Do something with the invoice
272271
273272
Querying muliple entity types at the same time:
274273

275-
::
274+
.. code-block:: python
276275
277276
from quickbooks.objects import Invoice, Customer
278277
@@ -281,63 +280,60 @@ Querying muliple entity types at the same time:
281280
282281
If you use a ``datetime`` object for the timestamp, it is automatically converted to a string:
283282

284-
::
283+
.. code-block:: python
285284
286285
from datetime import datetime
287286
288287
cdc_response = change_data_capture([Invoice, Customer], datetime(2017, 1, 1, 0, 0, 0), qb=client)
289288
290-
291289
Attachments
292290
----------------
293291
See `Attachable documentation`_ for list of valid file types, file size limits and other restrictions.
294292

295293
Attaching a note to a customer:
296294

297-
::
295+
.. code-block:: python
298296
299-
attachment = Attachable()
297+
attachment = Attachable()
300298
301-
attachable_ref = AttachableRef()
302-
attachable_ref.EntityRef = customer.to_ref()
299+
attachable_ref = AttachableRef()
300+
attachable_ref.EntityRef = customer.to_ref()
303301
304-
attachment.AttachableRef.append(attachable_ref)
302+
attachment.AttachableRef.append(attachable_ref)
305303
306-
attachment.Note = 'This is a note'
307-
attachment.save(qb=client)
304+
attachment.Note = 'This is a note'
305+
attachment.save(qb=client)
308306
309307
Attaching a file to customer:
310308

311-
::
312-
313-
attachment = Attachable()
314-
315-
attachable_ref = AttachableRef()
316-
attachable_ref.EntityRef = customer.to_ref()
309+
.. code-block:: python
317310
318-
attachment.AttachableRef.append(attachable_ref)
311+
attachment = Attachable()
319312
320-
attachment.FileName = 'Filename'
321-
attachment._FilePath = '/folder/filename' # full path to file
322-
attachment.ContentType = 'application/pdf'
323-
attachment.save(qb=client)
313+
attachable_ref = AttachableRef()
314+
attachable_ref.EntityRef = customer.to_ref()
324315
316+
attachment.AttachableRef.append(attachable_ref)
325317
318+
attachment.FileName = 'Filename'
319+
attachment._FilePath = '/folder/filename' # full path to file
320+
attachment.ContentType = 'application/pdf'
321+
attachment.save(qb=client)
326322
327323
Working with JSON data
328324
----------------
329325
All objects include ``to_json`` and ``from_json`` methods.
330326

331327
Converting an object to JSON data:
332328

333-
::
329+
.. code-block:: python
334330
335331
account = Account.get(1, qb=client)
336332
json_data = account.to_json()
337333
338334
Loading JSON data into a quickbooks object:
339335

340-
::
336+
.. code-block:: python
341337
342338
account = Account()
343339
account.from_json(
@@ -353,7 +349,7 @@ Date formatting
353349
When setting date or datetime fields, Quickbooks requires a specific format.
354350
Formating helpers are available in helpers.py. Example usage:
355351

356-
::
352+
.. code-block:: python
357353
358354
date_string = qb_date_format(date(2016, 7, 22))
359355
date_time_string = qb_datetime_format(datetime(2016, 7, 22, 10, 35, 00))

0 commit comments

Comments
 (0)