square.rb 18.0.0.20220216 → 20.0.0.20220512
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +41 -221
- data/lib/square/api/base_api.rb +1 -1
- data/lib/square/api/bookings_api.rb +9 -0
- data/lib/square/api/checkout_api.rb +202 -0
- data/lib/square/api/customer_custom_attributes_api.rb +540 -0
- data/lib/square/api/customer_groups_api.rb +7 -6
- data/lib/square/api/customer_segments_api.rb +7 -6
- data/lib/square/api/customers_api.rb +11 -8
- data/lib/square/api/gift_card_activities_api.rb +5 -6
- data/lib/square/api/gift_cards_api.rb +6 -6
- data/lib/square/api/locations_api.rb +3 -4
- data/lib/square/api/loyalty_api.rb +4 -3
- data/lib/square/api/orders_api.rb +2 -2
- data/lib/square/api/payouts_api.rb +173 -0
- data/lib/square/api/subscriptions_api.rb +0 -3
- data/lib/square/api/terminal_api.rb +157 -6
- data/lib/square/api/vendors_api.rb +257 -0
- data/lib/square/client.rb +20 -2
- data/lib/square/configuration.rb +1 -1
- data/lib/square/http/faraday_client.rb +15 -5
- data/lib/square/http/http_client.rb +31 -12
- data/lib/square/http/http_request.rb +6 -2
- data/lib/square.rb +3 -0
- metadata +53 -8
@@ -0,0 +1,540 @@
|
|
1
|
+
module Square
|
2
|
+
# CustomerCustomAttributesApi
|
3
|
+
class CustomerCustomAttributesApi < BaseApi
|
4
|
+
def initialize(config, http_call_back: nil)
|
5
|
+
super(config, http_call_back: http_call_back)
|
6
|
+
end
|
7
|
+
|
8
|
+
# Lists the customer-related custom attribute definitions that belong to a
|
9
|
+
# Square seller account.
|
10
|
+
# When all response pages are retrieved, the results include all custom
|
11
|
+
# attribute definitions
|
12
|
+
# that are visible to the requesting application, including those that are
|
13
|
+
# created by other
|
14
|
+
# applications and set to `VISIBILITY_READ_ONLY` or
|
15
|
+
# `VISIBILITY_READ_WRITE_VALUES`.
|
16
|
+
# @param [Integer] limit Optional parameter: The maximum number of results
|
17
|
+
# to return in a single paged response. This limit is advisory. The response
|
18
|
+
# might contain more or fewer results. The minimum value is 1 and the
|
19
|
+
# maximum value is 100. The default value is 20. For more information, see
|
20
|
+
# [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
|
21
|
+
# atterns/pagination).
|
22
|
+
# @param [String] cursor Optional parameter: The cursor returned in the
|
23
|
+
# paged response from the previous call to this endpoint. Provide this
|
24
|
+
# cursor to retrieve the next page of results for your original request. For
|
25
|
+
# more information, see
|
26
|
+
# [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
|
27
|
+
# atterns/pagination).
|
28
|
+
# @return [ListCustomerCustomAttributeDefinitionsResponse Hash] response from the API call
|
29
|
+
def list_customer_custom_attribute_definitions(limit: nil,
|
30
|
+
cursor: nil)
|
31
|
+
# Prepare query url.
|
32
|
+
_query_builder = config.get_base_uri
|
33
|
+
_query_builder << '/v2/customers/custom-attribute-definitions'
|
34
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
35
|
+
_query_builder,
|
36
|
+
'limit' => limit,
|
37
|
+
'cursor' => cursor
|
38
|
+
)
|
39
|
+
_query_url = APIHelper.clean_url _query_builder
|
40
|
+
|
41
|
+
# Prepare headers.
|
42
|
+
_headers = {
|
43
|
+
'accept' => 'application/json'
|
44
|
+
}
|
45
|
+
|
46
|
+
# Prepare and execute HttpRequest.
|
47
|
+
_request = config.http_client.get(
|
48
|
+
_query_url,
|
49
|
+
headers: _headers
|
50
|
+
)
|
51
|
+
OAuth2.apply(config, _request)
|
52
|
+
_response = execute_request(_request)
|
53
|
+
|
54
|
+
# Return appropriate response type.
|
55
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
56
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
57
|
+
ApiResponse.new(
|
58
|
+
_response, data: decoded, errors: _errors
|
59
|
+
)
|
60
|
+
end
|
61
|
+
|
62
|
+
# Creates a customer-related custom attribute definition for a Square seller
|
63
|
+
# account. Use this
|
64
|
+
# endpoint to define a custom attribute that can be associated with customer
|
65
|
+
# profiles.
|
66
|
+
# A custom attribute definition specifies the `key`, `visibility`, `schema`,
|
67
|
+
# and other properties
|
68
|
+
# for a custom attribute. After the definition is created, you can call
|
69
|
+
# [UpsertCustomerCustomAttribute]($e/CustomerCustomAttributes/UpsertCustomer
|
70
|
+
# CustomAttribute) or
|
71
|
+
# [BulkUpsertCustomerCustomAttributes]($e/CustomerCustomAttributes/BulkUpser
|
72
|
+
# tCustomerCustomAttributes)
|
73
|
+
# to set the custom attribute for customer profiles in the seller's Customer
|
74
|
+
# Directory.
|
75
|
+
# Sellers can view all custom attributes in exported customer data,
|
76
|
+
# including those set to
|
77
|
+
# `VISIBILITY_HIDDEN`.
|
78
|
+
# @param [CreateCustomerCustomAttributeDefinitionRequest] body Required
|
79
|
+
# parameter: An object containing the fields to POST for the request. See
|
80
|
+
# the corresponding object definition for field details.
|
81
|
+
# @return [CreateCustomerCustomAttributeDefinitionResponse Hash] response from the API call
|
82
|
+
def create_customer_custom_attribute_definition(body:)
|
83
|
+
# Prepare query url.
|
84
|
+
_query_builder = config.get_base_uri
|
85
|
+
_query_builder << '/v2/customers/custom-attribute-definitions'
|
86
|
+
_query_url = APIHelper.clean_url _query_builder
|
87
|
+
|
88
|
+
# Prepare headers.
|
89
|
+
_headers = {
|
90
|
+
'accept' => 'application/json',
|
91
|
+
'Content-Type' => 'application/json'
|
92
|
+
}
|
93
|
+
|
94
|
+
# Prepare and execute HttpRequest.
|
95
|
+
_request = config.http_client.post(
|
96
|
+
_query_url,
|
97
|
+
headers: _headers,
|
98
|
+
parameters: body.to_json
|
99
|
+
)
|
100
|
+
OAuth2.apply(config, _request)
|
101
|
+
_response = execute_request(_request)
|
102
|
+
|
103
|
+
# Return appropriate response type.
|
104
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
105
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
106
|
+
ApiResponse.new(
|
107
|
+
_response, data: decoded, errors: _errors
|
108
|
+
)
|
109
|
+
end
|
110
|
+
|
111
|
+
# Deletes a customer-related custom attribute definition from a Square
|
112
|
+
# seller account.
|
113
|
+
# Deleting a custom attribute definition also deletes the corresponding
|
114
|
+
# custom attribute from
|
115
|
+
# all customer profiles in the seller's Customer Directory.
|
116
|
+
# Only the definition owner can delete a custom attribute definition.
|
117
|
+
# @param [String] key Required parameter: The key of the custom attribute
|
118
|
+
# definition to delete.
|
119
|
+
# @return [DeleteCustomerCustomAttributeDefinitionResponse Hash] response from the API call
|
120
|
+
def delete_customer_custom_attribute_definition(key:)
|
121
|
+
# Prepare query url.
|
122
|
+
_query_builder = config.get_base_uri
|
123
|
+
_query_builder << '/v2/customers/custom-attribute-definitions/{key}'
|
124
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
125
|
+
_query_builder,
|
126
|
+
'key' => { 'value' => key, 'encode' => true }
|
127
|
+
)
|
128
|
+
_query_url = APIHelper.clean_url _query_builder
|
129
|
+
|
130
|
+
# Prepare headers.
|
131
|
+
_headers = {
|
132
|
+
'accept' => 'application/json'
|
133
|
+
}
|
134
|
+
|
135
|
+
# Prepare and execute HttpRequest.
|
136
|
+
_request = config.http_client.delete(
|
137
|
+
_query_url,
|
138
|
+
headers: _headers
|
139
|
+
)
|
140
|
+
OAuth2.apply(config, _request)
|
141
|
+
_response = execute_request(_request)
|
142
|
+
|
143
|
+
# Return appropriate response type.
|
144
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
145
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
146
|
+
ApiResponse.new(
|
147
|
+
_response, data: decoded, errors: _errors
|
148
|
+
)
|
149
|
+
end
|
150
|
+
|
151
|
+
# Retrieves a customer-related custom attribute definition from a Square
|
152
|
+
# seller account.
|
153
|
+
# To retrieve a custom attribute definition created by another application,
|
154
|
+
# the `visibility`
|
155
|
+
# setting must be `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`.
|
156
|
+
# @param [String] key Required parameter: The key of the custom attribute
|
157
|
+
# definition to retrieve. If the requesting application is not the
|
158
|
+
# definition owner, you must use the qualified key.
|
159
|
+
# @param [Integer] version Optional parameter: The current version of the
|
160
|
+
# custom attribute definition, which is used for strongly consistent reads
|
161
|
+
# to guarantee that you receive the most up-to-date data. When included in
|
162
|
+
# the request, Square returns the specified version or a higher version if
|
163
|
+
# one exists. If the specified version is higher than the current version,
|
164
|
+
# Square returns a `BAD_REQUEST` error.
|
165
|
+
# @return [RetrieveCustomerCustomAttributeDefinitionResponse Hash] response from the API call
|
166
|
+
def retrieve_customer_custom_attribute_definition(key:,
|
167
|
+
version: nil)
|
168
|
+
# Prepare query url.
|
169
|
+
_query_builder = config.get_base_uri
|
170
|
+
_query_builder << '/v2/customers/custom-attribute-definitions/{key}'
|
171
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
172
|
+
_query_builder,
|
173
|
+
'key' => { 'value' => key, 'encode' => true }
|
174
|
+
)
|
175
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
176
|
+
_query_builder,
|
177
|
+
'version' => version
|
178
|
+
)
|
179
|
+
_query_url = APIHelper.clean_url _query_builder
|
180
|
+
|
181
|
+
# Prepare headers.
|
182
|
+
_headers = {
|
183
|
+
'accept' => 'application/json'
|
184
|
+
}
|
185
|
+
|
186
|
+
# Prepare and execute HttpRequest.
|
187
|
+
_request = config.http_client.get(
|
188
|
+
_query_url,
|
189
|
+
headers: _headers
|
190
|
+
)
|
191
|
+
OAuth2.apply(config, _request)
|
192
|
+
_response = execute_request(_request)
|
193
|
+
|
194
|
+
# Return appropriate response type.
|
195
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
196
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
197
|
+
ApiResponse.new(
|
198
|
+
_response, data: decoded, errors: _errors
|
199
|
+
)
|
200
|
+
end
|
201
|
+
|
202
|
+
# Updates a customer-related custom attribute definition for a Square seller
|
203
|
+
# account.
|
204
|
+
# Use this endpoint to update the following fields: `name`, `description`,
|
205
|
+
# `visibility`, or the
|
206
|
+
# `schema` for a `Selection` data type.
|
207
|
+
# Only the definition owner can update a custom attribute definition. Note
|
208
|
+
# that sellers can view
|
209
|
+
# all custom attributes in exported customer data, including those set to
|
210
|
+
# `VISIBILITY_HIDDEN`.
|
211
|
+
# @param [String] key Required parameter: The key of the custom attribute
|
212
|
+
# definition to update.
|
213
|
+
# @param [UpdateCustomerCustomAttributeDefinitionRequest] body Required
|
214
|
+
# parameter: An object containing the fields to POST for the request. See
|
215
|
+
# the corresponding object definition for field details.
|
216
|
+
# @return [UpdateCustomerCustomAttributeDefinitionResponse Hash] response from the API call
|
217
|
+
def update_customer_custom_attribute_definition(key:,
|
218
|
+
body:)
|
219
|
+
# Prepare query url.
|
220
|
+
_query_builder = config.get_base_uri
|
221
|
+
_query_builder << '/v2/customers/custom-attribute-definitions/{key}'
|
222
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
223
|
+
_query_builder,
|
224
|
+
'key' => { 'value' => key, 'encode' => true }
|
225
|
+
)
|
226
|
+
_query_url = APIHelper.clean_url _query_builder
|
227
|
+
|
228
|
+
# Prepare headers.
|
229
|
+
_headers = {
|
230
|
+
'accept' => 'application/json',
|
231
|
+
'Content-Type' => 'application/json'
|
232
|
+
}
|
233
|
+
|
234
|
+
# Prepare and execute HttpRequest.
|
235
|
+
_request = config.http_client.put(
|
236
|
+
_query_url,
|
237
|
+
headers: _headers,
|
238
|
+
parameters: body.to_json
|
239
|
+
)
|
240
|
+
OAuth2.apply(config, _request)
|
241
|
+
_response = execute_request(_request)
|
242
|
+
|
243
|
+
# Return appropriate response type.
|
244
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
245
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
246
|
+
ApiResponse.new(
|
247
|
+
_response, data: decoded, errors: _errors
|
248
|
+
)
|
249
|
+
end
|
250
|
+
|
251
|
+
# Creates or updates custom attributes for customer profiles as a bulk
|
252
|
+
# operation.
|
253
|
+
# Use this endpoint to set the value of one or more custom attributes for
|
254
|
+
# one or more customer profiles.
|
255
|
+
# A custom attribute is based on a custom attribute definition in a Square
|
256
|
+
# seller account, which is
|
257
|
+
# created using the
|
258
|
+
# [CreateCustomerCustomAttributeDefinition]($e/CustomerCustomAttributes/Crea
|
259
|
+
# teCustomerCustomAttributeDefinition) endpoint.
|
260
|
+
# This `BulkUpsertCustomerCustomAttributes` endpoint accepts a map of 1 to
|
261
|
+
# 25 individual upsert
|
262
|
+
# requests and returns a map of individual upsert responses. Each upsert
|
263
|
+
# request has a unique ID
|
264
|
+
# and provides a customer ID and custom attribute. Each upsert response is
|
265
|
+
# returned with the ID
|
266
|
+
# of the corresponding request.
|
267
|
+
# To create or update a custom attribute owned by another application, the
|
268
|
+
# `visibility` setting
|
269
|
+
# must be `VISIBILITY_READ_WRITE_VALUES`.
|
270
|
+
# @param [BulkUpsertCustomerCustomAttributesRequest] body Required
|
271
|
+
# parameter: An object containing the fields to POST for the request. See
|
272
|
+
# the corresponding object definition for field details.
|
273
|
+
# @return [BulkUpsertCustomerCustomAttributesResponse Hash] response from the API call
|
274
|
+
def bulk_upsert_customer_custom_attributes(body:)
|
275
|
+
# Prepare query url.
|
276
|
+
_query_builder = config.get_base_uri
|
277
|
+
_query_builder << '/v2/customers/custom-attributes/bulk-upsert'
|
278
|
+
_query_url = APIHelper.clean_url _query_builder
|
279
|
+
|
280
|
+
# Prepare headers.
|
281
|
+
_headers = {
|
282
|
+
'accept' => 'application/json',
|
283
|
+
'Content-Type' => 'application/json'
|
284
|
+
}
|
285
|
+
|
286
|
+
# Prepare and execute HttpRequest.
|
287
|
+
_request = config.http_client.post(
|
288
|
+
_query_url,
|
289
|
+
headers: _headers,
|
290
|
+
parameters: body.to_json
|
291
|
+
)
|
292
|
+
OAuth2.apply(config, _request)
|
293
|
+
_response = execute_request(_request)
|
294
|
+
|
295
|
+
# Return appropriate response type.
|
296
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
297
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
298
|
+
ApiResponse.new(
|
299
|
+
_response, data: decoded, errors: _errors
|
300
|
+
)
|
301
|
+
end
|
302
|
+
|
303
|
+
# Lists the custom attributes associated with a customer profile.
|
304
|
+
# You can use the `with_definitions` query parameter to also retrieve custom
|
305
|
+
# attribute definitions
|
306
|
+
# in the same call.
|
307
|
+
# When all response pages are retrieved, the results include all custom
|
308
|
+
# attributes that are
|
309
|
+
# visible to the requesting application, including those that are owned by
|
310
|
+
# other applications
|
311
|
+
# and set to `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`.
|
312
|
+
# @param [String] customer_id Required parameter: The ID of the target
|
313
|
+
# [customer profile]($m/Customer).
|
314
|
+
# @param [Integer] limit Optional parameter: The maximum number of results
|
315
|
+
# to return in a single paged response. This limit is advisory. The response
|
316
|
+
# might contain more or fewer results. The minimum value is 1 and the
|
317
|
+
# maximum value is 100. The default value is 20. For more information, see
|
318
|
+
# [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
|
319
|
+
# atterns/pagination).
|
320
|
+
# @param [String] cursor Optional parameter: The cursor returned in the
|
321
|
+
# paged response from the previous call to this endpoint. Provide this
|
322
|
+
# cursor to retrieve the next page of results for your original request. For
|
323
|
+
# more information, see
|
324
|
+
# [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
|
325
|
+
# atterns/pagination).
|
326
|
+
# @param [Boolean] with_definitions Optional parameter: Indicates whether to
|
327
|
+
# return the [custom attribute definition]($m/CustomAttributeDefinition) in
|
328
|
+
# the `definition` field of each custom attribute. Set this parameter to
|
329
|
+
# `true` to get the name and description of each custom attribute,
|
330
|
+
# information about the data type, or other definition details. The default
|
331
|
+
# value is `false`.
|
332
|
+
# @return [ListCustomerCustomAttributesResponse Hash] response from the API call
|
333
|
+
def list_customer_custom_attributes(customer_id:,
|
334
|
+
limit: nil,
|
335
|
+
cursor: nil,
|
336
|
+
with_definitions: false)
|
337
|
+
# Prepare query url.
|
338
|
+
_query_builder = config.get_base_uri
|
339
|
+
_query_builder << '/v2/customers/{customer_id}/custom-attributes'
|
340
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
341
|
+
_query_builder,
|
342
|
+
'customer_id' => { 'value' => customer_id, 'encode' => true }
|
343
|
+
)
|
344
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
345
|
+
_query_builder,
|
346
|
+
'limit' => limit,
|
347
|
+
'cursor' => cursor,
|
348
|
+
'with_definitions' => with_definitions
|
349
|
+
)
|
350
|
+
_query_url = APIHelper.clean_url _query_builder
|
351
|
+
|
352
|
+
# Prepare headers.
|
353
|
+
_headers = {
|
354
|
+
'accept' => 'application/json'
|
355
|
+
}
|
356
|
+
|
357
|
+
# Prepare and execute HttpRequest.
|
358
|
+
_request = config.http_client.get(
|
359
|
+
_query_url,
|
360
|
+
headers: _headers
|
361
|
+
)
|
362
|
+
OAuth2.apply(config, _request)
|
363
|
+
_response = execute_request(_request)
|
364
|
+
|
365
|
+
# Return appropriate response type.
|
366
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
367
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
368
|
+
ApiResponse.new(
|
369
|
+
_response, data: decoded, errors: _errors
|
370
|
+
)
|
371
|
+
end
|
372
|
+
|
373
|
+
# Deletes a custom attribute associated with a customer profile.
|
374
|
+
# To delete a custom attribute owned by another application, the
|
375
|
+
# `visibility` setting must be
|
376
|
+
# `VISIBILITY_READ_WRITE_VALUES`.
|
377
|
+
# @param [String] customer_id Required parameter: The ID of the target
|
378
|
+
# [customer profile]($m/Customer).
|
379
|
+
# @param [String] key Required parameter: The key of the custom attribute to
|
380
|
+
# delete. This key must match the `key` of a custom attribute definition in
|
381
|
+
# the Square seller account. If the requesting application is not the
|
382
|
+
# definition owner, you must use the qualified key.
|
383
|
+
# @return [DeleteCustomerCustomAttributeResponse Hash] response from the API call
|
384
|
+
def delete_customer_custom_attribute(customer_id:,
|
385
|
+
key:)
|
386
|
+
# Prepare query url.
|
387
|
+
_query_builder = config.get_base_uri
|
388
|
+
_query_builder << '/v2/customers/{customer_id}/custom-attributes/{key}'
|
389
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
390
|
+
_query_builder,
|
391
|
+
'customer_id' => { 'value' => customer_id, 'encode' => true },
|
392
|
+
'key' => { 'value' => key, 'encode' => true }
|
393
|
+
)
|
394
|
+
_query_url = APIHelper.clean_url _query_builder
|
395
|
+
|
396
|
+
# Prepare headers.
|
397
|
+
_headers = {
|
398
|
+
'accept' => 'application/json'
|
399
|
+
}
|
400
|
+
|
401
|
+
# Prepare and execute HttpRequest.
|
402
|
+
_request = config.http_client.delete(
|
403
|
+
_query_url,
|
404
|
+
headers: _headers
|
405
|
+
)
|
406
|
+
OAuth2.apply(config, _request)
|
407
|
+
_response = execute_request(_request)
|
408
|
+
|
409
|
+
# Return appropriate response type.
|
410
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
411
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
412
|
+
ApiResponse.new(
|
413
|
+
_response, data: decoded, errors: _errors
|
414
|
+
)
|
415
|
+
end
|
416
|
+
|
417
|
+
# Retrieves a custom attribute associated with a customer profile.
|
418
|
+
# You can use the `with_definition` query parameter to also retrieve the
|
419
|
+
# custom attribute definition
|
420
|
+
# in the same call.
|
421
|
+
# To retrieve a custom attribute owned by another application, the
|
422
|
+
# `visibility` setting must be
|
423
|
+
# `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`.
|
424
|
+
# @param [String] customer_id Required parameter: The ID of the target
|
425
|
+
# [customer profile]($m/Customer).
|
426
|
+
# @param [String] key Required parameter: The key of the custom attribute to
|
427
|
+
# retrieve. This key must match the `key` of a custom attribute definition
|
428
|
+
# in the Square seller account. If the requesting application is not the
|
429
|
+
# definition owner, you must use the qualified key.
|
430
|
+
# @param [Boolean] with_definition Optional parameter: Indicates whether to
|
431
|
+
# return the [custom attribute definition]($m/CustomAttributeDefinition) in
|
432
|
+
# the `definition` field of the custom attribute. Set this parameter to
|
433
|
+
# `true` to get the name and description of the custom attribute,
|
434
|
+
# information about the data type, or other definition details. The default
|
435
|
+
# value is `false`.
|
436
|
+
# @param [Integer] version Optional parameter: The current version of the
|
437
|
+
# custom attribute, which is used for strongly consistent reads to guarantee
|
438
|
+
# that you receive the most up-to-date data. When included in the request,
|
439
|
+
# Square returns the specified version or a higher version if one exists. If
|
440
|
+
# the specified version is higher than the current version, Square returns a
|
441
|
+
# `BAD_REQUEST` error.
|
442
|
+
# @return [RetrieveCustomerCustomAttributeResponse Hash] response from the API call
|
443
|
+
def retrieve_customer_custom_attribute(customer_id:,
|
444
|
+
key:,
|
445
|
+
with_definition: false,
|
446
|
+
version: nil)
|
447
|
+
# Prepare query url.
|
448
|
+
_query_builder = config.get_base_uri
|
449
|
+
_query_builder << '/v2/customers/{customer_id}/custom-attributes/{key}'
|
450
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
451
|
+
_query_builder,
|
452
|
+
'customer_id' => { 'value' => customer_id, 'encode' => true },
|
453
|
+
'key' => { 'value' => key, 'encode' => true }
|
454
|
+
)
|
455
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
456
|
+
_query_builder,
|
457
|
+
'with_definition' => with_definition,
|
458
|
+
'version' => version
|
459
|
+
)
|
460
|
+
_query_url = APIHelper.clean_url _query_builder
|
461
|
+
|
462
|
+
# Prepare headers.
|
463
|
+
_headers = {
|
464
|
+
'accept' => 'application/json'
|
465
|
+
}
|
466
|
+
|
467
|
+
# Prepare and execute HttpRequest.
|
468
|
+
_request = config.http_client.get(
|
469
|
+
_query_url,
|
470
|
+
headers: _headers
|
471
|
+
)
|
472
|
+
OAuth2.apply(config, _request)
|
473
|
+
_response = execute_request(_request)
|
474
|
+
|
475
|
+
# Return appropriate response type.
|
476
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
477
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
478
|
+
ApiResponse.new(
|
479
|
+
_response, data: decoded, errors: _errors
|
480
|
+
)
|
481
|
+
end
|
482
|
+
|
483
|
+
# Creates or updates a custom attribute for a customer profile.
|
484
|
+
# Use this endpoint to set the value of a custom attribute for a specified
|
485
|
+
# customer profile.
|
486
|
+
# A custom attribute is based on a custom attribute definition in a Square
|
487
|
+
# seller account, which
|
488
|
+
# is created using the
|
489
|
+
# [CreateCustomerCustomAttributeDefinition]($e/CustomerCustomAttributes/Crea
|
490
|
+
# teCustomerCustomAttributeDefinition) endpoint.
|
491
|
+
# To create or update a custom attribute owned by another application, the
|
492
|
+
# `visibility` setting
|
493
|
+
# must be `VISIBILITY_READ_WRITE_VALUES`.
|
494
|
+
# @param [String] customer_id Required parameter: The ID of the target
|
495
|
+
# [customer profile]($m/Customer).
|
496
|
+
# @param [String] key Required parameter: The key of the custom attribute to
|
497
|
+
# create or update. This key must match the `key` of a custom attribute
|
498
|
+
# definition in the Square seller account. If the requesting application is
|
499
|
+
# not the definition owner, you must use the qualified key.
|
500
|
+
# @param [UpsertCustomerCustomAttributeRequest] body Required parameter: An
|
501
|
+
# object containing the fields to POST for the request. See the
|
502
|
+
# corresponding object definition for field details.
|
503
|
+
# @return [UpsertCustomerCustomAttributeResponse Hash] response from the API call
|
504
|
+
def upsert_customer_custom_attribute(customer_id:,
|
505
|
+
key:,
|
506
|
+
body:)
|
507
|
+
# Prepare query url.
|
508
|
+
_query_builder = config.get_base_uri
|
509
|
+
_query_builder << '/v2/customers/{customer_id}/custom-attributes/{key}'
|
510
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
511
|
+
_query_builder,
|
512
|
+
'customer_id' => { 'value' => customer_id, 'encode' => true },
|
513
|
+
'key' => { 'value' => key, 'encode' => true }
|
514
|
+
)
|
515
|
+
_query_url = APIHelper.clean_url _query_builder
|
516
|
+
|
517
|
+
# Prepare headers.
|
518
|
+
_headers = {
|
519
|
+
'accept' => 'application/json',
|
520
|
+
'Content-Type' => 'application/json'
|
521
|
+
}
|
522
|
+
|
523
|
+
# Prepare and execute HttpRequest.
|
524
|
+
_request = config.http_client.post(
|
525
|
+
_query_url,
|
526
|
+
headers: _headers,
|
527
|
+
parameters: body.to_json
|
528
|
+
)
|
529
|
+
OAuth2.apply(config, _request)
|
530
|
+
_response = execute_request(_request)
|
531
|
+
|
532
|
+
# Return appropriate response type.
|
533
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
534
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
535
|
+
ApiResponse.new(
|
536
|
+
_response, data: decoded, errors: _errors
|
537
|
+
)
|
538
|
+
end
|
539
|
+
end
|
540
|
+
end
|
@@ -9,14 +9,15 @@ module Square
|
|
9
9
|
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
10
10
|
# a previous call to this endpoint. Provide this cursor to retrieve the next
|
11
11
|
# set of results for your original query. For more information, see
|
12
|
-
# [Pagination](https://developer.squareup.com/docs/
|
13
|
-
#
|
12
|
+
# [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
|
13
|
+
# atterns/pagination).
|
14
14
|
# @param [Integer] limit Optional parameter: The maximum number of results
|
15
15
|
# to return in a single page. This limit is advisory. The response might
|
16
|
-
# contain more or fewer results.
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
16
|
+
# contain more or fewer results. If the limit is less than 1 or greater than
|
17
|
+
# 50, Square returns a `400 VALUE_TOO_LOW` or `400 VALUE_TOO_HIGH` error.
|
18
|
+
# The default value is 50. For more information, see
|
19
|
+
# [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
|
20
|
+
# atterns/pagination).
|
20
21
|
# @return [ListCustomerGroupsResponse Hash] response from the API call
|
21
22
|
def list_customer_groups(cursor: nil,
|
22
23
|
limit: nil)
|
@@ -9,14 +9,15 @@ module Square
|
|
9
9
|
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
10
10
|
# previous calls to `ListCustomerSegments`. This cursor is used to retrieve
|
11
11
|
# the next set of query results. For more information, see
|
12
|
-
# [Pagination](https://developer.squareup.com/docs/
|
13
|
-
#
|
12
|
+
# [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
|
13
|
+
# atterns/pagination).
|
14
14
|
# @param [Integer] limit Optional parameter: The maximum number of results
|
15
15
|
# to return in a single page. This limit is advisory. The response might
|
16
|
-
# contain more or fewer results.
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
16
|
+
# contain more or fewer results. If the specified limit is less than 1 or
|
17
|
+
# greater than 50, Square returns a `400 VALUE_TOO_LOW` or `400
|
18
|
+
# VALUE_TOO_HIGH` error. The default value is 50. For more information, see
|
19
|
+
# [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
|
20
|
+
# atterns/pagination).
|
20
21
|
# @return [ListCustomerSegmentsResponse Hash] response from the API call
|
21
22
|
def list_customer_segments(cursor: nil,
|
22
23
|
limit: nil)
|
@@ -15,14 +15,16 @@ module Square
|
|
15
15
|
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
16
16
|
# a previous call to this endpoint. Provide this cursor to retrieve the next
|
17
17
|
# set of results for your original query. For more information, see
|
18
|
-
# [Pagination](https://developer.squareup.com/docs/
|
19
|
-
#
|
18
|
+
# [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
|
19
|
+
# atterns/pagination).
|
20
20
|
# @param [Integer] limit Optional parameter: The maximum number of results
|
21
21
|
# to return in a single page. This limit is advisory. The response might
|
22
|
-
# contain more or fewer results.
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
22
|
+
# contain more or fewer results. If the specified limit is less than 1 or
|
23
|
+
# greater than 100, Square returns a `400 VALUE_TOO_LOW` or `400
|
24
|
+
# VALUE_TOO_HIGH` error. The default value is 100. For more information,
|
25
|
+
# see
|
26
|
+
# [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
|
27
|
+
# atterns/pagination).
|
26
28
|
# @param [CustomerSortField] sort_field Optional parameter: Indicates how
|
27
29
|
# customers should be sorted. The default value is `DEFAULT`.
|
28
30
|
# @param [SortOrder] sort_order Optional parameter: Indicates whether
|
@@ -166,8 +168,9 @@ module Square
|
|
166
168
|
# @param [Long] version Optional parameter: The current version of the
|
167
169
|
# customer profile. As a best practice, you should include this parameter
|
168
170
|
# to enable [optimistic
|
169
|
-
# concurrency](https://developer.squareup.com/docs/
|
170
|
-
#
|
171
|
+
# concurrency](https://developer.squareup.com/docs/build-basics/common-api-p
|
172
|
+
# atterns/optimistic-concurrency) control. For more information, see
|
173
|
+
# [Delete a customer
|
171
174
|
# profile](https://developer.squareup.com/docs/customers-api/use-the-api/kee
|
172
175
|
# p-records#delete-customer-profile).
|
173
176
|
# @return [DeleteCustomerResponse Hash] response from the API call
|
@@ -91,12 +91,11 @@ module Square
|
|
91
91
|
)
|
92
92
|
end
|
93
93
|
|
94
|
-
# Creates a gift card activity
|
95
|
-
#
|
96
|
-
#
|
97
|
-
#
|
98
|
-
#
|
99
|
-
# #using-activated-gift-cards).
|
94
|
+
# Creates a gift card activity to manage the balance or state of a [gift
|
95
|
+
# card]($m/GiftCard).
|
96
|
+
# For example, you create an `ACTIVATE` activity to activate a gift card
|
97
|
+
# with an initial balance
|
98
|
+
# before the gift card can be used.
|
100
99
|
# @param [CreateGiftCardActivityRequest] body Required parameter: An object
|
101
100
|
# containing the fields to POST for the request. See the corresponding
|
102
101
|
# object definition for field details.
|
@@ -68,11 +68,11 @@ module Square
|
|
68
68
|
end
|
69
69
|
|
70
70
|
# Creates a digital gift card or registers a physical (plastic) gift card.
|
71
|
-
#
|
72
|
-
#
|
73
|
-
# [
|
74
|
-
#
|
75
|
-
#
|
71
|
+
# After the gift card
|
72
|
+
# is created, you must call
|
73
|
+
# [CreateGiftCardActivity]($e/GiftCardActivities/CreateGiftCardActivity)
|
74
|
+
# to activate the card with an initial balance before it can be used for
|
75
|
+
# payment.
|
76
76
|
# @param [CreateGiftCardRequest] body Required parameter: An object
|
77
77
|
# containing the fields to POST for the request. See the corresponding
|
78
78
|
# object definition for field details.
|
@@ -259,7 +259,7 @@ module Square
|
|
259
259
|
)
|
260
260
|
end
|
261
261
|
|
262
|
-
# Retrieves a gift card using
|
262
|
+
# Retrieves a gift card using the gift card ID.
|
263
263
|
# @param [String] id Required parameter: The ID of the gift card to
|
264
264
|
# retrieve.
|
265
265
|
# @return [RetrieveGiftCardResponse Hash] response from the API call
|