Class: Square::EventsApi

Inherits:
BaseApi show all
Defined in:
lib/square/api/events_api.rb

Overview

EventsApi

Instance Attribute Summary

Attributes inherited from BaseApi

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseApi

#initialize, #new_api_call_builder, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters

Constructor Details

This class inherits a constructor from Square::BaseApi

Instance Method Details

#disable_eventsDisableEventsResponse Hash

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:

  • (DisableEventsResponse Hash)

    response from the API call



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/square/api/events_api.rb', line 32

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

#enable_eventsEnableEventsResponse Hash

Enables events to make them searchable. Only events that occur while in the enabled state are searchable.

Returns:

  • (EnableEventsResponse Hash)

    response from the API call



49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/square/api/events_api.rb', line 49

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

#list_event_types(api_version: nil) ⇒ ListEventTypesResponse Hash

Lists all event types that you can subscribe to as webhooks or query using the Events API. to list event types. Setting this field overrides the default version used by the application.

Parameters:

  • api_version (String) (defaults to: nil)

    Optional parameter: The API version for which

Returns:

  • (ListEventTypesResponse Hash)

    response from the API call



69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/square/api/events_api.rb', line 69

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

#search_events(body:) ⇒ SearchEventsResponse Hash

Search for Square API events that occur within a 28-day timeframe. the fields to POST for the request. See the corresponding object definition for field details.

Parameters:

  • body (SearchEventsRequest)

    Required parameter: An object containing

Returns:

  • (SearchEventsResponse Hash)

    response from the API call



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/square/api/events_api.rb', line 9

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