From 39e6efb6c45303cc20562e0ac769a170bf1993ac Mon Sep 17 00:00:00 2001 From: autobot Date: Mon, 3 Jun 2024 17:05:58 +0000 Subject: [PATCH] Generated PR for Release: 38.1.0.20240604 --- doc/api/events.md | 134 ++++++++++++++++++++++++ doc/client.md | 5 +- doc/models/disable-events-response.md | 40 +++++++ doc/models/enable-events-response.md | 34 ++++++ doc/models/event-data.md | 8 +- doc/models/event-metadata.md | 25 +++++ doc/models/event.md | 2 +- doc/models/list-event-types-request.md | 23 ++++ doc/models/list-event-types-response.md | 52 +++++++++ doc/models/quantity-ratio.md | 2 +- doc/models/search-events-filter.md | 43 ++++++++ doc/models/search-events-query.md | 44 ++++++++ doc/models/search-events-request.md | 49 +++++++++ doc/models/search-events-response.md | 85 +++++++++++++++ doc/models/search-events-sort-field.md | 15 +++ doc/models/search-events-sort.md | 25 +++++ lib/square.rb | 1 + lib/square/api/base_api.rb | 2 +- lib/square/api/events_api.rb | 84 +++++++++++++++ lib/square/client.rb | 10 +- lib/square/configuration.rb | 6 +- square.gemspec | 2 +- 22 files changed, 676 insertions(+), 15 deletions(-) create mode 100644 doc/api/events.md create mode 100644 doc/models/disable-events-response.md create mode 100644 doc/models/enable-events-response.md create mode 100644 doc/models/event-metadata.md create mode 100644 doc/models/list-event-types-request.md create mode 100644 doc/models/list-event-types-response.md create mode 100644 doc/models/search-events-filter.md create mode 100644 doc/models/search-events-query.md create mode 100644 doc/models/search-events-request.md create mode 100644 doc/models/search-events-response.md create mode 100644 doc/models/search-events-sort-field.md create mode 100644 doc/models/search-events-sort.md create mode 100644 lib/square/api/events_api.rb diff --git a/doc/api/events.md b/doc/api/events.md new file mode 100644 index 00000000..5bcc7a8f --- /dev/null +++ b/doc/api/events.md @@ -0,0 +1,134 @@ +# Events + +```ruby +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. + +```ruby +def search_events(body:) +``` + +## Parameters + +| Parameter | Type | Tags | Description | +| --- | --- | --- | --- | +| `body` | [`Search Events Request Hash`](../../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 `data` property in this instance returns the response data which is of type [`Search Events Response Hash`](../../doc/models/search-events-response.md). + +## Example Usage + +```ruby +body = {} + + +result = events_api.search_events(body: body) + +if result.success? + puts result.data +elsif result.error? + warn result.errors +end +``` + + +# 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. + +```ruby +def disable_events +``` + +## Response Type + +This method returns a `\ApiResponse` instance. The `data` property in this instance returns the response data which is of type [`Disable Events Response Hash`](../../doc/models/disable-events-response.md). + +## Example Usage + +```ruby +result = events_api.disable_events + +if result.success? + puts result.data +elsif result.error? + warn result.errors +end +``` + + +# Enable Events + +Enables events to make them searchable. Only events that occur while in the enabled state are searchable. + +```ruby +def enable_events +``` + +## Response Type + +This method returns a `\ApiResponse` instance. The `data` property in this instance returns the response data which is of type [`Enable Events Response Hash`](../../doc/models/enable-events-response.md). + +## Example Usage + +```ruby +result = events_api.enable_events + +if result.success? + puts result.data +elsif result.error? + warn result.errors +end +``` + + +# List Event Types + +Lists all event types that you can subscribe to as webhooks or query using the Events API. + +```ruby +def list_event_types(api_version: nil) +``` + +## Parameters + +| Parameter | Type | Tags | Description | +| --- | --- | --- | --- | +| `api_version` | `String` | 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 `data` property in this instance returns the response data which is of type [`List Event Types Response Hash`](../../doc/models/list-event-types-response.md). + +## Example Usage + +```ruby +result = events_api.list_event_types + +if result.success? + puts result.data +elsif result.error? + warn result.errors +end +``` + diff --git a/doc/client.md b/doc/client.md index aba9cd79..c646122d 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` | `String` | Square Connect API versions
*Default*: `'2024-05-15'` | +| `square_version` | `String` | Square Connect API versions
*Default*: `'2024-06-04'` | | `custom_url` | `String` | 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`** | | `connection` | `Faraday::Connection` | The Faraday connection object passed by the SDK user for making requests | @@ -25,7 +25,7 @@ The API client can be initialized as follows: ```ruby client = Square::Client.new( - square_version: '2024-05-15', + square_version: '2024-06-04', bearer_auth_credentials: BearerAuthCredentials.new( access_token: 'AccessToken' ), @@ -94,6 +94,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 00000000..a1839f08 --- /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` | [`Array`](../../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 00000000..4713d0c1 --- /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` | [`Array`](../../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 a8c7cb18..c6498460 100644 --- a/doc/models/event-data.md +++ b/doc/models/event-data.md @@ -9,10 +9,10 @@ | Name | Type | Tags | Description | | --- | --- | --- | --- | -| `type` | `String` | Optional | Name of the affected object’s type. | -| `id` | `String` | Optional | ID of the affected object. | -| `deleted` | `TrueClass \| FalseClass` | Optional | Is true if the affected object was deleted. Otherwise absent. | -| `object` | `Hash` | Optional | An object containing fields and values relevant to the event. Is absent if affected object was deleted. | +| `type` | `String` | Optional | The name of the affected object’s type. | +| `id` | `String` | Optional | The ID of the affected object. | +| `deleted` | `TrueClass \| FalseClass` | Optional | This is true if the affected object has been deleted; otherwise, it's absent. | +| `object` | `Hash` | 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 00000000..9055b9a6 --- /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` | `String` | Optional | A unique ID for the event. | +| `api_version` | `String` | 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 f270f141..8642ab9a 100644 --- a/doc/models/event.md +++ b/doc/models/event.md @@ -10,7 +10,7 @@ | Name | Type | Tags | Description | | --- | --- | --- | --- | | `merchant_id` | `String` | Optional | The ID of the target merchant associated with the event. | -| `location_id` | `String` | Optional | The ID of the location associated with the event. | +| `location_id` | `String` | Optional | The ID of the target location associated with the event. | | `type` | `String` | Optional | The type of event this represents. | | `event_id` | `String` | Optional | A unique ID for the event. | | `created_at` | `String` | 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 00000000..da615000 --- /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` | `String` | 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 00000000..4a43841e --- /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` | [`Array`](../../doc/models/error.md) | Optional | Information on errors encountered during the request. | +| `event_types` | `Array` | Optional | The list of event types. | +| `metadata` | [`Array`](../../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 0710b506..99c01fbb 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` | `Integer` | Optional | The whole or fractional quantity as the numerator. | -| `quantity_denominator` | `Integer` | 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` | `Integer` | 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 00000000..5af626c1 --- /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` | `Array` | Optional | Filter events by event types. | +| `merchant_ids` | `Array` | Optional | Filter events by merchant. | +| `location_ids` | `Array` | Optional | Filter events by location. | +| `created_at` | [`Time Range Hash`](../../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 00000000..4d5f7b2f --- /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 Hash`](../../doc/models/search-events-filter.md) | Optional | Criteria to filter events by. | +| `sort` | [`Search Events Sort Hash`](../../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 00000000..5f9cb1dc --- /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` | `String` | 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` | `Integer` | 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 Hash`](../../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 00000000..9d9b8715 --- /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` | [`Array`](../../doc/models/error.md) | Optional | Information on errors encountered during the request. | +| `events` | [`Array`](../../doc/models/event.md) | Optional | The list of [Event](entity:Event)s returned by the search. | +| `metadata` | [`Array`](../../doc/models/event-metadata.md) | Optional | Contains the metadata of an event. For more information, see [Event](entity:Event). | +| `cursor` | `String` | 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 00000000..01df1825 --- /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 00000000..40b43791 --- /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` | [`String (Search Events Sort Field)`](../../doc/models/search-events-sort-field.md) | Optional | Specifies the sort key for events returned from a search. | +| `order` | [`String (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/lib/square.rb b/lib/square.rb index 4ad809e7..73352f3c 100644 --- a/lib/square.rb +++ b/lib/square.rb @@ -48,6 +48,7 @@ require_relative 'square/api/devices_api' require_relative 'square/api/disputes_api' require_relative 'square/api/employees_api' +require_relative 'square/api/events_api' require_relative 'square/api/gift_cards_api' require_relative 'square/api/gift_card_activities_api' require_relative 'square/api/inventory_api' diff --git a/lib/square/api/base_api.rb b/lib/square/api/base_api.rb index b2bc283a..1620f8c7 100644 --- a/lib/square/api/base_api.rb +++ b/lib/square/api/base_api.rb @@ -5,7 +5,7 @@ class BaseApi attr_accessor :config, :http_call_back def self.user_agent - 'Square-Ruby-SDK/38.0.0.20240515 ({api-version}) {engine}/{engine-version} ({os-info}) {detail}' + 'Square-Ruby-SDK/38.1.0.20240604 ({api-version}) {engine}/{engine-version} ({os-info}) {detail}' end def self.user_agent_parameters diff --git a/lib/square/api/events_api.rb b/lib/square/api/events_api.rb new file mode 100644 index 00000000..341ebbb3 --- /dev/null +++ b/lib/square/api/events_api.rb @@ -0,0 +1,84 @@ +module Square + # EventsApi + class EventsApi < BaseApi + # Search for Square API events that occur within a 28-day timeframe. + # @param [SearchEventsRequest] body Required parameter: An object containing + # the fields to POST for the request. See the corresponding object + # definition for field details. + # @return [SearchEventsResponse Hash] response from the API call + def search_events(body:) + new_api_call_builder + .request(new_request_builder(HttpMethodEnum::POST, + '/v2/events', + 'default') + .header_param(new_parameter('application/json', key: 'Content-Type')) + .body_param(new_parameter(body)) + .header_param(new_parameter('application/json', key: 'accept')) + .body_serializer(proc do |param| param.to_json unless param.nil? end) + .auth(Single.new('global'))) + .response(new_response_handler + .deserializer(APIHelper.method(:json_deserialize)) + .is_api_response(true) + .convertor(ApiResponse.method(:create))) + .execute + end + + # 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. + # @return [DisableEventsResponse Hash] response from the API call + def disable_events + new_api_call_builder + .request(new_request_builder(HttpMethodEnum::PUT, + '/v2/events/disable', + 'default') + .header_param(new_parameter('application/json', key: 'accept')) + .auth(Single.new('global'))) + .response(new_response_handler + .deserializer(APIHelper.method(:json_deserialize)) + .is_api_response(true) + .convertor(ApiResponse.method(:create))) + .execute + end + + # Enables events to make them searchable. Only events that occur while in + # the enabled state are searchable. + # @return [EnableEventsResponse Hash] response from the API call + def enable_events + new_api_call_builder + .request(new_request_builder(HttpMethodEnum::PUT, + '/v2/events/enable', + 'default') + .header_param(new_parameter('application/json', key: 'accept')) + .auth(Single.new('global'))) + .response(new_response_handler + .deserializer(APIHelper.method(:json_deserialize)) + .is_api_response(true) + .convertor(ApiResponse.method(:create))) + .execute + end + + # Lists all event types that you can subscribe to as webhooks or query using + # the Events API. + # @param [String] api_version Optional parameter: The API version for which + # to list event types. Setting this field overrides the default version used + # by the application. + # @return [ListEventTypesResponse Hash] response from the API call + def list_event_types(api_version: nil) + new_api_call_builder + .request(new_request_builder(HttpMethodEnum::GET, + '/v2/events/types', + 'default') + .query_param(new_parameter(api_version, key: 'api_version')) + .header_param(new_parameter('application/json', key: 'accept')) + .auth(Single.new('global'))) + .response(new_response_handler + .deserializer(APIHelper.method(:json_deserialize)) + .is_api_response(true) + .convertor(ApiResponse.method(:create))) + .execute + end + end +end diff --git a/lib/square/client.rb b/lib/square/client.rb index d1fe8936..9f87c793 100644 --- a/lib/square/client.rb +++ b/lib/square/client.rb @@ -5,7 +5,7 @@ class Client attr_reader :config, :auth_managers def sdk_version - '38.0.0.20240515' + '38.1.0.20240604' end def square_version @@ -118,6 +118,12 @@ def employees @employees ||= EmployeesApi.new @global_configuration end + # Access to events controller. + # @return [EventsApi] Returns the controller instance. + def events + @events ||= EventsApi.new @global_configuration + end + # Access to gift_cards controller. # @return [GiftCardsApi] Returns the controller instance. def gift_cards @@ -268,7 +274,7 @@ def initialize( retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524], retry_methods: %i[get put], http_callback: nil, environment: 'production', custom_url: 'https://connect.squareup.com', access_token: nil, - bearer_auth_credentials: nil, square_version: '2024-05-15', + bearer_auth_credentials: nil, square_version: '2024-06-04', user_agent_detail: '', additional_headers: {}, config: nil ) @config = if config.nil? diff --git a/lib/square/configuration.rb b/lib/square/configuration.rb index df770640..79296beb 100644 --- a/lib/square/configuration.rb +++ b/lib/square/configuration.rb @@ -7,8 +7,8 @@ def access_token end # The attribute readers for properties. - attr_reader :environment, :custom_url, :bearer_auth_credentials, :square_version, - :user_agent_detail + attr_reader :environment, :custom_url, :bearer_auth_credentials, + :square_version, :user_agent_detail def additional_headers @additional_headers.clone @@ -24,7 +24,7 @@ def initialize( retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524], retry_methods: %i[get put], http_callback: nil, environment: 'production', custom_url: 'https://connect.squareup.com', access_token: nil, - bearer_auth_credentials: nil, square_version: '2024-05-15', + bearer_auth_credentials: nil, square_version: '2024-06-04', user_agent_detail: '', additional_headers: {} ) diff --git a/square.gemspec b/square.gemspec index 518d1b66..5140f8ec 100644 --- a/square.gemspec +++ b/square.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |s| s.name = 'square.rb' - s.version = '38.0.0.20240515' + s.version = '38.1.0.20240604' s.summary = 'square' s.description = '' s.authors = ['Square Developer Platform']