diff --git a/doc/api/events.md b/doc/api/events.md new file mode 100644 index 0000000..50fbd1e --- /dev/null +++ b/doc/api/events.md @@ -0,0 +1,135 @@ +# Events + +```python +events_api = client.events +``` + +## Class Name + +`EventsApi` + +## Methods + +* [Search Events](../../doc/api/events.md#search-events) +* [Disable Events](../../doc/api/events.md#disable-events) +* [Enable Events](../../doc/api/events.md#enable-events) +* [List Event Types](../../doc/api/events.md#list-event-types) + + +# Search Events + +Search for Square API events that occur within a 28-day timeframe. + +```python +def search_events(self, + body) +``` + +## Parameters + +| Parameter | Type | Tags | Description | +| --- | --- | --- | --- | +| `body` | [`Search Events Request`](../../doc/models/search-events-request.md) | Body, Required | An object containing the fields to POST for the request.

See the corresponding object definition for field details. | + +## Response Type + +This method returns a `ApiResponse` instance. The `body` property of this instance returns the response data which is of type [`Search Events Response`](../../doc/models/search-events-response.md). + +## Example Usage + +```python +body = {} + +result = events_api.search_events(body) +print(result) + +if result.is_success(): + print(result.body) +elif result.is_error(): + print(result.errors) +``` + + +# Disable Events + +Disables events to prevent them from being searchable. +All events are disabled by default. You must enable events to make them searchable. +Disabling events for a specific time period prevents them from being searchable, even if you re-enable them later. + +```python +def disable_events(self) +``` + +## Response Type + +This method returns a `ApiResponse` instance. The `body` property of this instance returns the response data which is of type [`Disable Events Response`](../../doc/models/disable-events-response.md). + +## Example Usage + +```python +result = events_api.disable_events() +print(result) + +if result.is_success(): + print(result.body) +elif result.is_error(): + print(result.errors) +``` + + +# Enable Events + +Enables events to make them searchable. Only events that occur while in the enabled state are searchable. + +```python +def enable_events(self) +``` + +## Response Type + +This method returns a `ApiResponse` instance. The `body` property of this instance returns the response data which is of type [`Enable Events Response`](../../doc/models/enable-events-response.md). + +## Example Usage + +```python +result = events_api.enable_events() +print(result) + +if result.is_success(): + print(result.body) +elif result.is_error(): + print(result.errors) +``` + + +# List Event Types + +Lists all event types that you can subscribe to as webhooks or query using the Events API. + +```python +def list_event_types(self, + api_version=None) +``` + +## Parameters + +| Parameter | Type | Tags | Description | +| --- | --- | --- | --- | +| `api_version` | `str` | Query, Optional | The API version for which to list event types. Setting this field overrides the default version used by the application. | + +## Response Type + +This method returns a `ApiResponse` instance. The `body` property of this instance returns the response data which is of type [`List Event Types Response`](../../doc/models/list-event-types-response.md). + +## Example Usage + +```python +result = events_api.list_event_types() +print(result) + +if result.is_success(): + print(result.body) +elif result.is_error(): + print(result.errors) +``` + diff --git a/doc/client.md b/doc/client.md index 810f1a6..a305f4f 100644 --- a/doc/client.md +++ b/doc/client.md @@ -5,7 +5,7 @@ The following parameters are configurable for the API Client: | Parameter | Type | Description | | --- | --- | --- | -| `square_version` | `str` | Square Connect API versions
*Default*: `'2024-05-15'` | +| `square_version` | `str` | Square Connect API versions
*Default*: `'2024-06-04'` | | `custom_url` | `str` | Sets the base URL requests are made to. Defaults to `https://connect.squareup.com`
*Default*: `'https://connect.squareup.com'` | | `environment` | `string` | The API environment.
**Default: `production`** | | `http_client_instance` | `HttpClient` | The Http Client passed from the sdk user for making requests | @@ -24,7 +24,7 @@ The API client can be initialized as follows: ```python client = Client( - square_version='2024-05-15', + square_version='2024-06-04', bearer_auth_credentials=BearerAuthCredentials( access_token='AccessToken' ) @@ -51,7 +51,7 @@ from square.http.auth.o_auth_2 import BearerAuthCredentials from square.client import Client client = Client( - square_version='2024-05-15', + square_version='2024-06-04', bearer_auth_credentials=BearerAuthCredentials( access_token='AccessToken' ) @@ -92,6 +92,7 @@ The gateway for the SDK. This class acts as a factory for the Apis and also hold | devices | Gets DevicesApi | | disputes | Gets DisputesApi | | employees | Gets EmployeesApi | +| events | Gets EventsApi | | gift_cards | Gets GiftCardsApi | | gift_card_activities | Gets GiftCardActivitiesApi | | inventory | Gets InventoryApi | diff --git a/doc/models/disable-events-response.md b/doc/models/disable-events-response.md new file mode 100644 index 0000000..7114fc1 --- /dev/null +++ b/doc/models/disable-events-response.md @@ -0,0 +1,40 @@ + +# Disable Events Response + +Defines the fields that are included in the response body of +a request to the [DisableEvents](../../doc/api/events.md#disable-events) endpoint. + +Note: if there are errors processing the request, the events field will not be +present. + +## Structure + +`Disable Events Response` + +## Fields + +| Name | Type | Tags | Description | +| --- | --- | --- | --- | +| `errors` | [`List Error`](../../doc/models/error.md) | Optional | Information on errors encountered during the request. | + +## Example (as JSON) + +```json +{ + "errors": [ + { + "category": "MERCHANT_SUBSCRIPTION_ERROR", + "code": "MAP_KEY_LENGTH_TOO_LONG", + "detail": "detail6", + "field": "field4" + }, + { + "category": "MERCHANT_SUBSCRIPTION_ERROR", + "code": "MAP_KEY_LENGTH_TOO_LONG", + "detail": "detail6", + "field": "field4" + } + ] +} +``` + diff --git a/doc/models/enable-events-response.md b/doc/models/enable-events-response.md new file mode 100644 index 0000000..d9ac159 --- /dev/null +++ b/doc/models/enable-events-response.md @@ -0,0 +1,34 @@ + +# Enable Events Response + +Defines the fields that are included in the response body of +a request to the [EnableEvents](../../doc/api/events.md#enable-events) endpoint. + +Note: if there are errors processing the request, the events field will not be +present. + +## Structure + +`Enable Events Response` + +## Fields + +| Name | Type | Tags | Description | +| --- | --- | --- | --- | +| `errors` | [`List Error`](../../doc/models/error.md) | Optional | Information on errors encountered during the request. | + +## Example (as JSON) + +```json +{ + "errors": [ + { + "category": "MERCHANT_SUBSCRIPTION_ERROR", + "code": "MAP_KEY_LENGTH_TOO_LONG", + "detail": "detail6", + "field": "field4" + } + ] +} +``` + diff --git a/doc/models/event-data.md b/doc/models/event-data.md index e6df5e0..82d013f 100644 --- a/doc/models/event-data.md +++ b/doc/models/event-data.md @@ -9,10 +9,10 @@ | Name | Type | Tags | Description | | --- | --- | --- | --- | -| `type` | `str` | Optional | Name of the affected object’s type. | -| `id` | `str` | Optional | ID of the affected object. | -| `deleted` | `bool` | Optional | Is true if the affected object was deleted. Otherwise absent. | -| `object` | `dict` | Optional | An object containing fields and values relevant to the event. Is absent if affected object was deleted. | +| `type` | `str` | Optional | The name of the affected object’s type. | +| `id` | `str` | Optional | The ID of the affected object. | +| `deleted` | `bool` | Optional | This is true if the affected object has been deleted; otherwise, it's absent. | +| `object` | `dict` | Optional | An object containing fields and values relevant to the event. It is absent if the affected object has been deleted. | ## Example (as JSON) diff --git a/doc/models/event-metadata.md b/doc/models/event-metadata.md new file mode 100644 index 0000000..4942223 --- /dev/null +++ b/doc/models/event-metadata.md @@ -0,0 +1,25 @@ + +# Event Metadata + +Contains metadata about a particular [Event](../../doc/models/event.md). + +## Structure + +`Event Metadata` + +## Fields + +| Name | Type | Tags | Description | +| --- | --- | --- | --- | +| `event_id` | `str` | Optional | A unique ID for the event. | +| `api_version` | `str` | Optional | The API version of the event. This corresponds to the default API version of the developer application at the time when the event was created. | + +## Example (as JSON) + +```json +{ + "event_id": "event_id0", + "api_version": "api_version6" +} +``` + diff --git a/doc/models/event.md b/doc/models/event.md index a683f44..85cfd59 100644 --- a/doc/models/event.md +++ b/doc/models/event.md @@ -10,7 +10,7 @@ | Name | Type | Tags | Description | | --- | --- | --- | --- | | `merchant_id` | `str` | Optional | The ID of the target merchant associated with the event. | -| `location_id` | `str` | Optional | The ID of the location associated with the event. | +| `location_id` | `str` | Optional | The ID of the target location associated with the event. | | `type` | `str` | Optional | The type of event this represents. | | `event_id` | `str` | Optional | A unique ID for the event. | | `created_at` | `str` | Optional | Timestamp of when the event was created, in RFC 3339 format. | diff --git a/doc/models/list-event-types-request.md b/doc/models/list-event-types-request.md new file mode 100644 index 0000000..f14bea3 --- /dev/null +++ b/doc/models/list-event-types-request.md @@ -0,0 +1,23 @@ + +# List Event Types Request + +Lists all event types that can be subscribed to. + +## Structure + +`List Event Types Request` + +## Fields + +| Name | Type | Tags | Description | +| --- | --- | --- | --- | +| `api_version` | `str` | Optional | The API version for which to list event types. Setting this field overrides the default version used by the application. | + +## Example (as JSON) + +```json +{ + "api_version": "api_version0" +} +``` + diff --git a/doc/models/list-event-types-response.md b/doc/models/list-event-types-response.md new file mode 100644 index 0000000..5a39f91 --- /dev/null +++ b/doc/models/list-event-types-response.md @@ -0,0 +1,52 @@ + +# List Event Types Response + +Defines the fields that are included in the response body of +a request to the [ListEventTypes](../../doc/api/events.md#list-event-types) endpoint. + +Note: if there are errors processing the request, the event types field will not be +present. + +## Structure + +`List Event Types Response` + +## Fields + +| Name | Type | Tags | Description | +| --- | --- | --- | --- | +| `errors` | [`List Error`](../../doc/models/error.md) | Optional | Information on errors encountered during the request. | +| `event_types` | `List[str]` | Optional | The list of event types. | +| `metadata` | [`List Event Type Metadata`](../../doc/models/event-type-metadata.md) | Optional | Contains the metadata of an event type. For more information, see [EventTypeMetadata](entity:EventTypeMetadata). | + +## Example (as JSON) + +```json +{ + "event_types": [ + "inventory.count.updated" + ], + "metadata": [ + { + "api_version_introduced": "2018-07-12", + "event_type": "inventory.count.updated", + "release_status": "PUBLIC" + } + ], + "errors": [ + { + "category": "MERCHANT_SUBSCRIPTION_ERROR", + "code": "MAP_KEY_LENGTH_TOO_LONG", + "detail": "detail6", + "field": "field4" + }, + { + "category": "MERCHANT_SUBSCRIPTION_ERROR", + "code": "MAP_KEY_LENGTH_TOO_LONG", + "detail": "detail6", + "field": "field4" + } + ] +} +``` + diff --git a/doc/models/quantity-ratio.md b/doc/models/quantity-ratio.md index 0b1f6e9..d0a8127 100644 --- a/doc/models/quantity-ratio.md +++ b/doc/models/quantity-ratio.md @@ -12,7 +12,7 @@ A whole number or unreduced fractional ratio. | Name | Type | Tags | Description | | --- | --- | --- | --- | | `quantity` | `int` | Optional | The whole or fractional quantity as the numerator. | -| `quantity_denominator` | `int` | Optional | The whole or fractional quantity as the denominator.
In the case of fractional quantity this field is the denominator and quantity is the numerator.
When unspecified, the value is `1`. For example, when `quantity=3` and `quantity_donominator` is unspecified,
the quantity ratio is `3` or `3/1`. | +| `quantity_denominator` | `int` | Optional | The whole or fractional quantity as the denominator.
With fractional quantity this field is the denominator and quantity is the numerator.
The default value is `1`. For example, when `quantity=3` and `quantity_denominator` is unspecified,
the quantity ratio is `3` or `3/1`. | ## Example (as JSON) diff --git a/doc/models/search-events-filter.md b/doc/models/search-events-filter.md new file mode 100644 index 0000000..687ecb5 --- /dev/null +++ b/doc/models/search-events-filter.md @@ -0,0 +1,43 @@ + +# Search Events Filter + +Criteria to filter events by. + +## Structure + +`Search Events Filter` + +## Fields + +| Name | Type | Tags | Description | +| --- | --- | --- | --- | +| `event_types` | `List[str]` | Optional | Filter events by event types. | +| `merchant_ids` | `List[str]` | Optional | Filter events by merchant. | +| `location_ids` | `List[str]` | Optional | Filter events by location. | +| `created_at` | [`Time Range`](../../doc/models/time-range.md) | Optional | Represents a generic time range. The start and end values are
represented in RFC 3339 format. Time ranges are customized to be
inclusive or exclusive based on the needs of a particular endpoint.
Refer to the relevant endpoint-specific documentation to determine
how time ranges are handled. | + +## Example (as JSON) + +```json +{ + "event_types": [ + "event_types6", + "event_types7", + "event_types8" + ], + "merchant_ids": [ + "merchant_ids5", + "merchant_ids6", + "merchant_ids7" + ], + "location_ids": [ + "location_ids8", + "location_ids9" + ], + "created_at": { + "start_at": "start_at4", + "end_at": "end_at8" + } +} +``` + diff --git a/doc/models/search-events-query.md b/doc/models/search-events-query.md new file mode 100644 index 0000000..b4ffed9 --- /dev/null +++ b/doc/models/search-events-query.md @@ -0,0 +1,44 @@ + +# Search Events Query + +Contains query criteria for the search. + +## Structure + +`Search Events Query` + +## Fields + +| Name | Type | Tags | Description | +| --- | --- | --- | --- | +| `filter` | [`Search Events Filter`](../../doc/models/search-events-filter.md) | Optional | Criteria to filter events by. | +| `sort` | [`Search Events Sort`](../../doc/models/search-events-sort.md) | Optional | Criteria to sort events by. | + +## Example (as JSON) + +```json +{ + "filter": { + "event_types": [ + "event_types2", + "event_types3" + ], + "merchant_ids": [ + "merchant_ids1", + "merchant_ids2" + ], + "location_ids": [ + "location_ids4" + ], + "created_at": { + "start_at": "start_at4", + "end_at": "end_at8" + } + }, + "sort": { + "field": "DEFAULT", + "order": "DESC" + } +} +``` + diff --git a/doc/models/search-events-request.md b/doc/models/search-events-request.md new file mode 100644 index 0000000..1c53fcf --- /dev/null +++ b/doc/models/search-events-request.md @@ -0,0 +1,49 @@ + +# Search Events Request + +Searches [Event](../../doc/models/event.md)s for your application. + +## Structure + +`Search Events Request` + +## Fields + +| Name | Type | Tags | Description | +| --- | --- | --- | --- | +| `cursor` | `str` | Optional | A pagination cursor returned by a previous call to this endpoint. Provide this cursor to retrieve the next set of events for your original query.

For more information, see [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination).
**Constraints**: *Maximum Length*: `256` | +| `limit` | `int` | Optional | The maximum number of events to return in a single page. The response might contain fewer events. The default value is 100, which is also the maximum allowed value.

For more information, see [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination).

Default: 100
**Constraints**: `>= 1`, `<= 100` | +| `query` | [`Search Events Query`](../../doc/models/search-events-query.md) | Optional | Contains query criteria for the search. | + +## Example (as JSON) + +```json +{ + "cursor": "cursor8", + "limit": 176, + "query": { + "filter": { + "event_types": [ + "event_types2", + "event_types3" + ], + "merchant_ids": [ + "merchant_ids1", + "merchant_ids2" + ], + "location_ids": [ + "location_ids4" + ], + "created_at": { + "start_at": "start_at4", + "end_at": "end_at8" + } + }, + "sort": { + "field": "DEFAULT", + "order": "DESC" + } + } +} +``` + diff --git a/doc/models/search-events-response.md b/doc/models/search-events-response.md new file mode 100644 index 0000000..9e8754f --- /dev/null +++ b/doc/models/search-events-response.md @@ -0,0 +1,85 @@ + +# Search Events Response + +Defines the fields that are included in the response body of +a request to the [SearchEvents](../../doc/api/events.md#search-events) endpoint. + +Note: if there are errors processing the request, the events field will not be +present. + +## Structure + +`Search Events Response` + +## Fields + +| Name | Type | Tags | Description | +| --- | --- | --- | --- | +| `errors` | [`List Error`](../../doc/models/error.md) | Optional | Information on errors encountered during the request. | +| `events` | [`List Event`](../../doc/models/event.md) | Optional | The list of [Event](entity:Event)s returned by the search. | +| `metadata` | [`List Event Metadata`](../../doc/models/event-metadata.md) | Optional | Contains the metadata of an event. For more information, see [Event](entity:Event). | +| `cursor` | `str` | Optional | When a response is truncated, it includes a cursor that you can use in a subsequent request to fetch the next set of events. If empty, this is the final response.

For more information, see [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). | + +## Example (as JSON) + +```json +{ + "cursor": "6b571fc9773647f=", + "events": [ + { + "created_at": "2022-04-26T10:08:40.454726", + "data": { + "id": "ORSEVtZAJxb37RA1EiGw", + "object": { + "dispute": { + "amount_money": { + "amount": 8801, + "currency": "USD" + }, + "brand_dispute_id": "r9rKGSBBQbywBNnWWIiGFg", + "card_brand": "VISA", + "created_at": "2020-02-19T21:24:53.258Z", + "disputed_payment": { + "payment_id": "fbmsaEOpoARDKxiSGH1fqPuqoqFZY" + }, + "due_at": "2020-03-04T00:00:00.000Z", + "id": "ORSEVtZAJxb37RA1EiGw", + "location_id": "VJDQQP3CG14EY", + "reason": "AMOUNT_DIFFERS", + "reported_at": "2020-02-19T00:00:00.000Z", + "state": "WON", + "updated_at": "2020-02-19T21:34:41.851Z", + "version": 6 + } + }, + "type": "dispute" + }, + "event_id": "73ecd468-0aba-424f-b862-583d44efe7c8", + "location_id": "VJDQQP3CG14EY", + "merchant_id": "0HPGX5JYE6EE1", + "type": "dispute.state.updated" + } + ], + "metadata": [ + { + "api_version": "2022-12-13", + "event_id": "73ecd468-0aba-424f-b862-583d44efe7c8" + } + ], + "errors": [ + { + "category": "MERCHANT_SUBSCRIPTION_ERROR", + "code": "MAP_KEY_LENGTH_TOO_LONG", + "detail": "detail6", + "field": "field4" + }, + { + "category": "MERCHANT_SUBSCRIPTION_ERROR", + "code": "MAP_KEY_LENGTH_TOO_LONG", + "detail": "detail6", + "field": "field4" + } + ] +} +``` + diff --git a/doc/models/search-events-sort-field.md b/doc/models/search-events-sort-field.md new file mode 100644 index 0000000..01df182 --- /dev/null +++ b/doc/models/search-events-sort-field.md @@ -0,0 +1,15 @@ + +# Search Events Sort Field + +Specifies the sort key for events returned from a search. + +## Enumeration + +`Search Events Sort Field` + +## Fields + +| Name | Description | +| --- | --- | +| `DEFAULT` | Use the default sort key. The default behavior is to sort events by when they were created (`created_at`). | + diff --git a/doc/models/search-events-sort.md b/doc/models/search-events-sort.md new file mode 100644 index 0000000..7f19b35 --- /dev/null +++ b/doc/models/search-events-sort.md @@ -0,0 +1,25 @@ + +# Search Events Sort + +Criteria to sort events by. + +## Structure + +`Search Events Sort` + +## Fields + +| Name | Type | Tags | Description | +| --- | --- | --- | --- | +| `field` | [`str (Search Events Sort Field)`](../../doc/models/search-events-sort-field.md) | Optional | Specifies the sort key for events returned from a search. | +| `order` | [`str (Sort Order)`](../../doc/models/sort-order.md) | Optional | The order (e.g., chronological or alphabetical) in which results from a request are returned. | + +## Example (as JSON) + +```json +{ + "field": "DEFAULT", + "order": "DESC" +} +``` + diff --git a/pyproject.toml b/pyproject.toml index ea26560..35bc7eb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ requires = ["setuptools>=61.0"] [project] name = "squareup" description = "Use Square APIs to manage and run business including payment, customer, product, inventory, and employee management." -version = "37.0.0.20240515" +version = "37.1.0.20240604" readme = "README.md" requires-python = ">=3.7" authors = [{name = "Square Developer Platform", email = "developers@squareup.com"}] diff --git a/square/api/__init__.py b/square/api/__init__.py index af0df6f..a047993 100644 --- a/square/api/__init__.py +++ b/square/api/__init__.py @@ -17,6 +17,7 @@ 'devices_api', 'disputes_api', 'employees_api', + 'events_api', 'gift_cards_api', 'gift_card_activities_api', 'inventory_api', diff --git a/square/api/base_api.py b/square/api/base_api.py index b3856c9..82493ac 100644 --- a/square/api/base_api.py +++ b/square/api/base_api.py @@ -22,7 +22,7 @@ class BaseApi(object): @staticmethod def user_agent(): - return 'Square-Python-SDK/37.0.0.20240515 ({api-version}) {engine}/{engine-version} ({os-info}) {detail}' + return 'Square-Python-SDK/37.1.0.20240604 ({api-version}) {engine}/{engine-version} ({os-info}) {detail}' @staticmethod def user_agent_parameters(): diff --git a/square/api/events_api.py b/square/api/events_api.py new file mode 100644 index 0000000..cde4a62 --- /dev/null +++ b/square/api/events_api.py @@ -0,0 +1,172 @@ +# -*- coding: utf-8 -*- + +from square.api_helper import APIHelper +from square.http.api_response import ApiResponse +from square.api.base_api import BaseApi +from apimatic_core.request_builder import RequestBuilder +from apimatic_core.response_handler import ResponseHandler +from apimatic_core.types.parameter import Parameter +from square.http.http_method_enum import HttpMethodEnum +from apimatic_core.authentication.multiple.single_auth import Single + + +class EventsApi(BaseApi): + + """A Controller to access Endpoints in the square API.""" + def __init__(self, config): + super(EventsApi, self).__init__(config) + + def search_events(self, + body): + """Does a POST request to /v2/events. + + Search for Square API events that occur within a 28-day timeframe. + + Args: + body (SearchEventsRequest): An object containing the fields to + POST for the request. See the corresponding object definition + for field details. + + Returns: + ApiResponse: An object with the response value as well as other + useful information such as status codes and headers. Success + + Raises: + APIException: When an error occurs while fetching the data from + the remote API. This exception includes the HTTP Response + code, an error message, and the HTTP body that was received in + the request. + + """ + + return super().new_api_call_builder.request( + RequestBuilder().server('default') + .path('/v2/events') + .http_method(HttpMethodEnum.POST) + .header_param(Parameter() + .key('Content-Type') + .value('application/json')) + .body_param(Parameter() + .value(body)) + .header_param(Parameter() + .key('accept') + .value('application/json')) + .body_serializer(APIHelper.json_serialize) + .auth(Single('global')) + ).response( + ResponseHandler() + .deserializer(APIHelper.json_deserialize) + .is_api_response(True) + .convertor(ApiResponse.create) + ).execute() + + def disable_events(self): + """Does a PUT request to /v2/events/disable. + + Disables events to prevent them from being searchable. + All events are disabled by default. You must enable events to make + them searchable. + Disabling events for a specific time period prevents them from being + searchable, even if you re-enable them later. + + Returns: + ApiResponse: An object with the response value as well as other + useful information such as status codes and headers. Success + + Raises: + APIException: When an error occurs while fetching the data from + the remote API. This exception includes the HTTP Response + code, an error message, and the HTTP body that was received in + the request. + + """ + + return super().new_api_call_builder.request( + RequestBuilder().server('default') + .path('/v2/events/disable') + .http_method(HttpMethodEnum.PUT) + .header_param(Parameter() + .key('accept') + .value('application/json')) + .auth(Single('global')) + ).response( + ResponseHandler() + .deserializer(APIHelper.json_deserialize) + .is_api_response(True) + .convertor(ApiResponse.create) + ).execute() + + def enable_events(self): + """Does a PUT request to /v2/events/enable. + + Enables events to make them searchable. Only events that occur while + in the enabled state are searchable. + + Returns: + ApiResponse: An object with the response value as well as other + useful information such as status codes and headers. Success + + Raises: + APIException: When an error occurs while fetching the data from + the remote API. This exception includes the HTTP Response + code, an error message, and the HTTP body that was received in + the request. + + """ + + return super().new_api_call_builder.request( + RequestBuilder().server('default') + .path('/v2/events/enable') + .http_method(HttpMethodEnum.PUT) + .header_param(Parameter() + .key('accept') + .value('application/json')) + .auth(Single('global')) + ).response( + ResponseHandler() + .deserializer(APIHelper.json_deserialize) + .is_api_response(True) + .convertor(ApiResponse.create) + ).execute() + + def list_event_types(self, + api_version=None): + """Does a GET request to /v2/events/types. + + Lists all event types that you can subscribe to as webhooks or query + using the Events API. + + Args: + api_version (str, optional): The API version for which to list + event types. Setting this field overrides the default version + used by the application. + + Returns: + ApiResponse: An object with the response value as well as other + useful information such as status codes and headers. Success + + Raises: + APIException: When an error occurs while fetching the data from + the remote API. This exception includes the HTTP Response + code, an error message, and the HTTP body that was received in + the request. + + """ + + return super().new_api_call_builder.request( + RequestBuilder().server('default') + .path('/v2/events/types') + .http_method(HttpMethodEnum.GET) + .query_param(Parameter() + .key('api_version') + .value(api_version)) + .header_param(Parameter() + .key('accept') + .value('application/json')) + .auth(Single('global')) + ).response( + ResponseHandler() + .deserializer(APIHelper.json_deserialize) + .is_api_response(True) + .convertor(ApiResponse.create) + ).execute() diff --git a/square/client.py b/square/client.py index 298ec10..0a5ba5e 100644 --- a/square/client.py +++ b/square/client.py @@ -23,6 +23,7 @@ from square.api.devices_api import DevicesApi from square.api.disputes_api import DisputesApi from square.api.employees_api import EmployeesApi +from square.api.events_api import EventsApi from square.api.gift_cards_api import GiftCardsApi from square.api.gift_card_activities_api import GiftCardActivitiesApi from square.api.inventory_api import InventoryApi @@ -54,11 +55,11 @@ class Client(object): @staticmethod def sdk_version(): - return '37.0.0.20240515' + return '37.1.0.20240604' @staticmethod def square_version(): - return '2024-05-15' + return '2024-06-04' def user_agent_detail(self): return self.config.user_agent_detail @@ -131,6 +132,10 @@ def disputes(self): def employees(self): return EmployeesApi(self.global_configuration) + @LazyProperty + def events(self): + return EventsApi(self.global_configuration) + @LazyProperty def gift_cards(self): return GiftCardsApi(self.global_configuration) @@ -233,7 +238,7 @@ def __init__(self, http_client_instance=None, retry_statuses=None, retry_methods=None, environment='production', custom_url='https://connect.squareup.com', access_token=None, - bearer_auth_credentials=None, square_version='2024-05-15', + bearer_auth_credentials=None, square_version='2024-06-04', additional_headers={}, user_agent_detail='', config=None): self.config = config or Configuration( http_client_instance=http_client_instance, diff --git a/square/configuration.py b/square/configuration.py index 4c4c706..bfc0e8c 100644 --- a/square/configuration.py +++ b/square/configuration.py @@ -45,7 +45,7 @@ def __init__(self, http_client_instance=None, retry_statuses=None, retry_methods=None, environment='production', custom_url='https://connect.squareup.com', access_token=None, - bearer_auth_credentials=None, square_version='2024-05-15', + bearer_auth_credentials=None, square_version='2024-06-04', additional_headers={}, user_agent_detail=''): if retry_methods is None: retry_methods = ['GET', 'PUT']