Skip to content
This repository was archived by the owner on Apr 23, 2021. It is now read-only.

From connect-api-specification: Fix python location example in readme #32

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 43 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ import squareconnect

### Retrieve your location IDs
```python
from __future__ import print_function
from __future__ import print_function

import squareconnect
from squareconnect.rest import ApiException
from squareconnect.apis.location_api import LocationApi
from squareconnect.apis.locations_api import LocationsApi

# setup authorization
squareconnect.configuration.access_token = 'YOUR_ACCESS_TOKEN'
# create an instance of the Location API class
api_instance = LocationApi()
api_instance = LocationsApi()

try:
# ListLocations
Expand All @@ -63,7 +63,7 @@ except ApiException as e:
```
### Charge the card nonce
```python
from __future__ import print_function
from __future__ import print_function
import uuid

import squareconnect
Expand All @@ -74,8 +74,8 @@ from squareconnect.apis.transaction_api import TransactionApi
squareconnect.configuration.access_token = 'YOUR_ACCESS_TOKEN'
# create an instance of the Transaction API class
api_instance = TransactionApi()
location_id = 'YOUR_LOCATION_ID'
nonce = 'YOUR_NONCE'
location_id = 'YOUR_LOCATION_ID'
nonce = 'YOUR_NONCE'

try:
# Charge
Expand All @@ -94,8 +94,8 @@ except ApiException as e:
All URIs are relative to [Square Connect Documentation](https://docs.connect.squareup.com/)


Class | Method | HTTP request
------------ | ------------- | -------------
Class | Method | HTTP request
------------ | ------------- | -------------
*CatalogApi* | [**batch_delete_catalog_objects**](docs/CatalogApi.md#batch_delete_catalog_objects) | **POST** /v2/catalog/batch-delete
*CatalogApi* | [**batch_retrieve_catalog_objects**](docs/CatalogApi.md#batch_retrieve_catalog_objects) | **POST** /v2/catalog/batch-retrieve
*CatalogApi* | [**batch_upsert_catalog_objects**](docs/CatalogApi.md#batch_upsert_catalog_objects) | **POST** /v2/catalog/batch-upsert
Expand Down Expand Up @@ -370,7 +370,7 @@ Class | Method | HTTP request

- **Type**: OAuth
- **Flow**: accessCode
- **Authorization URL**: `https://connect.squareup.com/oauth2/authorize?<PARAMETERS>`
- **Authorization URL**: `https://connect.squareup.com/oauth2/authorize`
- **Scopes**:
- **MERCHANT_PROFILE_READ**: GET endpoints related to a merchant's business and location entities. Almost all Connect API applications need this permission in order to obtain a merchant's location IDs
- **PAYMENTS_READ**: GET endpoints related to transactions and refunds
Expand All @@ -389,6 +389,40 @@ Class | Method | HTTP request
- **TIMECARDS_WRITE**: POST, PUT, and DELETE endpoints related to employee timecards


## Pagination of V1 Endpoints

V1 Endpoints return pagination information via HTTP headers. In order to obtain
response headers and extract the `batch_token` parameter you will need to get it
from the response object after each call as follows:

### Example

```python
from __future__ import print_function

import squareconnect
from squareconnect.rest import ApiException
from squareconnect.apis.v1_employees_api import V1EmployeesApi

# setup authorization
squareconnect.configuration.access_token = 'YOUR_ACCESS_TOKEN'
# create an instance of the V1 Employee API class
api_instance = V1EmployeesApi()
has_next_page = True
token = None

try:
while has_next_page:
# ListEmployeeRoles
api_response = api_instance.list_employee_roles(batch_token=token)
print (api_response.locations)

token = api_instance.api_client.last_response.getbatch_token()
has_next_page = token != None
except ApiException as e:
print ('Exception when calling V1EmployeesApi->list_employee_roles: %s\n' % e)
```

## Contributing

Send bug reports, feature requests, and code contributions to the [API
Expand Down
11 changes: 6 additions & 5 deletions docs/V1EmployeesApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ Assign your **Access Token** from developer portal to the authorization paramete
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

# **list_employee_roles**
> list[V1EmployeeRole] list_employee_roles(order=order, limit=limit, cursor=cursor)
> list[V1EmployeeRole] list_employee_roles(order=order, limit=limit, batch_token=batch_token)

### Description

Expand All @@ -155,7 +155,7 @@ Name | Type | Notes | Default Value
------------- | ------------- | ------------- | -------------
**order** | **str**| [optional]
**limit** | **int**| [optional]
**cursor** | **str**| [optional]
**batch_token** | **str**| [optional]

### Return type

Expand All @@ -168,7 +168,7 @@ Assign your **Access Token** from developer portal to the authorization paramete
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

# **list_employees**
> list[V1Employee] list_employees(order=order, begin_updated_at=begin_updated_at, end_updated_at=end_updated_at, begin_created_at=begin_created_at, end_created_at=end_created_at, status=status, external_id=external_id, limit=limit)
> list[V1Employee] list_employees(order=order, begin_updated_at=begin_updated_at, end_updated_at=end_updated_at, begin_created_at=begin_created_at, end_created_at=end_created_at, status=status, external_id=external_id, limit=limit, batch_token=batch_token)

### Description

Expand All @@ -186,6 +186,7 @@ Name | Type | Notes | Default Value
**status** | **str**| [optional]
**external_id** | **str**| [optional]
**limit** | **int**| [optional]
**batch_token** | **str**| [optional]

### Return type

Expand Down Expand Up @@ -221,7 +222,7 @@ Assign your **Access Token** from developer portal to the authorization paramete
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

# **list_timecards**
> list[V1Timecard] list_timecards(order=order, employee_id=employee_id, begin_clockin_time=begin_clockin_time, end_clockin_time=end_clockin_time, begin_clockout_time=begin_clockout_time, end_clockout_time=end_clockout_time, begin_updated_at=begin_updated_at, end_updated_at=end_updated_at, deleted=deleted, limit=limit, cursor=cursor)
> list[V1Timecard] list_timecards(order=order, employee_id=employee_id, begin_clockin_time=begin_clockin_time, end_clockin_time=end_clockin_time, begin_clockout_time=begin_clockout_time, end_clockout_time=end_clockout_time, begin_updated_at=begin_updated_at, end_updated_at=end_updated_at, deleted=deleted, limit=limit, batch_token=batch_token)

### Description

Expand All @@ -241,7 +242,7 @@ Name | Type | Notes | Default Value
**end_updated_at** | **str**| [optional]
**deleted** | **bool**| [optional]
**limit** | **int**| [optional]
**cursor** | **str**| [optional]
**batch_token** | **str**| [optional]

### Return type

Expand Down
6 changes: 4 additions & 2 deletions docs/V1ItemsApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ Assign your **Access Token** from developer portal to the authorization paramete
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

# **list_inventory**
> list[V1InventoryEntry] list_inventory(location_id, limit=limit)
> list[V1InventoryEntry] list_inventory(location_id, limit=limit, batch_token=batch_token)

### Description

Expand All @@ -619,6 +619,7 @@ Name | Type | Notes | Default Value
------------- | ------------- | ------------- | -------------
**location_id** | **str**|
**limit** | **int**| [optional]
**batch_token** | **str**| [optional]

### Return type

Expand All @@ -631,7 +632,7 @@ Assign your **Access Token** from developer portal to the authorization paramete
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

# **list_items**
> list[V1Item] list_items(location_id)
> list[V1Item] list_items(location_id, batch_token=batch_token)

### Description

Expand All @@ -642,6 +643,7 @@ Provides summary information for all of a location's items.
Name | Type | Notes | Default Value
------------- | ------------- | ------------- | -------------
**location_id** | **str**|
**batch_token** | **str**| [optional]

### Return type

Expand Down
12 changes: 8 additions & 4 deletions docs/V1TransactionsApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Assign your **Access Token** from developer portal to the authorization paramete
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

# **list_orders**
> list[V1Order] list_orders(location_id, order=order, limit=limit)
> list[V1Order] list_orders(location_id, order=order, limit=limit, batch_token=batch_token)

### Description

Expand All @@ -80,6 +80,7 @@ Name | Type | Notes | Default Value
**location_id** | **str**|
**order** | **str**| [optional]
**limit** | **int**| [optional]
**batch_token** | **str**| [optional]

### Return type

Expand All @@ -92,7 +93,7 @@ Assign your **Access Token** from developer portal to the authorization paramete
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

# **list_payments**
> list[V1Payment] list_payments(location_id, order=order, begin_time=begin_time, end_time=end_time, limit=limit)
> list[V1Payment] list_payments(location_id, order=order, begin_time=begin_time, end_time=end_time, limit=limit, batch_token=batch_token)

### Description

Expand All @@ -107,6 +108,7 @@ Name | Type | Notes | Default Value
**begin_time** | **str**| [optional]
**end_time** | **str**| [optional]
**limit** | **int**| [optional]
**batch_token** | **str**| [optional]

### Return type

Expand All @@ -119,7 +121,7 @@ Assign your **Access Token** from developer portal to the authorization paramete
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

# **list_refunds**
> list[V1Refund] list_refunds(location_id, order=order, begin_time=begin_time, end_time=end_time, limit=limit)
> list[V1Refund] list_refunds(location_id, order=order, begin_time=begin_time, end_time=end_time, limit=limit, batch_token=batch_token)

### Description

Expand All @@ -134,6 +136,7 @@ Name | Type | Notes | Default Value
**begin_time** | **str**| [optional]
**end_time** | **str**| [optional]
**limit** | **int**| [optional]
**batch_token** | **str**| [optional]

### Return type

Expand All @@ -146,7 +149,7 @@ Assign your **Access Token** from developer portal to the authorization paramete
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

# **list_settlements**
> list[V1Settlement] list_settlements(location_id, order=order, begin_time=begin_time, end_time=end_time, limit=limit, status=status)
> list[V1Settlement] list_settlements(location_id, order=order, begin_time=begin_time, end_time=end_time, limit=limit, status=status, batch_token=batch_token)

### Description

Expand All @@ -162,6 +165,7 @@ Name | Type | Notes | Default Value
**end_time** | **str**| [optional]
**limit** | **int**| [optional]
**status** | **str**| [optional]
**batch_token** | **str**| [optional]

### Return type

Expand Down
21 changes: 12 additions & 9 deletions squareconnect/apis/v1_employees_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,13 +462,13 @@ def list_employee_roles(self, **kwargs):
for asynchronous request. (optional)
:param str order: The order in which employees are listed in the response, based on their created_at field.Default value: ASC
:param int limit: The maximum integer number of employee entities to return in a single response. Default 100, maximum 200.
:param str cursor: A pagination cursor to retrieve the next set of results for your original query to the endpoint.
:param str batch_token: A pagination cursor to retrieve the next set of results for your original query to the endpoint.
:return: list[V1EmployeeRole]
If the method is called asynchronously,
returns the request thread.
"""

all_params = ['order', 'limit', 'cursor']
all_params = ['order', 'limit', 'batch_token']
all_params.append('callback')

params = locals()
Expand All @@ -493,8 +493,8 @@ def list_employee_roles(self, **kwargs):
query_params['order'] = params['order']
if 'limit' in params and params['limit'] is not None:
query_params['limit'] = params['limit']
if 'cursor' in params and params['cursor'] is not None:
query_params['cursor'] = params['cursor']
if 'batch_token' in params and params['batch_token'] is not None:
query_params['batch_token'] = params['batch_token']

header_params = {}

Expand Down Expand Up @@ -551,12 +551,13 @@ def list_employees(self, **kwargs):
:param str status: If provided, the endpoint returns only employee entities with the specified status (ACTIVE or INACTIVE).
:param str external_id: If provided, the endpoint returns only employee entities with the specified external_id.
:param int limit: The maximum integer number of employee entities to return in a single response. Default 100, maximum 200.
:param str batch_token: A pagination cursor to retrieve the next set of results for your original query to the endpoint.
:return: list[V1Employee]
If the method is called asynchronously,
returns the request thread.
"""

all_params = ['order', 'begin_updated_at', 'end_updated_at', 'begin_created_at', 'end_created_at', 'status', 'external_id', 'limit']
all_params = ['order', 'begin_updated_at', 'end_updated_at', 'begin_created_at', 'end_created_at', 'status', 'external_id', 'limit', 'batch_token']
all_params.append('callback')

params = locals()
Expand Down Expand Up @@ -593,6 +594,8 @@ def list_employees(self, **kwargs):
query_params['external_id'] = params['external_id']
if 'limit' in params and params['limit'] is not None:
query_params['limit'] = params['limit']
if 'batch_token' in params and params['batch_token'] is not None:
query_params['batch_token'] = params['batch_token']

header_params = {}

Expand Down Expand Up @@ -729,13 +732,13 @@ def list_timecards(self, **kwargs):
:param str end_updated_at: If filtering results by their updated_at field, the end of the requested reporting period, in ISO 8601 format.
:param bool deleted: If true, only deleted timecards are returned. If false, only valid timecards are returned.If you don't provide this parameter, both valid and deleted timecards are returned.
:param int limit: The maximum integer number of employee entities to return in a single response. Default 100, maximum 200.
:param str cursor: A pagination cursor to retrieve the next set of results for your original query to the endpoint.
:param str batch_token: A pagination cursor to retrieve the next set of results for your original query to the endpoint.
:return: list[V1Timecard]
If the method is called asynchronously,
returns the request thread.
"""

all_params = ['order', 'employee_id', 'begin_clockin_time', 'end_clockin_time', 'begin_clockout_time', 'end_clockout_time', 'begin_updated_at', 'end_updated_at', 'deleted', 'limit', 'cursor']
all_params = ['order', 'employee_id', 'begin_clockin_time', 'end_clockin_time', 'begin_clockout_time', 'end_clockout_time', 'begin_updated_at', 'end_updated_at', 'deleted', 'limit', 'batch_token']
all_params.append('callback')

params = locals()
Expand Down Expand Up @@ -776,8 +779,8 @@ def list_timecards(self, **kwargs):
query_params['deleted'] = params['deleted']
if 'limit' in params and params['limit'] is not None:
query_params['limit'] = params['limit']
if 'cursor' in params and params['cursor'] is not None:
query_params['cursor'] = params['cursor']
if 'batch_token' in params and params['batch_token'] is not None:
query_params['batch_token'] = params['batch_token']

header_params = {}

Expand Down
10 changes: 8 additions & 2 deletions squareconnect/apis/v1_items_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2025,12 +2025,13 @@ def list_inventory(self, location_id, **kwargs):
for asynchronous request. (optional)
:param str location_id: The ID of the item's associated location. (required)
:param int limit: The maximum number of inventory entries to return in a single response. This value cannot exceed 1000.
:param str batch_token: A pagination cursor to retrieve the next set of results for your original query to the endpoint.
:return: list[V1InventoryEntry]
If the method is called asynchronously,
returns the request thread.
"""

all_params = ['location_id', 'limit']
all_params = ['location_id', 'limit', 'batch_token']
all_params.append('callback')

params = locals()
Expand Down Expand Up @@ -2058,6 +2059,8 @@ def list_inventory(self, location_id, **kwargs):
query_params = {}
if 'limit' in params and params['limit'] is not None:
query_params['limit'] = params['limit']
if 'batch_token' in params and params['batch_token'] is not None:
query_params['batch_token'] = params['batch_token']

header_params = {}

Expand Down Expand Up @@ -2107,12 +2110,13 @@ def list_items(self, location_id, **kwargs):
:param callback function: The callback function
for asynchronous request. (optional)
:param str location_id: The ID of the location to list items for. (required)
:param str batch_token: A pagination cursor to retrieve the next set of results for your original query to the endpoint.
:return: list[V1Item]
If the method is called asynchronously,
returns the request thread.
"""

all_params = ['location_id']
all_params = ['location_id', 'batch_token']
all_params.append('callback')

params = locals()
Expand All @@ -2136,6 +2140,8 @@ def list_items(self, location_id, **kwargs):
path_params['location_id'] = params['location_id']

query_params = {}
if 'batch_token' in params and params['batch_token'] is not None:
query_params['batch_token'] = params['batch_token']

header_params = {}

Expand Down
Loading