From e48ee0a4475099dd2035965070f9b0827909df1b Mon Sep 17 00:00:00 2001 From: Travis CI Date: Fri, 11 Aug 2017 17:22:54 +0000 Subject: [PATCH 1/3] From connect-api-specification: Merge pull request #57 from square/tristans/update-csharp-readme fix locations/transactions example in readme --- README.md | 52 +++++-- docs/V1EmployeesApi.md | 11 +- docs/V1ItemsApi.md | 6 +- docs/V1Refund.md | 5 + docs/V1TransactionsApi.md | 12 +- docs/V1Variation.md | 1 + setup.py | 2 +- squareconnect/api_client.py | 2 +- squareconnect/apis/v1_employees_api.py | 21 +-- squareconnect/apis/v1_items_api.py | 10 +- squareconnect/apis/v1_transactions_api.py | 20 ++- squareconnect/configuration.py | 2 +- .../models/search_catalog_objects_request.py | 4 +- squareconnect/models/v1_refund.py | 132 +++++++++++++++++- squareconnect/models/v1_variation.py | 28 +++- squareconnect/rest.py | 22 ++- tox.ini | 2 +- 17 files changed, 285 insertions(+), 47 deletions(-) diff --git a/README.md b/README.md index e7290ef..01b8efe 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 @@ -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 @@ -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 @@ -370,7 +370,7 @@ Class | Method | HTTP request - **Type**: OAuth - **Flow**: accessCode -- **Authorization URL**: `https://connect.squareup.com/oauth2/authorize?` +- **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 @@ -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 diff --git a/docs/V1EmployeesApi.md b/docs/V1EmployeesApi.md index 87f6b7f..45459af 100644 --- a/docs/V1EmployeesApi.md +++ b/docs/V1EmployeesApi.md @@ -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 @@ -155,7 +155,7 @@ Name | Type | Notes | Default Value ------------- | ------------- | ------------- | ------------- **order** | **str**| [optional] **limit** | **int**| [optional] - **cursor** | **str**| [optional] + **batch_token** | **str**| [optional] ### Return type @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/docs/V1ItemsApi.md b/docs/V1ItemsApi.md index 19597be..52556b5 100644 --- a/docs/V1ItemsApi.md +++ b/docs/V1ItemsApi.md @@ -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 @@ -619,6 +619,7 @@ Name | Type | Notes | Default Value ------------- | ------------- | ------------- | ------------- **location_id** | **str**| **limit** | **int**| [optional] + **batch_token** | **str**| [optional] ### Return type @@ -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 @@ -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 diff --git a/docs/V1Refund.md b/docs/V1Refund.md index 9732241..e94de80 100644 --- a/docs/V1Refund.md +++ b/docs/V1Refund.md @@ -9,6 +9,11 @@ Name | Type | Notes **type** | **str** | [optional] **reason** | **str** | [optional] **refunded_money** | [**V1Money**](V1Money.md) | [optional] +**refunded_processing_fee_money** | [**V1Money**](V1Money.md) | [optional] +**refunded_additive_tax_money** | [**V1Money**](V1Money.md) | [optional] +**refunded_inclusive_tax_money** | [**V1Money**](V1Money.md) | [optional] +**refunded_tip_money** | [**V1Money**](V1Money.md) | [optional] +**refunded_discount_money** | [**V1Money**](V1Money.md) | [optional] **created_at** | **str** | [optional] **processed_at** | **str** | [optional] **payment_id** | **str** | [optional] diff --git a/docs/V1TransactionsApi.md b/docs/V1TransactionsApi.md index 64b3bee..a56901f 100644 --- a/docs/V1TransactionsApi.md +++ b/docs/V1TransactionsApi.md @@ -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 @@ -80,6 +80,7 @@ Name | Type | Notes | Default Value **location_id** | **str**| **order** | **str**| [optional] **limit** | **int**| [optional] + **batch_token** | **str**| [optional] ### Return type @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/docs/V1Variation.md b/docs/V1Variation.md index 44e0a16..3b663b4 100644 --- a/docs/V1Variation.md +++ b/docs/V1Variation.md @@ -9,6 +9,7 @@ Name | Type | Notes **id** | **str** | [optional] **name** | **str** | [optional] **item_id** | **str** | [optional] +**ordinal** | **int** | [optional] **pricing_type** | **str** | [optional] **price_money** | [**V1Money**](V1Money.md) | [optional] **sku** | **str** | [optional] diff --git a/setup.py b/setup.py index ec28a3d..0fa7868 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ from setuptools import setup, find_packages NAME = "squareconnect" -VERSION = "2.2.0" +VERSION = "2.2.1" diff --git a/squareconnect/api_client.py b/squareconnect/api_client.py index 57f001e..a349a69 100644 --- a/squareconnect/api_client.py +++ b/squareconnect/api_client.py @@ -80,7 +80,7 @@ def __init__(self, host=None, header_name=None, header_value=None, cookie=None): self.host = host self.cookie = cookie # Set default User-Agent. - self.user_agent = 'Square-Connect-Python/2.2.0' + self.user_agent = 'Square-Connect-Python/2.2.1' @property def user_agent(self): diff --git a/squareconnect/apis/v1_employees_api.py b/squareconnect/apis/v1_employees_api.py index 3fb15aa..adb4710 100644 --- a/squareconnect/apis/v1_employees_api.py +++ b/squareconnect/apis/v1_employees_api.py @@ -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() @@ -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 = {} @@ -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() @@ -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 = {} @@ -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() @@ -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 = {} diff --git a/squareconnect/apis/v1_items_api.py b/squareconnect/apis/v1_items_api.py index e3222d1..a8c5b6d 100644 --- a/squareconnect/apis/v1_items_api.py +++ b/squareconnect/apis/v1_items_api.py @@ -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() @@ -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 = {} @@ -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() @@ -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 = {} diff --git a/squareconnect/apis/v1_transactions_api.py b/squareconnect/apis/v1_transactions_api.py index 95abbf2..84488e1 100644 --- a/squareconnect/apis/v1_transactions_api.py +++ b/squareconnect/apis/v1_transactions_api.py @@ -226,12 +226,13 @@ def list_orders(self, location_id, **kwargs): :param str location_id: The ID of the location to list online store orders for. (required) :param str order: TThe order in which payments are listed in the response. :param int limit: The maximum number of payments to return in a single response. This value cannot exceed 200. + :param str batch_token: A pagination cursor to retrieve the next set of results for your original query to the endpoint. :return: list[V1Order] If the method is called asynchronously, returns the request thread. """ - all_params = ['location_id', 'order', 'limit'] + all_params = ['location_id', 'order', 'limit', 'batch_token'] all_params.append('callback') params = locals() @@ -261,6 +262,8 @@ def list_orders(self, location_id, **kwargs): query_params['order'] = params['order'] 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 = {} @@ -314,12 +317,13 @@ def list_payments(self, location_id, **kwargs): :param str begin_time: The beginning of the requested reporting period, in ISO 8601 format. If this value is before January 1, 2013 (2013-01-01T00:00:00Z), this endpoint returns an error. Default value: The current time minus one year. :param str end_time: The end of the requested reporting period, in ISO 8601 format. If this value is more than one year greater than begin_time, this endpoint returns an error. Default value: The current time. :param int limit: The maximum number of payments to return in a single response. This value cannot exceed 200. + :param str batch_token: A pagination cursor to retrieve the next set of results for your original query to the endpoint. :return: list[V1Payment] If the method is called asynchronously, returns the request thread. """ - all_params = ['location_id', 'order', 'begin_time', 'end_time', 'limit'] + all_params = ['location_id', 'order', 'begin_time', 'end_time', 'limit', 'batch_token'] all_params.append('callback') params = locals() @@ -353,6 +357,8 @@ def list_payments(self, location_id, **kwargs): query_params['end_time'] = params['end_time'] 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 = {} @@ -406,12 +412,13 @@ def list_refunds(self, location_id, **kwargs): :param str begin_time: The beginning of the requested reporting period, in ISO 8601 format. If this value is before January 1, 2013 (2013-01-01T00:00:00Z), this endpoint returns an error. Default value: The current time minus one year. :param str end_time: The end of the requested reporting period, in ISO 8601 format. If this value is more than one year greater than begin_time, this endpoint returns an error. Default value: The current time. :param int limit: The maximum number of payments to return in a single response. This value cannot exceed 200. + :param str batch_token: A pagination cursor to retrieve the next set of results for your original query to the endpoint. :return: list[V1Refund] If the method is called asynchronously, returns the request thread. """ - all_params = ['location_id', 'order', 'begin_time', 'end_time', 'limit'] + all_params = ['location_id', 'order', 'begin_time', 'end_time', 'limit', 'batch_token'] all_params.append('callback') params = locals() @@ -445,6 +452,8 @@ def list_refunds(self, location_id, **kwargs): query_params['end_time'] = params['end_time'] 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 = {} @@ -499,12 +508,13 @@ def list_settlements(self, location_id, **kwargs): :param str end_time: The end of the requested reporting period, in ISO 8601 format. If this value is more than one year greater than begin_time, this endpoint returns an error. Default value: The current time. :param int limit: The maximum number of payments to return in a single response. This value cannot exceed 200. :param str status: Provide this parameter to retrieve only settlements with a particular status (SENT or FAILED). + :param str batch_token: A pagination cursor to retrieve the next set of results for your original query to the endpoint. :return: list[V1Settlement] If the method is called asynchronously, returns the request thread. """ - all_params = ['location_id', 'order', 'begin_time', 'end_time', 'limit', 'status'] + all_params = ['location_id', 'order', 'begin_time', 'end_time', 'limit', 'status', 'batch_token'] all_params.append('callback') params = locals() @@ -540,6 +550,8 @@ def list_settlements(self, location_id, **kwargs): query_params['limit'] = params['limit'] if 'status' in params and params['status'] is not None: query_params['status'] = params['status'] + if 'batch_token' in params and params['batch_token'] is not None: + query_params['batch_token'] = params['batch_token'] header_params = {} diff --git a/squareconnect/configuration.py b/squareconnect/configuration.py index 657b261..c748760 100644 --- a/squareconnect/configuration.py +++ b/squareconnect/configuration.py @@ -235,5 +235,5 @@ def to_debug_report(self): "OS: {env}\n"\ "Python Version: {pyversion}\n"\ "Version of the API: 2.0\n"\ - "SDK Package Version: 2.2.0".\ + "SDK Package Version: 2.2.1".\ format(env=sys.platform, pyversion=sys.version) diff --git a/squareconnect/models/search_catalog_objects_request.py b/squareconnect/models/search_catalog_objects_request.py index 46fb77c..79a6c19 100644 --- a/squareconnect/models/search_catalog_objects_request.py +++ b/squareconnect/models/search_catalog_objects_request.py @@ -91,7 +91,7 @@ def cursor(self, cursor): def object_types(self): """ Gets the object_types of this SearchCatalogObjectsRequest. - The desired set of object types to apper in the search results. The legal values are taken from the [CatalogObjectType](#type-catalogobjecttype) enumeration, namely `\"ITEM\"`, `\"ITEM_VARIATION\"`, `\"CATEGORY\"`, `\"DISCOUNT\"`, `\"TAX\"`, `\"MODIFIER\"`, or `\"MODIFIER_LIST\"`. + The desired set of object types to appear in the search results. The legal values are taken from the [CatalogObjectType](#type-catalogobjecttype) enumeration, namely `\"ITEM\"`, `\"ITEM_VARIATION\"`, `\"CATEGORY\"`, `\"DISCOUNT\"`, `\"TAX\"`, `\"MODIFIER\"`, or `\"MODIFIER_LIST\"`. :return: The object_types of this SearchCatalogObjectsRequest. :rtype: list[str] @@ -102,7 +102,7 @@ def object_types(self): def object_types(self, object_types): """ Sets the object_types of this SearchCatalogObjectsRequest. - The desired set of object types to apper in the search results. The legal values are taken from the [CatalogObjectType](#type-catalogobjecttype) enumeration, namely `\"ITEM\"`, `\"ITEM_VARIATION\"`, `\"CATEGORY\"`, `\"DISCOUNT\"`, `\"TAX\"`, `\"MODIFIER\"`, or `\"MODIFIER_LIST\"`. + The desired set of object types to appear in the search results. The legal values are taken from the [CatalogObjectType](#type-catalogobjecttype) enumeration, namely `\"ITEM\"`, `\"ITEM_VARIATION\"`, `\"CATEGORY\"`, `\"DISCOUNT\"`, `\"TAX\"`, `\"MODIFIER\"`, or `\"MODIFIER_LIST\"`. :param object_types: The object_types of this SearchCatalogObjectsRequest. :type: list[str] diff --git a/squareconnect/models/v1_refund.py b/squareconnect/models/v1_refund.py index da7f951..0425756 100644 --- a/squareconnect/models/v1_refund.py +++ b/squareconnect/models/v1_refund.py @@ -27,7 +27,7 @@ class V1Refund(object): NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ - def __init__(self, type=None, reason=None, refunded_money=None, created_at=None, processed_at=None, payment_id=None, merchant_id=None): + def __init__(self, type=None, reason=None, refunded_money=None, refunded_processing_fee_money=None, refunded_additive_tax_money=None, refunded_inclusive_tax_money=None, refunded_tip_money=None, refunded_discount_money=None, created_at=None, processed_at=None, payment_id=None, merchant_id=None): """ V1Refund - a model defined in Swagger @@ -40,6 +40,11 @@ def __init__(self, type=None, reason=None, refunded_money=None, created_at=None, 'type': 'str', 'reason': 'str', 'refunded_money': 'V1Money', + 'refunded_processing_fee_money': 'V1Money', + 'refunded_additive_tax_money': 'V1Money', + 'refunded_inclusive_tax_money': 'V1Money', + 'refunded_tip_money': 'V1Money', + 'refunded_discount_money': 'V1Money', 'created_at': 'str', 'processed_at': 'str', 'payment_id': 'str', @@ -50,6 +55,11 @@ def __init__(self, type=None, reason=None, refunded_money=None, created_at=None, 'type': 'type', 'reason': 'reason', 'refunded_money': 'refunded_money', + 'refunded_processing_fee_money': 'refunded_processing_fee_money', + 'refunded_additive_tax_money': 'refunded_additive_tax_money', + 'refunded_inclusive_tax_money': 'refunded_inclusive_tax_money', + 'refunded_tip_money': 'refunded_tip_money', + 'refunded_discount_money': 'refunded_discount_money', 'created_at': 'created_at', 'processed_at': 'processed_at', 'payment_id': 'payment_id', @@ -59,6 +69,11 @@ def __init__(self, type=None, reason=None, refunded_money=None, created_at=None, self._type = type self._reason = reason self._refunded_money = refunded_money + self._refunded_processing_fee_money = refunded_processing_fee_money + self._refunded_additive_tax_money = refunded_additive_tax_money + self._refunded_inclusive_tax_money = refunded_inclusive_tax_money + self._refunded_tip_money = refunded_tip_money + self._refunded_discount_money = refunded_discount_money self._created_at = created_at self._processed_at = processed_at self._payment_id = payment_id @@ -133,6 +148,121 @@ def refunded_money(self, refunded_money): self._refunded_money = refunded_money + @property + def refunded_processing_fee_money(self): + """ + Gets the refunded_processing_fee_money of this V1Refund. + The amount of processing fee money refunded. + + :return: The refunded_processing_fee_money of this V1Refund. + :rtype: V1Money + """ + return self._refunded_processing_fee_money + + @refunded_processing_fee_money.setter + def refunded_processing_fee_money(self, refunded_processing_fee_money): + """ + Sets the refunded_processing_fee_money of this V1Refund. + The amount of processing fee money refunded. + + :param refunded_processing_fee_money: The refunded_processing_fee_money of this V1Refund. + :type: V1Money + """ + + self._refunded_processing_fee_money = refunded_processing_fee_money + + @property + def refunded_additive_tax_money(self): + """ + Gets the refunded_additive_tax_money of this V1Refund. + The amount of additive tax money refunded. + + :return: The refunded_additive_tax_money of this V1Refund. + :rtype: V1Money + """ + return self._refunded_additive_tax_money + + @refunded_additive_tax_money.setter + def refunded_additive_tax_money(self, refunded_additive_tax_money): + """ + Sets the refunded_additive_tax_money of this V1Refund. + The amount of additive tax money refunded. + + :param refunded_additive_tax_money: The refunded_additive_tax_money of this V1Refund. + :type: V1Money + """ + + self._refunded_additive_tax_money = refunded_additive_tax_money + + @property + def refunded_inclusive_tax_money(self): + """ + Gets the refunded_inclusive_tax_money of this V1Refund. + The amount of inclusive tax money refunded. + + :return: The refunded_inclusive_tax_money of this V1Refund. + :rtype: V1Money + """ + return self._refunded_inclusive_tax_money + + @refunded_inclusive_tax_money.setter + def refunded_inclusive_tax_money(self, refunded_inclusive_tax_money): + """ + Sets the refunded_inclusive_tax_money of this V1Refund. + The amount of inclusive tax money refunded. + + :param refunded_inclusive_tax_money: The refunded_inclusive_tax_money of this V1Refund. + :type: V1Money + """ + + self._refunded_inclusive_tax_money = refunded_inclusive_tax_money + + @property + def refunded_tip_money(self): + """ + Gets the refunded_tip_money of this V1Refund. + The amount of tip money refunded. + + :return: The refunded_tip_money of this V1Refund. + :rtype: V1Money + """ + return self._refunded_tip_money + + @refunded_tip_money.setter + def refunded_tip_money(self, refunded_tip_money): + """ + Sets the refunded_tip_money of this V1Refund. + The amount of tip money refunded. + + :param refunded_tip_money: The refunded_tip_money of this V1Refund. + :type: V1Money + """ + + self._refunded_tip_money = refunded_tip_money + + @property + def refunded_discount_money(self): + """ + Gets the refunded_discount_money of this V1Refund. + The amount of discount money refunded. + + :return: The refunded_discount_money of this V1Refund. + :rtype: V1Money + """ + return self._refunded_discount_money + + @refunded_discount_money.setter + def refunded_discount_money(self, refunded_discount_money): + """ + Sets the refunded_discount_money of this V1Refund. + The amount of discount money refunded. + + :param refunded_discount_money: The refunded_discount_money of this V1Refund. + :type: V1Money + """ + + self._refunded_discount_money = refunded_discount_money + @property def created_at(self): """ diff --git a/squareconnect/models/v1_variation.py b/squareconnect/models/v1_variation.py index 9dd1c94..a396cf6 100644 --- a/squareconnect/models/v1_variation.py +++ b/squareconnect/models/v1_variation.py @@ -27,7 +27,7 @@ class V1Variation(object): NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ - def __init__(self, id=None, name=None, item_id=None, pricing_type=None, price_money=None, sku=None, track_inventory=None, inventory_alert_type=None, inventory_alert_threshold=None, user_data=None): + def __init__(self, id=None, name=None, item_id=None, ordinal=None, pricing_type=None, price_money=None, sku=None, track_inventory=None, inventory_alert_type=None, inventory_alert_threshold=None, user_data=None): """ V1Variation - a model defined in Swagger @@ -40,6 +40,7 @@ def __init__(self, id=None, name=None, item_id=None, pricing_type=None, price_mo 'id': 'str', 'name': 'str', 'item_id': 'str', + 'ordinal': 'int', 'pricing_type': 'str', 'price_money': 'V1Money', 'sku': 'str', @@ -53,6 +54,7 @@ def __init__(self, id=None, name=None, item_id=None, pricing_type=None, price_mo 'id': 'id', 'name': 'name', 'item_id': 'item_id', + 'ordinal': 'ordinal', 'pricing_type': 'pricing_type', 'price_money': 'price_money', 'sku': 'sku', @@ -65,6 +67,7 @@ def __init__(self, id=None, name=None, item_id=None, pricing_type=None, price_mo self._id = id self._name = name self._item_id = item_id + self._ordinal = ordinal self._pricing_type = pricing_type self._price_money = price_money self._sku = sku @@ -142,6 +145,29 @@ def item_id(self, item_id): self._item_id = item_id + @property + def ordinal(self): + """ + Gets the ordinal of this V1Variation. + Indicates the variation's list position when displayed in Square Register and the merchant dashboard. If more than one variation for the same item has the same ordinal value, those variations are displayed in alphabetical order + + :return: The ordinal of this V1Variation. + :rtype: int + """ + return self._ordinal + + @ordinal.setter + def ordinal(self, ordinal): + """ + Sets the ordinal of this V1Variation. + Indicates the variation's list position when displayed in Square Register and the merchant dashboard. If more than one variation for the same item has the same ordinal value, those variations are displayed in alphabetical order + + :param ordinal: The ordinal of this V1Variation. + :type: int + """ + + self._ordinal = ordinal + @property def pricing_type(self): """ diff --git a/squareconnect/rest.py b/squareconnect/rest.py index 02cbe45..7b3aff2 100644 --- a/squareconnect/rest.py +++ b/squareconnect/rest.py @@ -24,6 +24,7 @@ import ssl import certifi import logging +import re # python 2 and python 3 compatibility library from six import iteritems @@ -38,10 +39,11 @@ try: # for python3 from urllib.parse import urlencode + from urllib.parse import urlparse except ImportError: # for python2 from urllib import urlencode - + import urlparse logger = logging.getLogger(__name__) @@ -52,7 +54,7 @@ def __init__(self, resp, method): self.urllib3_response = resp self.status = resp.status self.reason = resp.reason - # In Square Connect v2 API, + # In Square Connect v2 API, # GET ListCustomers/ListLocations/ListTransaction/ListRefunds # may have large response thus calling stream() for chunked-encoding if method in ['GET', 'HEAD']: @@ -62,7 +64,7 @@ def __init__(self, resp, method): # we need to decode it to string. if sys.version_info > (3,): self.data += chunk.decode('utf8') - else: + else: self.data += str(chunk) # as using preload_content=False, we should call release_conn() # to release the http connection back to the connection pool so that @@ -86,6 +88,18 @@ def getheader(self, name, default=None): """ return self.urllib3_response.getheader(name, default) + def getbatch_token(self): + link_header = self.getheader('Link') + if link_header != None: + match = re.match("^<([^>]+)>;rel='next'$", link_header) + if match != None: + next_url = match.group(1) + parsed_url = urlparse.urlparse(next_url) + parameters = urlparse.parse_qs(parsed_url.query) + if parameters.has_key('batch_token'): + return parameters['batch_token'][0] + return None + class RESTClientObject(object): @@ -178,7 +192,7 @@ def request(self, method, url, query_params=None, headers=None, fields=query_params, headers=headers, preload_content=False) - + except urllib3.exceptions.SSLError as e: msg = "{0}\n{1}".format(type(e).__name__, str(e)) raise ApiException(status=0, reason=msg) diff --git a/tox.ini b/tox.ini index d99517b..1cf0829 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27, py34 +envlist = py27, py3 [testenv] deps=-r{toxinidir}/requirements.txt From 153b85be33d93d8cc9de0f95d4c373c70fa01014 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Fri, 11 Aug 2017 17:29:37 +0000 Subject: [PATCH 2/3] From connect-api-specification: Merge pull request #65 from square/tristans/fix-interger-typo [2.2.1] Bug fixes --- docs/V1PaymentItemDetail.md | 2 +- squareconnect/models/v1_payment_item_detail.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/V1PaymentItemDetail.md b/docs/V1PaymentItemDetail.md index 8518514..e9cc481 100644 --- a/docs/V1PaymentItemDetail.md +++ b/docs/V1PaymentItemDetail.md @@ -7,7 +7,7 @@ Name | Type | Notes ------------ | ------------- | ------------- **category_name** | **str** | [optional] -**sku** | **float** | [optional] +**sku** | **str** | [optional] **item_id** | **str** | [optional] **item_variation_id** | **str** | [optional] diff --git a/squareconnect/models/v1_payment_item_detail.py b/squareconnect/models/v1_payment_item_detail.py index d0584c0..973db58 100644 --- a/squareconnect/models/v1_payment_item_detail.py +++ b/squareconnect/models/v1_payment_item_detail.py @@ -38,7 +38,7 @@ def __init__(self, category_name=None, sku=None, item_id=None, item_variation_id """ self.swagger_types = { 'category_name': 'str', - 'sku': 'float', + 'sku': 'str', 'item_id': 'str', 'item_variation_id': 'str' } @@ -85,7 +85,7 @@ def sku(self): The item's merchant-defined SKU, if any. :return: The sku of this V1PaymentItemDetail. - :rtype: float + :rtype: str """ return self._sku @@ -96,7 +96,7 @@ def sku(self, sku): The item's merchant-defined SKU, if any. :param sku: The sku of this V1PaymentItemDetail. - :type: float + :type: str """ self._sku = sku From 88d1ee9442423ab17ac1790f632b87ad928fe61c Mon Sep 17 00:00:00 2001 From: Juan Pablo Marzetti Date: Fri, 11 Aug 2017 11:57:45 -0700 Subject: [PATCH 3/3] Release 2.2.1 Changes --- CHANGES.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 561a01d..aed203d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,12 @@ # Change Log +## Version 2.2.1 (2017-08-11) + +* Documentation style and links fixes +* Support for pagination on V1 endpoints +* Include refund detail fields on V1 Refund model +* Fix locations example on README + ### Version 2.0.2 (2017-02-07) * Bug Fixes for List Locations endpoint