square.rb 5.1.0.20200325 → 5.2.0.20200422

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 138fb32372ec1f9f3d7fad1888d2cd713e65f177fe4efbf0e22927ef22840c08
4
- data.tar.gz: 1a801b869c9216881f41ae33c70867f0918c3cd11c63e23d29449593b20da41a
3
+ metadata.gz: 8f25be21c125d2034bf9d8ba530dce3255ebe7d6abb9d3d2ae8f623c3d103e6f
4
+ data.tar.gz: 70146041c8c1779a1a9c20de825004830db2dc8f08b4dad40baf207d7962bec5
5
5
  SHA512:
6
- metadata.gz: 2a20b19c6ded28b7263ebe2410891f7673fcaa2d1a07f1b06cdb2fecca07e3c7246c19df7e6f6c5e22209df84ad33555ce867dc3044f1cb0958330e2e6a619c1
7
- data.tar.gz: 7f340885a07aba8355b416b6ceca057ee9115ca2fcfade634c5ccee74be5c92faf1c03980dba6bf3284bce08ed31fcba5e9bcf960c41cb2e1f2d3efdcdd1cb8f
6
+ metadata.gz: fd597786c9a36e84faa3abd2aebc872fb139590f0b497a73619a96056936d582a317a48013dfa4b6ec0f61f373b30ec3341896a6e8a525ff8c6822435ae4042b
7
+ data.tar.gz: d4aebec4b15d78102afa75ac589daa53a8cffaef3b25848d8abe6691cfff93f75b549b1fe6d5a4603ba97d8bb7d3fab948b98af22e186d55e8506ef5dce4e027
@@ -8,8 +8,8 @@ module Square
8
8
  @http_call_back = http_call_back
9
9
 
10
10
  @global_headers = {
11
- 'user-agent' => 'Square-Ruby-SDK/5.1.0.20200325',
12
- 'Square-Version' => '2020-03-25'
11
+ 'user-agent' => 'Square-Ruby-SDK/5.2.0.20200422',
12
+ 'Square-Version' => '2020-04-22'
13
13
  }
14
14
  end
15
15
 
@@ -0,0 +1,182 @@
1
+ module Square
2
+ # CustomerGroupsApi
3
+ class CustomerGroupsApi < BaseApi
4
+ def initialize(config, http_call_back: nil)
5
+ super(config, http_call_back: http_call_back)
6
+ end
7
+
8
+ # Retrieves the list of customer groups of a business.
9
+ # @param [String] cursor Optional parameter: A pagination cursor returned by
10
+ # a previous call to this endpoint. Provide this to retrieve the next set of
11
+ # results for your original query. See the [Pagination
12
+ # guide](https://developer.squareup.com/docs/working-with-apis/pagination)
13
+ # for more information.
14
+ # @return [ListCustomerGroupsResponse Hash] response from the API call
15
+ def list_customer_groups(cursor: nil)
16
+ # Prepare query url.
17
+ _query_builder = config.get_base_uri
18
+ _query_builder << '/v2/customers/groups'
19
+ _query_builder = APIHelper.append_url_with_query_parameters(
20
+ _query_builder,
21
+ 'cursor' => cursor
22
+ )
23
+ _query_url = APIHelper.clean_url _query_builder
24
+
25
+ # Prepare headers.
26
+ _headers = {
27
+ 'accept' => 'application/json'
28
+ }
29
+
30
+ # Prepare and execute HttpRequest.
31
+ _request = config.http_client.get(
32
+ _query_url,
33
+ headers: _headers
34
+ )
35
+ OAuth2.apply(config, _request)
36
+ _response = execute_request(_request)
37
+
38
+ # Return appropriate response type.
39
+ decoded = APIHelper.json_deserialize(_response.raw_body)
40
+ _errors = APIHelper.map_response(decoded, ['errors'])
41
+ ApiResponse.new(_response, data: decoded, errors: _errors)
42
+ end
43
+
44
+ # Creates a new customer group for a business.
45
+ # The request must include at least the `name` value of the group.
46
+ # @param [CreateCustomerGroupRequest] body Required parameter: An object
47
+ # containing the fields to POST for the request. See the corresponding
48
+ # object definition for field details.
49
+ # @return [CreateCustomerGroupResponse Hash] response from the API call
50
+ def create_customer_group(body:)
51
+ # Prepare query url.
52
+ _query_builder = config.get_base_uri
53
+ _query_builder << '/v2/customers/groups'
54
+ _query_url = APIHelper.clean_url _query_builder
55
+
56
+ # Prepare headers.
57
+ _headers = {
58
+ 'accept' => 'application/json',
59
+ 'content-type' => 'application/json; charset=utf-8'
60
+ }
61
+
62
+ # Prepare and execute HttpRequest.
63
+ _request = config.http_client.post(
64
+ _query_url,
65
+ headers: _headers,
66
+ parameters: body.to_json
67
+ )
68
+ OAuth2.apply(config, _request)
69
+ _response = execute_request(_request)
70
+
71
+ # Return appropriate response type.
72
+ decoded = APIHelper.json_deserialize(_response.raw_body)
73
+ _errors = APIHelper.map_response(decoded, ['errors'])
74
+ ApiResponse.new(_response, data: decoded, errors: _errors)
75
+ end
76
+
77
+ # Deletes a customer group as identified by the `group_id` value.
78
+ # @param [String] group_id Required parameter: The ID of the customer group
79
+ # to delete.
80
+ # @return [DeleteCustomerGroupResponse Hash] response from the API call
81
+ def delete_customer_group(group_id:)
82
+ # Prepare query url.
83
+ _query_builder = config.get_base_uri
84
+ _query_builder << '/v2/customers/groups/{group_id}'
85
+ _query_builder = APIHelper.append_url_with_template_parameters(
86
+ _query_builder,
87
+ 'group_id' => group_id
88
+ )
89
+ _query_url = APIHelper.clean_url _query_builder
90
+
91
+ # Prepare headers.
92
+ _headers = {
93
+ 'accept' => 'application/json'
94
+ }
95
+
96
+ # Prepare and execute HttpRequest.
97
+ _request = config.http_client.delete(
98
+ _query_url,
99
+ headers: _headers
100
+ )
101
+ OAuth2.apply(config, _request)
102
+ _response = execute_request(_request)
103
+
104
+ # Return appropriate response type.
105
+ decoded = APIHelper.json_deserialize(_response.raw_body)
106
+ _errors = APIHelper.map_response(decoded, ['errors'])
107
+ ApiResponse.new(_response, data: decoded, errors: _errors)
108
+ end
109
+
110
+ # Retrieves a specific customer group as identified by the `group_id` value.
111
+ # @param [String] group_id Required parameter: The ID of the customer group
112
+ # to retrieve.
113
+ # @return [RetrieveCustomerGroupResponse Hash] response from the API call
114
+ def retrieve_customer_group(group_id:)
115
+ # Prepare query url.
116
+ _query_builder = config.get_base_uri
117
+ _query_builder << '/v2/customers/groups/{group_id}'
118
+ _query_builder = APIHelper.append_url_with_template_parameters(
119
+ _query_builder,
120
+ 'group_id' => group_id
121
+ )
122
+ _query_url = APIHelper.clean_url _query_builder
123
+
124
+ # Prepare headers.
125
+ _headers = {
126
+ 'accept' => 'application/json'
127
+ }
128
+
129
+ # Prepare and execute HttpRequest.
130
+ _request = config.http_client.get(
131
+ _query_url,
132
+ headers: _headers
133
+ )
134
+ OAuth2.apply(config, _request)
135
+ _response = execute_request(_request)
136
+
137
+ # Return appropriate response type.
138
+ decoded = APIHelper.json_deserialize(_response.raw_body)
139
+ _errors = APIHelper.map_response(decoded, ['errors'])
140
+ ApiResponse.new(_response, data: decoded, errors: _errors)
141
+ end
142
+
143
+ # Updates a customer group as identified by the `group_id` value.
144
+ # @param [String] group_id Required parameter: The ID of the customer group
145
+ # to update.
146
+ # @param [UpdateCustomerGroupRequest] body Required parameter: An object
147
+ # containing the fields to POST for the request. See the corresponding
148
+ # object definition for field details.
149
+ # @return [UpdateCustomerGroupResponse Hash] response from the API call
150
+ def update_customer_group(group_id:,
151
+ body:)
152
+ # Prepare query url.
153
+ _query_builder = config.get_base_uri
154
+ _query_builder << '/v2/customers/groups/{group_id}'
155
+ _query_builder = APIHelper.append_url_with_template_parameters(
156
+ _query_builder,
157
+ 'group_id' => group_id
158
+ )
159
+ _query_url = APIHelper.clean_url _query_builder
160
+
161
+ # Prepare headers.
162
+ _headers = {
163
+ 'accept' => 'application/json',
164
+ 'content-type' => 'application/json; charset=utf-8'
165
+ }
166
+
167
+ # Prepare and execute HttpRequest.
168
+ _request = config.http_client.put(
169
+ _query_url,
170
+ headers: _headers,
171
+ parameters: body.to_json
172
+ )
173
+ OAuth2.apply(config, _request)
174
+ _response = execute_request(_request)
175
+
176
+ # Return appropriate response type.
177
+ decoded = APIHelper.json_deserialize(_response.raw_body)
178
+ _errors = APIHelper.map_response(decoded, ['errors'])
179
+ ApiResponse.new(_response, data: decoded, errors: _errors)
180
+ end
181
+ end
182
+ end
@@ -0,0 +1,83 @@
1
+ module Square
2
+ # CustomerSegmentsApi
3
+ class CustomerSegmentsApi < BaseApi
4
+ def initialize(config, http_call_back: nil)
5
+ super(config, http_call_back: http_call_back)
6
+ end
7
+
8
+ # Retrieves the list of customer segments of a business.
9
+ # @param [String] cursor Optional parameter: A pagination cursor returned by
10
+ # previous calls to __ListCustomerSegments__. Used to retrieve the next set
11
+ # of query results. See the [Pagination
12
+ # guide](https://developer.squareup.com/docs/docs/working-with-apis/paginati
13
+ # on) for more information.
14
+ # @param [Long] limit Optional parameter: Sets the maximum number of results
15
+ # to be returned in a single page. Limit values outside the supported range
16
+ # are ignored. Minimum value: `1` Maximum value: `1,000`
17
+ # @return [ListCustomerSegmentsResponse Hash] response from the API call
18
+ def list_customer_segments(cursor: nil,
19
+ limit: nil)
20
+ # Prepare query url.
21
+ _query_builder = config.get_base_uri
22
+ _query_builder << '/v2/customers/segments'
23
+ _query_builder = APIHelper.append_url_with_query_parameters(
24
+ _query_builder,
25
+ 'cursor' => cursor,
26
+ 'limit' => limit
27
+ )
28
+ _query_url = APIHelper.clean_url _query_builder
29
+
30
+ # Prepare headers.
31
+ _headers = {
32
+ 'accept' => 'application/json'
33
+ }
34
+
35
+ # Prepare and execute HttpRequest.
36
+ _request = config.http_client.get(
37
+ _query_url,
38
+ headers: _headers
39
+ )
40
+ OAuth2.apply(config, _request)
41
+ _response = execute_request(_request)
42
+
43
+ # Return appropriate response type.
44
+ decoded = APIHelper.json_deserialize(_response.raw_body)
45
+ _errors = APIHelper.map_response(decoded, ['errors'])
46
+ ApiResponse.new(_response, data: decoded, errors: _errors)
47
+ end
48
+
49
+ # Retrieves a specific customer segment as identified by the `segment_id`
50
+ # value.
51
+ # @param [String] segment_id Required parameter: The Square-issued ID of the
52
+ # customer segment.
53
+ # @return [RetrieveCustomerSegmentResponse Hash] response from the API call
54
+ def retrieve_customer_segment(segment_id:)
55
+ # Prepare query url.
56
+ _query_builder = config.get_base_uri
57
+ _query_builder << '/v2/customers/segments/{segment_id}'
58
+ _query_builder = APIHelper.append_url_with_template_parameters(
59
+ _query_builder,
60
+ 'segment_id' => segment_id
61
+ )
62
+ _query_url = APIHelper.clean_url _query_builder
63
+
64
+ # Prepare headers.
65
+ _headers = {
66
+ 'accept' => 'application/json'
67
+ }
68
+
69
+ # Prepare and execute HttpRequest.
70
+ _request = config.http_client.get(
71
+ _query_url,
72
+ headers: _headers
73
+ )
74
+ OAuth2.apply(config, _request)
75
+ _response = execute_request(_request)
76
+
77
+ # Return appropriate response type.
78
+ decoded = APIHelper.json_deserialize(_response.raw_body)
79
+ _errors = APIHelper.map_response(decoded, ['errors'])
80
+ ApiResponse.new(_response, data: decoded, errors: _errors)
81
+ end
82
+ end
83
+ end
@@ -323,5 +323,83 @@ module Square
323
323
  _errors = APIHelper.map_response(decoded, ['errors'])
324
324
  ApiResponse.new(_response, data: decoded, errors: _errors)
325
325
  end
326
+
327
+ # Removes a customer membership from a customer group.
328
+ # The customer is identified by the `customer_id` value
329
+ # and the customer group is identified by the `group_id` value.
330
+ # @param [String] customer_id Required parameter: The ID of the customer to
331
+ # remove from the group.
332
+ # @param [String] group_id Required parameter: The ID of the customer group
333
+ # to remove the customer from.
334
+ # @return [RemoveGroupFromCustomerResponse Hash] response from the API call
335
+ def remove_group_from_customer(customer_id:,
336
+ group_id:)
337
+ # Prepare query url.
338
+ _query_builder = config.get_base_uri
339
+ _query_builder << '/v2/customers/{customer_id}/groups/{group_id}'
340
+ _query_builder = APIHelper.append_url_with_template_parameters(
341
+ _query_builder,
342
+ 'customer_id' => customer_id,
343
+ 'group_id' => group_id
344
+ )
345
+ _query_url = APIHelper.clean_url _query_builder
346
+
347
+ # Prepare headers.
348
+ _headers = {
349
+ 'accept' => 'application/json'
350
+ }
351
+
352
+ # Prepare and execute HttpRequest.
353
+ _request = config.http_client.delete(
354
+ _query_url,
355
+ headers: _headers
356
+ )
357
+ OAuth2.apply(config, _request)
358
+ _response = execute_request(_request)
359
+
360
+ # Return appropriate response type.
361
+ decoded = APIHelper.json_deserialize(_response.raw_body)
362
+ _errors = APIHelper.map_response(decoded, ['errors'])
363
+ ApiResponse.new(_response, data: decoded, errors: _errors)
364
+ end
365
+
366
+ # Adds a customer membership to a customer group.
367
+ # The customer is identified by the `customer_id` value
368
+ # and the customer group is identified by the `group_id` value.
369
+ # @param [String] customer_id Required parameter: The ID of the customer to
370
+ # add to a group.
371
+ # @param [String] group_id Required parameter: The ID of the customer group
372
+ # to add the customer to.
373
+ # @return [AddGroupToCustomerResponse Hash] response from the API call
374
+ def add_group_to_customer(customer_id:,
375
+ group_id:)
376
+ # Prepare query url.
377
+ _query_builder = config.get_base_uri
378
+ _query_builder << '/v2/customers/{customer_id}/groups/{group_id}'
379
+ _query_builder = APIHelper.append_url_with_template_parameters(
380
+ _query_builder,
381
+ 'customer_id' => customer_id,
382
+ 'group_id' => group_id
383
+ )
384
+ _query_url = APIHelper.clean_url _query_builder
385
+
386
+ # Prepare headers.
387
+ _headers = {
388
+ 'accept' => 'application/json'
389
+ }
390
+
391
+ # Prepare and execute HttpRequest.
392
+ _request = config.http_client.put(
393
+ _query_url,
394
+ headers: _headers
395
+ )
396
+ OAuth2.apply(config, _request)
397
+ _response = execute_request(_request)
398
+
399
+ # Return appropriate response type.
400
+ decoded = APIHelper.json_deserialize(_response.raw_body)
401
+ _errors = APIHelper.map_response(decoded, ['errors'])
402
+ ApiResponse.new(_response, data: decoded, errors: _errors)
403
+ end
326
404
  end
327
405
  end
@@ -0,0 +1,120 @@
1
+ module Square
2
+ # DevicesApi
3
+ class DevicesApi < BaseApi
4
+ def initialize(config, http_call_back: nil)
5
+ super(config, http_call_back: http_call_back)
6
+ end
7
+
8
+ # Lists all DeviceCodes associated with the merchant.
9
+ # @param [String] cursor Optional parameter: A pagination cursor returned by
10
+ # a previous call to this endpoint. Provide this to retrieve the next set of
11
+ # results for your original query. See [Paginating
12
+ # results](#paginatingresults) for more information.
13
+ # @param [String] location_id Optional parameter: If specified, only returns
14
+ # DeviceCodes of the specified location. Returns DeviceCodes of all
15
+ # locations if empty.
16
+ # @param [ProductType] product_type Optional parameter: If specified, only
17
+ # returns DeviceCodes targeting the specified product type. Returns
18
+ # DeviceCodes of all product types if empty.
19
+ # @return [ListDeviceCodesResponse Hash] response from the API call
20
+ def list_device_codes(cursor: nil,
21
+ location_id: nil,
22
+ product_type: nil)
23
+ # Prepare query url.
24
+ _query_builder = config.get_base_uri
25
+ _query_builder << '/v2/devices/codes'
26
+ _query_builder = APIHelper.append_url_with_query_parameters(
27
+ _query_builder,
28
+ 'cursor' => cursor,
29
+ 'location_id' => location_id,
30
+ 'product_type' => product_type
31
+ )
32
+ _query_url = APIHelper.clean_url _query_builder
33
+
34
+ # Prepare headers.
35
+ _headers = {
36
+ 'accept' => 'application/json'
37
+ }
38
+
39
+ # Prepare and execute HttpRequest.
40
+ _request = config.http_client.get(
41
+ _query_url,
42
+ headers: _headers
43
+ )
44
+ OAuth2.apply(config, _request)
45
+ _response = execute_request(_request)
46
+
47
+ # Return appropriate response type.
48
+ decoded = APIHelper.json_deserialize(_response.raw_body)
49
+ _errors = APIHelper.map_response(decoded, ['errors'])
50
+ ApiResponse.new(_response, data: decoded, errors: _errors)
51
+ end
52
+
53
+ # Creates a DeviceCode that can be used to login to a Square Terminal device
54
+ # to enter the connected
55
+ # terminal mode.
56
+ # @param [CreateDeviceCodeRequest] body Required parameter: An object
57
+ # containing the fields to POST for the request. See the corresponding
58
+ # object definition for field details.
59
+ # @return [CreateDeviceCodeResponse Hash] response from the API call
60
+ def create_device_code(body:)
61
+ # Prepare query url.
62
+ _query_builder = config.get_base_uri
63
+ _query_builder << '/v2/devices/codes'
64
+ _query_url = APIHelper.clean_url _query_builder
65
+
66
+ # Prepare headers.
67
+ _headers = {
68
+ 'accept' => 'application/json',
69
+ 'content-type' => 'application/json; charset=utf-8'
70
+ }
71
+
72
+ # Prepare and execute HttpRequest.
73
+ _request = config.http_client.post(
74
+ _query_url,
75
+ headers: _headers,
76
+ parameters: body.to_json
77
+ )
78
+ OAuth2.apply(config, _request)
79
+ _response = execute_request(_request)
80
+
81
+ # Return appropriate response type.
82
+ decoded = APIHelper.json_deserialize(_response.raw_body)
83
+ _errors = APIHelper.map_response(decoded, ['errors'])
84
+ ApiResponse.new(_response, data: decoded, errors: _errors)
85
+ end
86
+
87
+ # Retrieves DeviceCode with the associated ID.
88
+ # @param [String] id Required parameter: The unique identifier for the
89
+ # device code.
90
+ # @return [GetDeviceCodeResponse Hash] response from the API call
91
+ def get_device_code(id:)
92
+ # Prepare query url.
93
+ _query_builder = config.get_base_uri
94
+ _query_builder << '/v2/devices/codes/{id}'
95
+ _query_builder = APIHelper.append_url_with_template_parameters(
96
+ _query_builder,
97
+ 'id' => id
98
+ )
99
+ _query_url = APIHelper.clean_url _query_builder
100
+
101
+ # Prepare headers.
102
+ _headers = {
103
+ 'accept' => 'application/json'
104
+ }
105
+
106
+ # Prepare and execute HttpRequest.
107
+ _request = config.http_client.get(
108
+ _query_url,
109
+ headers: _headers
110
+ )
111
+ OAuth2.apply(config, _request)
112
+ _response = execute_request(_request)
113
+
114
+ # Return appropriate response type.
115
+ decoded = APIHelper.json_deserialize(_response.raw_body)
116
+ _errors = APIHelper.map_response(decoded, ['errors'])
117
+ ApiResponse.new(_response, data: decoded, errors: _errors)
118
+ end
119
+ end
120
+ end
@@ -0,0 +1,141 @@
1
+ module Square
2
+ # TerminalApi
3
+ class TerminalApi < BaseApi
4
+ def initialize(config, http_call_back: nil)
5
+ super(config, http_call_back: http_call_back)
6
+ end
7
+
8
+ # Creates a new Terminal checkout request and sends it to the specified
9
+ # device to take a payment for the requested amount.
10
+ # @param [CreateTerminalCheckoutRequest] body Required parameter: An object
11
+ # containing the fields to POST for the request. See the corresponding
12
+ # object definition for field details.
13
+ # @return [CreateTerminalCheckoutResponse Hash] response from the API call
14
+ def create_terminal_checkout(body:)
15
+ # Prepare query url.
16
+ _query_builder = config.get_base_uri
17
+ _query_builder << '/v2/terminals/checkouts'
18
+ _query_url = APIHelper.clean_url _query_builder
19
+
20
+ # Prepare headers.
21
+ _headers = {
22
+ 'accept' => 'application/json',
23
+ 'content-type' => 'application/json; charset=utf-8'
24
+ }
25
+
26
+ # Prepare and execute HttpRequest.
27
+ _request = config.http_client.post(
28
+ _query_url,
29
+ headers: _headers,
30
+ parameters: body.to_json
31
+ )
32
+ OAuth2.apply(config, _request)
33
+ _response = execute_request(_request)
34
+
35
+ # Return appropriate response type.
36
+ decoded = APIHelper.json_deserialize(_response.raw_body)
37
+ _errors = APIHelper.map_response(decoded, ['errors'])
38
+ ApiResponse.new(_response, data: decoded, errors: _errors)
39
+ end
40
+
41
+ # Retrieves a filtered list of Terminal checkout requests created by the
42
+ # account making the request.
43
+ # @param [SearchTerminalCheckoutsRequest] body Required parameter: An object
44
+ # containing the fields to POST for the request. See the corresponding
45
+ # object definition for field details.
46
+ # @return [SearchTerminalCheckoutsResponse Hash] response from the API call
47
+ def search_terminal_checkouts(body:)
48
+ # Prepare query url.
49
+ _query_builder = config.get_base_uri
50
+ _query_builder << '/v2/terminals/checkouts/search'
51
+ _query_url = APIHelper.clean_url _query_builder
52
+
53
+ # Prepare headers.
54
+ _headers = {
55
+ 'accept' => 'application/json',
56
+ 'content-type' => 'application/json; charset=utf-8'
57
+ }
58
+
59
+ # Prepare and execute HttpRequest.
60
+ _request = config.http_client.post(
61
+ _query_url,
62
+ headers: _headers,
63
+ parameters: body.to_json
64
+ )
65
+ OAuth2.apply(config, _request)
66
+ _response = execute_request(_request)
67
+
68
+ # Return appropriate response type.
69
+ decoded = APIHelper.json_deserialize(_response.raw_body)
70
+ _errors = APIHelper.map_response(decoded, ['errors'])
71
+ ApiResponse.new(_response, data: decoded, errors: _errors)
72
+ end
73
+
74
+ # Retrieves a Terminal checkout request by checkout_id.
75
+ # @param [String] checkout_id Required parameter: Unique ID for the desired
76
+ # `TerminalCheckout`
77
+ # @return [GetTerminalCheckoutResponse Hash] response from the API call
78
+ def get_terminal_checkout(checkout_id:)
79
+ # Prepare query url.
80
+ _query_builder = config.get_base_uri
81
+ _query_builder << '/v2/terminals/checkouts/{checkout_id}'
82
+ _query_builder = APIHelper.append_url_with_template_parameters(
83
+ _query_builder,
84
+ 'checkout_id' => checkout_id
85
+ )
86
+ _query_url = APIHelper.clean_url _query_builder
87
+
88
+ # Prepare headers.
89
+ _headers = {
90
+ 'accept' => 'application/json'
91
+ }
92
+
93
+ # Prepare and execute HttpRequest.
94
+ _request = config.http_client.get(
95
+ _query_url,
96
+ headers: _headers
97
+ )
98
+ OAuth2.apply(config, _request)
99
+ _response = execute_request(_request)
100
+
101
+ # Return appropriate response type.
102
+ decoded = APIHelper.json_deserialize(_response.raw_body)
103
+ _errors = APIHelper.map_response(decoded, ['errors'])
104
+ ApiResponse.new(_response, data: decoded, errors: _errors)
105
+ end
106
+
107
+ # Cancels a Terminal checkout request, if the status of the request permits
108
+ # it.
109
+ # @param [String] checkout_id Required parameter: Unique ID for the desired
110
+ # `TerminalCheckout`
111
+ # @return [CancelTerminalCheckoutResponse Hash] response from the API call
112
+ def cancel_terminal_checkout(checkout_id:)
113
+ # Prepare query url.
114
+ _query_builder = config.get_base_uri
115
+ _query_builder << '/v2/terminals/checkouts/{checkout_id}/cancel'
116
+ _query_builder = APIHelper.append_url_with_template_parameters(
117
+ _query_builder,
118
+ 'checkout_id' => checkout_id
119
+ )
120
+ _query_url = APIHelper.clean_url _query_builder
121
+
122
+ # Prepare headers.
123
+ _headers = {
124
+ 'accept' => 'application/json'
125
+ }
126
+
127
+ # Prepare and execute HttpRequest.
128
+ _request = config.http_client.post(
129
+ _query_url,
130
+ headers: _headers
131
+ )
132
+ OAuth2.apply(config, _request)
133
+ _response = execute_request(_request)
134
+
135
+ # Return appropriate response type.
136
+ decoded = APIHelper.json_deserialize(_response.raw_body)
137
+ _errors = APIHelper.map_response(decoded, ['errors'])
138
+ ApiResponse.new(_response, data: decoded, errors: _errors)
139
+ end
140
+ end
141
+ end
data/lib/square/client.rb CHANGED
@@ -4,11 +4,11 @@ module Square
4
4
  attr_reader :config
5
5
 
6
6
  def sdk_version
7
- '5.1.0.20200325'
7
+ '5.2.0.20200422'
8
8
  end
9
9
 
10
10
  def square_version
11
- '2020-03-25'
11
+ '2020-04-22'
12
12
  end
13
13
 
14
14
  # Access to mobile_authorization controller.
@@ -77,6 +77,24 @@ module Square
77
77
  @customers ||= CustomersApi.new config
78
78
  end
79
79
 
80
+ # Access to customer_groups controller.
81
+ # @return [CustomerGroupsApi] Returns the controller instance.
82
+ def customer_groups
83
+ @customer_groups ||= CustomerGroupsApi.new config
84
+ end
85
+
86
+ # Access to customer_segments controller.
87
+ # @return [CustomerSegmentsApi] Returns the controller instance.
88
+ def customer_segments
89
+ @customer_segments ||= CustomerSegmentsApi.new config
90
+ end
91
+
92
+ # Access to devices controller.
93
+ # @return [DevicesApi] Returns the controller instance.
94
+ def devices
95
+ @devices ||= DevicesApi.new config
96
+ end
97
+
80
98
  # Access to disputes controller.
81
99
  # @return [DisputesApi] Returns the controller instance.
82
100
  def disputes
@@ -149,6 +167,12 @@ module Square
149
167
  @refunds ||= RefundsApi.new config
150
168
  end
151
169
 
170
+ # Access to terminal controller.
171
+ # @return [TerminalApi] Returns the controller instance.
172
+ def terminal
173
+ @terminal ||= TerminalApi.new config
174
+ end
175
+
152
176
  def initialize(timeout: 60, max_retries: 0, retry_interval: 1,
153
177
  backoff_factor: 1, environment: 'production',
154
178
  access_token: 'TODO: Replace', additional_headers: {},
data/lib/square.rb CHANGED
@@ -40,6 +40,9 @@ require_relative 'square/api/bank_accounts_api.rb'
40
40
  require_relative 'square/api/cash_drawers_api.rb'
41
41
  require_relative 'square/api/catalog_api.rb'
42
42
  require_relative 'square/api/customers_api.rb'
43
+ require_relative 'square/api/customer_groups_api.rb'
44
+ require_relative 'square/api/customer_segments_api.rb'
45
+ require_relative 'square/api/devices_api.rb'
43
46
  require_relative 'square/api/disputes_api.rb'
44
47
  require_relative 'square/api/employees_api.rb'
45
48
  require_relative 'square/api/inventory_api.rb'
@@ -52,3 +55,4 @@ require_relative 'square/api/transactions_api.rb'
52
55
  require_relative 'square/api/merchants_api.rb'
53
56
  require_relative 'square/api/payments_api.rb'
54
57
  require_relative 'square/api/refunds_api.rb'
58
+ require_relative 'square/api/terminal_api.rb'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: square.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.1.0.20200325
4
+ version: 5.2.0.20200422
5
5
  platform: ruby
6
6
  authors:
7
7
  - Square Developer Platform
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-25 00:00:00.000000000 Z
11
+ date: 2020-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logging
@@ -124,7 +124,10 @@ files:
124
124
  - lib/square/api/cash_drawers_api.rb
125
125
  - lib/square/api/catalog_api.rb
126
126
  - lib/square/api/checkout_api.rb
127
+ - lib/square/api/customer_groups_api.rb
128
+ - lib/square/api/customer_segments_api.rb
127
129
  - lib/square/api/customers_api.rb
130
+ - lib/square/api/devices_api.rb
128
131
  - lib/square/api/disputes_api.rb
129
132
  - lib/square/api/employees_api.rb
130
133
  - lib/square/api/inventory_api.rb
@@ -137,6 +140,7 @@ files:
137
140
  - lib/square/api/payments_api.rb
138
141
  - lib/square/api/refunds_api.rb
139
142
  - lib/square/api/reporting_api.rb
143
+ - lib/square/api/terminal_api.rb
140
144
  - lib/square/api/transactions_api.rb
141
145
  - lib/square/api/v1_employees_api.rb
142
146
  - lib/square/api/v1_items_api.rb