Skip to content

Commit 00364ed

Browse files
committed
update documentation
1 parent 1403f19 commit 00364ed

File tree

4 files changed

+67
-9
lines changed

4 files changed

+67
-9
lines changed

Diff for: README.md

+53-8
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ To install, run `pip install quickbase-json-api-client`
1515

1616
## Initialize Client
1717
Use the following code to create and initialize a client object.
18-
```
19-
from quickbase_json.client import QuickbaseJSONClient # import client
18+
```python
19+
from quickbase_json import QBClient
2020

21-
client = QuickbaseJSONClient(realm="yourRealm", auth="userToken")
21+
client = QBClient(realm="yourRealm", auth="userToken")
2222
```
2323

2424
Where `yourRealm` is the name (subdomain) of your Quickbase Realm and `userToken` is the user token used to authenticate
@@ -28,37 +28,82 @@ with the realm.
2828
Querying for records is one of the most useful features of the Quickbase JSON API. Querying records with QJAC can be done
2929
using the following code
3030

31-
`response = client.query_records('tableId', fids, 'queryString')`
31+
#### Basic Example
32+
33+
```python
34+
response = client.query_records(table='tableId', select=[3, 6, 12], query='queryString')
35+
```
3236

3337
Where `tableId` is the ID of the table you wish to query from, `fids` is a list of field IDs you wish to receive and `queryString`
3438
is a quickbase [query string](https://help.quickbase.com/api-guide/componentsquery.html).
3539

40+
41+
#### Adv. Example
42+
43+
```python
44+
from quickbase_json.helpers import Where
45+
# have static fids for table/records
46+
NEEDED_FIDS = [3, 6, 12]
47+
# build query str where 3 is either 130, 131 or 132
48+
# https://help.quickbase.com/api-guide/componentsquery.html
49+
q_str = Where(3, 'EX', [130, 131, 132]).build(join='OR')
50+
response = client.query_records(table='tableId', select=NEEDED_FIDS, query=q_str)
51+
```
52+
53+
In this example, we use the `Where()` helper. This can make building complex [QuickBase queries](https://help.quickbase.com/api-guide/componentsquery.html) easier.
54+
55+
The `Where()` helper documentation can be found [here](!https://github.com/robswc/quickbase-json-api-client/wiki/Helper:-Where).
56+
57+
3658
## Response Objects
3759

3860
A `QBResponse` object is returned when querying records with QJAC. A `QBResponse` has several methods that make
3961
handling returned data easier. Here are a few of the most useful ones.
4062

4163
### Response Methods
4264

43-
- **data()**
65+
- **.data()**
66+
67+
```python
68+
r = qbc.query_records(...).data()
69+
```
4470

45-
Returns the actual data. Equivalent to calling `.get('data')`
71+
Returns the data from QuickBase. Equivalent to calling `.get('data')`
4672

47-
- **denest()**
73+
- **.denest()**
74+
75+
```python
76+
r = qbc.query_records(...).denest()
77+
```
4878

4979
Denests the data. I.e. changes `{'fid': {'value': 'actualValue'}}` to `{'fid': 'actualValue'}`
5080

51-
- **orient(orient='records', key='3')**
81+
- **orient(orient: str, key: int)**
82+
83+
```python
84+
r = qbc.query_records(...).orient('records', key=3)
85+
```
5286

5387
Orients the data. Currently, the only option is 'records'. This will orient the returned data into a "record like structure", i.e. changes
5488
`{'fid': 'actualValue', 'fid': 'actualValue'}` to `{'key': {etc: etc}}`
5589

5690
- **convert()**
5791

92+
93+
```python
94+
r = qbc.query_records(...).convert('datetime')
95+
```
96+
5897
Converts the data, based on fields and provided arguments. For example, calling `convert('datetime')` will convert all data with fields
5998
of the 'date time' type to python datetime objects. Other conversions are 'currency' and 'int'.
6099

61100
- **round_ints()**
62101

102+
103+
```python
104+
r = qbc.query_records(...).round_ints()
105+
```
106+
107+
63108
Rounds all float integers into whole number ints. i.e. converts `55.0` to `55`.
64109

Diff for: setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = quickbase-json-api-client
3-
version = 0.1.0
3+
version = 0.1.1
44
author = Robert Carroll
55
author_email = [email protected]
66
description = Python wrapper for quickbase JSON API.

Diff for: src/quickbase_json/helpers.py

+6
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,15 @@ class QuickbaseParameter:
1717
def build(self):
1818
return 'Default String'
1919

20+
def to_json(self):
21+
return self.build()
22+
2023
def __str__(self):
2124
return self.build()
2225

26+
def __repr__(self):
27+
return self.build()
28+
2329

2430
class Where(QuickbaseParameter):
2531
def __init__(self, fid: any, operator: str, value: any, **kwargs):

Diff for: src/quickbase_json/qb_response.py

+7
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ def __init__(self, res=None, **kwargs):
4242
self.update(kwargs.get('sample_data'))
4343
super().__init__(requests_response=res)
4444

45+
def is_empty(self):
46+
"""
47+
Tests if data is empty, return True if so.
48+
:return: boolean
49+
"""
50+
return self.get('data', False)
51+
4552
def info(self, prt=True):
4653
"""
4754
Prints information about the response.

0 commit comments

Comments
 (0)