square.rb 6.2.0.20200812 → 8.0.0.20201216
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +34 -33
- data/lib/square.rb +61 -62
- data/lib/square/api/apple_pay_api.rb +5 -3
- data/lib/square/api/bank_accounts_api.rb +16 -19
- data/lib/square/api/base_api.rb +1 -1
- data/lib/square/api/bookings_api.rb +308 -0
- data/lib/square/api/cash_drawers_api.rb +13 -6
- data/lib/square/api/catalog_api.rb +68 -32
- data/lib/square/api/checkout_api.rb +4 -2
- data/lib/square/api/customer_groups_api.rb +18 -8
- data/lib/square/api/customer_segments_api.rb +9 -5
- data/lib/square/api/customers_api.rb +47 -27
- data/lib/square/api/devices_api.rb +17 -6
- data/lib/square/api/disputes_api.rb +71 -68
- data/lib/square/api/employees_api.rb +10 -5
- data/lib/square/api/inventory_api.rb +30 -15
- data/lib/square/api/invoices_api.rb +42 -38
- data/lib/square/api/labor_api.rb +131 -22
- data/lib/square/api/locations_api.rb +16 -13
- data/lib/square/api/loyalty_api.rb +60 -66
- data/lib/square/api/merchants_api.rb +7 -3
- data/lib/square/api/mobile_authorization_api.rb +5 -3
- data/lib/square/api/o_auth_api.rb +11 -8
- data/lib/square/api/orders_api.rb +111 -90
- data/lib/square/api/payments_api.rb +75 -65
- data/lib/square/api/refunds_api.rb +37 -27
- data/lib/square/api/subscriptions_api.rb +29 -28
- data/lib/square/api/team_api.rb +46 -30
- data/lib/square/api/terminal_api.rb +156 -7
- data/lib/square/api/transactions_api.rb +32 -18
- data/lib/square/api/v1_employees_api.rb +59 -31
- data/lib/square/api/v1_items_api.rb +195 -115
- data/lib/square/api/v1_transactions_api.rb +49 -27
- data/lib/square/api_helper.rb +14 -9
- data/lib/square/client.rb +14 -20
- data/lib/square/configuration.rb +2 -2
- data/lib/square/http/api_response.rb +2 -0
- data/lib/square/http/faraday_client.rb +9 -2
- data/spec/user_journey_spec.rb +2 -5
- data/test/api/api_test_base.rb +1 -6
- data/test/api/test_catalog_api.rb +1 -4
- data/test/api/test_customers_api.rb +1 -4
- data/test/api/test_employees_api.rb +1 -4
- data/test/api/test_labor_api.rb +2 -6
- data/test/api/test_locations_api.rb +22 -33
- data/test/api/test_merchants_api.rb +1 -4
- data/test/api/test_payments_api.rb +3 -6
- data/test/api/test_refunds_api.rb +3 -6
- data/test/http_response_catcher.rb +0 -5
- data/test/test_helper.rb +0 -5
- metadata +33 -16
- data/lib/square/api/reporting_api.rb +0 -138
- data/lib/square/api/v1_locations_api.rb +0 -65
@@ -57,11 +57,14 @@ module Square
|
|
57
57
|
# Return appropriate response type.
|
58
58
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
59
59
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
60
|
-
ApiResponse.new(
|
60
|
+
ApiResponse.new(
|
61
|
+
_response, data: decoded, errors: _errors
|
62
|
+
)
|
61
63
|
end
|
62
64
|
|
63
65
|
# Provides the summary details for a single cash drawer shift. See
|
64
|
-
#
|
66
|
+
# [ListCashDrawerShiftEvents](#endpoint-CashDrawers-ListCashDrawerShiftEvent
|
67
|
+
# s) for a list of cash drawer shift events.
|
65
68
|
# @param [String] location_id Required parameter: The ID of the location to
|
66
69
|
# retrieve cash drawer shifts from.
|
67
70
|
# @param [String] shift_id Required parameter: The shift ID.
|
@@ -73,7 +76,7 @@ module Square
|
|
73
76
|
_query_builder << '/v2/cash-drawers/shifts/{shift_id}'
|
74
77
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
75
78
|
_query_builder,
|
76
|
-
'shift_id' => shift_id
|
79
|
+
'shift_id' => { 'value' => shift_id, 'encode' => true }
|
77
80
|
)
|
78
81
|
_query_builder = APIHelper.append_url_with_query_parameters(
|
79
82
|
_query_builder,
|
@@ -97,7 +100,9 @@ module Square
|
|
97
100
|
# Return appropriate response type.
|
98
101
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
99
102
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
100
|
-
ApiResponse.new(
|
103
|
+
ApiResponse.new(
|
104
|
+
_response, data: decoded, errors: _errors
|
105
|
+
)
|
101
106
|
end
|
102
107
|
|
103
108
|
# Provides a paginated list of events for a single cash drawer shift.
|
@@ -118,7 +123,7 @@ module Square
|
|
118
123
|
_query_builder << '/v2/cash-drawers/shifts/{shift_id}/events'
|
119
124
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
120
125
|
_query_builder,
|
121
|
-
'shift_id' => shift_id
|
126
|
+
'shift_id' => { 'value' => shift_id, 'encode' => true }
|
122
127
|
)
|
123
128
|
_query_builder = APIHelper.append_url_with_query_parameters(
|
124
129
|
_query_builder,
|
@@ -144,7 +149,9 @@ module Square
|
|
144
149
|
# Return appropriate response type.
|
145
150
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
146
151
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
147
|
-
ApiResponse.new(
|
152
|
+
ApiResponse.new(
|
153
|
+
_response, data: decoded, errors: _errors
|
154
|
+
)
|
148
155
|
end
|
149
156
|
end
|
150
157
|
end
|
@@ -44,7 +44,9 @@ module Square
|
|
44
44
|
# Return appropriate response type.
|
45
45
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
46
46
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
47
|
-
ApiResponse.new(
|
47
|
+
ApiResponse.new(
|
48
|
+
_response, data: decoded, errors: _errors
|
49
|
+
)
|
48
50
|
end
|
49
51
|
|
50
52
|
# Returns a set of objects based on the provided ID.
|
@@ -83,7 +85,9 @@ module Square
|
|
83
85
|
# Return appropriate response type.
|
84
86
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
85
87
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
86
|
-
ApiResponse.new(
|
88
|
+
ApiResponse.new(
|
89
|
+
_response, data: decoded, errors: _errors
|
90
|
+
)
|
87
91
|
end
|
88
92
|
|
89
93
|
# Creates or updates up to 10,000 target objects based on the provided
|
@@ -128,10 +132,12 @@ module Square
|
|
128
132
|
# Return appropriate response type.
|
129
133
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
130
134
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
131
|
-
ApiResponse.new(
|
135
|
+
ApiResponse.new(
|
136
|
+
_response, data: decoded, errors: _errors
|
137
|
+
)
|
132
138
|
end
|
133
139
|
|
134
|
-
# Uploads an image file to be represented by
|
140
|
+
# Uploads an image file to be represented by a
|
135
141
|
# [CatalogImage](#type-catalogimage) object linked to an existing
|
136
142
|
# [CatalogObject](#type-catalogobject) instance. A call to this endpoint can
|
137
143
|
# upload an image, link an image to
|
@@ -139,10 +145,6 @@ module Square
|
|
139
145
|
# This `CreateCatalogImage` endpoint accepts HTTP multipart/form-data
|
140
146
|
# requests with a JSON part and an image file part in
|
141
147
|
# JPEG, PJPEG, PNG, or GIF format. The maximum file size is 15MB.
|
142
|
-
# Additional information and an example cURL request can be found in the
|
143
|
-
# [Create a Catalog Image
|
144
|
-
# recipe](https://developer.squareup.com/docs/more-apis/catalog/cookbook/cre
|
145
|
-
# ate-catalog-images).
|
146
148
|
# @param [CreateCatalogImageRequest] request Optional parameter: Example:
|
147
149
|
# @param [File | UploadIO] image_file Optional parameter: Example:
|
148
150
|
# @return [CreateCatalogImageResponse Hash] response from the API call
|
@@ -191,7 +193,9 @@ module Square
|
|
191
193
|
# Return appropriate response type.
|
192
194
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
193
195
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
194
|
-
ApiResponse.new(
|
196
|
+
ApiResponse.new(
|
197
|
+
_response, data: decoded, errors: _errors
|
198
|
+
)
|
195
199
|
end
|
196
200
|
|
197
201
|
# Retrieves information about the Square Catalog API, such as batch size
|
@@ -219,7 +223,9 @@ module Square
|
|
219
223
|
# Return appropriate response type.
|
220
224
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
221
225
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
222
|
-
ApiResponse.new(
|
226
|
+
ApiResponse.new(
|
227
|
+
_response, data: decoded, errors: _errors
|
228
|
+
)
|
223
229
|
end
|
224
230
|
|
225
231
|
# Returns a list of [CatalogObject](#type-catalogobject)s that includes
|
@@ -233,9 +239,9 @@ module Square
|
|
233
239
|
# `DISCOUNT`, `TAX`, `IMAGE`.
|
234
240
|
# __Important:__ ListCatalog does not return deleted catalog items. To
|
235
241
|
# retrieve
|
236
|
-
# deleted catalog items, use
|
237
|
-
#
|
238
|
-
# to `true`.
|
242
|
+
# deleted catalog items, use
|
243
|
+
# [SearchCatalogObjects](#endpoint-Catalog-SearchCatalogObjects)
|
244
|
+
# and set the `include_deleted_objects` attribute value to `true`.
|
239
245
|
# @param [String] cursor Optional parameter: The pagination cursor returned
|
240
246
|
# in the previous response. Leave unset for an initial request. See
|
241
247
|
# [Pagination](https://developer.squareup.com/docs/basics/api101/pagination)
|
@@ -245,16 +251,23 @@ module Square
|
|
245
251
|
# `ITEM,ITEM_VARIATION,CATEGORY,IMAGE`. The legal values are taken from the
|
246
252
|
# CatalogObjectType enum: `ITEM`, `ITEM_VARIATION`, `CATEGORY`, `DISCOUNT`,
|
247
253
|
# `TAX`, `MODIFIER`, `MODIFIER_LIST`, or `IMAGE`.
|
254
|
+
# @param [Long] catalog_version Optional parameter: The specific version of
|
255
|
+
# the catalog objects to be included in the response. This allows you to
|
256
|
+
# retrieve historical versions of objects. The specified version value is
|
257
|
+
# matched against the [CatalogObject](#type-catalogobject)s' `version`
|
258
|
+
# attribute.
|
248
259
|
# @return [ListCatalogResponse Hash] response from the API call
|
249
260
|
def list_catalog(cursor: nil,
|
250
|
-
types: nil
|
261
|
+
types: nil,
|
262
|
+
catalog_version: nil)
|
251
263
|
# Prepare query url.
|
252
264
|
_query_builder = config.get_base_uri
|
253
265
|
_query_builder << '/v2/catalog/list'
|
254
266
|
_query_builder = APIHelper.append_url_with_query_parameters(
|
255
267
|
_query_builder,
|
256
268
|
'cursor' => cursor,
|
257
|
-
'types' => types
|
269
|
+
'types' => types,
|
270
|
+
'catalog_version' => catalog_version
|
258
271
|
)
|
259
272
|
_query_url = APIHelper.clean_url _query_builder
|
260
273
|
|
@@ -274,7 +287,9 @@ module Square
|
|
274
287
|
# Return appropriate response type.
|
275
288
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
276
289
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
277
|
-
ApiResponse.new(
|
290
|
+
ApiResponse.new(
|
291
|
+
_response, data: decoded, errors: _errors
|
292
|
+
)
|
278
293
|
end
|
279
294
|
|
280
295
|
# Creates or updates the target [CatalogObject](#type-catalogobject).
|
@@ -306,7 +321,9 @@ module Square
|
|
306
321
|
# Return appropriate response type.
|
307
322
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
308
323
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
309
|
-
ApiResponse.new(
|
324
|
+
ApiResponse.new(
|
325
|
+
_response, data: decoded, errors: _errors
|
326
|
+
)
|
310
327
|
end
|
311
328
|
|
312
329
|
# Deletes a single [CatalogObject](#type-catalogobject) based on the
|
@@ -328,7 +345,7 @@ module Square
|
|
328
345
|
_query_builder << '/v2/catalog/object/{object_id}'
|
329
346
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
330
347
|
_query_builder,
|
331
|
-
'object_id' => object_id
|
348
|
+
'object_id' => { 'value' => object_id, 'encode' => true }
|
332
349
|
)
|
333
350
|
_query_url = APIHelper.clean_url _query_builder
|
334
351
|
|
@@ -348,7 +365,9 @@ module Square
|
|
348
365
|
# Return appropriate response type.
|
349
366
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
350
367
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
351
|
-
ApiResponse.new(
|
368
|
+
ApiResponse.new(
|
369
|
+
_response, data: decoded, errors: _errors
|
370
|
+
)
|
352
371
|
end
|
353
372
|
|
354
373
|
# Returns a single [CatalogItem](#type-catalogitem) as a
|
@@ -364,25 +383,32 @@ module Square
|
|
364
383
|
# @param [Boolean] include_related_objects Optional parameter: If `true`,
|
365
384
|
# the response will include additional objects that are related to the
|
366
385
|
# requested object, as follows: If the `object` field of the response
|
367
|
-
# contains a CatalogItem
|
368
|
-
#
|
386
|
+
# contains a `CatalogItem`, its associated `CatalogCategory`, `CatalogTax`,
|
387
|
+
# `CatalogImage` and `CatalogModifierList` objects will be returned in the
|
369
388
|
# `related_objects` field of the response. If the `object` field of the
|
370
|
-
# response contains a CatalogItemVariation
|
371
|
-
# returned in the `related_objects` field of the response. Default
|
372
|
-
# `false`
|
389
|
+
# response contains a `CatalogItemVariation`, its parent `CatalogItem` will
|
390
|
+
# be returned in the `related_objects` field of the response. Default
|
391
|
+
# value: `false`
|
392
|
+
# @param [Long] catalog_version Optional parameter: Requests objects as of a
|
393
|
+
# specific version of the catalog. This allows you to retrieve historical
|
394
|
+
# versions of objects. The value to retrieve a specific version of an object
|
395
|
+
# can be found in the version field of
|
396
|
+
# [CatalogObject](#type-catalogobject)s.
|
373
397
|
# @return [RetrieveCatalogObjectResponse Hash] response from the API call
|
374
398
|
def retrieve_catalog_object(object_id:,
|
375
|
-
include_related_objects: false
|
399
|
+
include_related_objects: false,
|
400
|
+
catalog_version: nil)
|
376
401
|
# Prepare query url.
|
377
402
|
_query_builder = config.get_base_uri
|
378
403
|
_query_builder << '/v2/catalog/object/{object_id}'
|
379
404
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
380
405
|
_query_builder,
|
381
|
-
'object_id' => object_id
|
406
|
+
'object_id' => { 'value' => object_id, 'encode' => true }
|
382
407
|
)
|
383
408
|
_query_builder = APIHelper.append_url_with_query_parameters(
|
384
409
|
_query_builder,
|
385
|
-
'include_related_objects' => include_related_objects
|
410
|
+
'include_related_objects' => include_related_objects,
|
411
|
+
'catalog_version' => catalog_version
|
386
412
|
)
|
387
413
|
_query_url = APIHelper.clean_url _query_builder
|
388
414
|
|
@@ -402,7 +428,9 @@ module Square
|
|
402
428
|
# Return appropriate response type.
|
403
429
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
404
430
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
405
|
-
ApiResponse.new(
|
431
|
+
ApiResponse.new(
|
432
|
+
_response, data: decoded, errors: _errors
|
433
|
+
)
|
406
434
|
end
|
407
435
|
|
408
436
|
# Searches for [CatalogObject](#type-CatalogObject) of any types against
|
@@ -450,7 +478,9 @@ module Square
|
|
450
478
|
# Return appropriate response type.
|
451
479
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
452
480
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
453
|
-
ApiResponse.new(
|
481
|
+
ApiResponse.new(
|
482
|
+
_response, data: decoded, errors: _errors
|
483
|
+
)
|
454
484
|
end
|
455
485
|
|
456
486
|
# Searches for catalog items or item variations by matching supported search
|
@@ -498,7 +528,9 @@ module Square
|
|
498
528
|
# Return appropriate response type.
|
499
529
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
500
530
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
501
|
-
ApiResponse.new(
|
531
|
+
ApiResponse.new(
|
532
|
+
_response, data: decoded, errors: _errors
|
533
|
+
)
|
502
534
|
end
|
503
535
|
|
504
536
|
# Updates the [CatalogModifierList](#type-catalogmodifierlist) objects
|
@@ -532,7 +564,9 @@ module Square
|
|
532
564
|
# Return appropriate response type.
|
533
565
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
534
566
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
535
|
-
ApiResponse.new(
|
567
|
+
ApiResponse.new(
|
568
|
+
_response, data: decoded, errors: _errors
|
569
|
+
)
|
536
570
|
end
|
537
571
|
|
538
572
|
# Updates the [CatalogTax](#type-catalogtax) objects that apply to the
|
@@ -566,7 +600,9 @@ module Square
|
|
566
600
|
# Return appropriate response type.
|
567
601
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
568
602
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
569
|
-
ApiResponse.new(
|
603
|
+
ApiResponse.new(
|
604
|
+
_response, data: decoded, errors: _errors
|
605
|
+
)
|
570
606
|
end
|
571
607
|
end
|
572
608
|
end
|
@@ -21,7 +21,7 @@ module Square
|
|
21
21
|
_query_builder << '/v2/locations/{location_id}/checkouts'
|
22
22
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
23
23
|
_query_builder,
|
24
|
-
'location_id' => location_id
|
24
|
+
'location_id' => { 'value' => location_id, 'encode' => true }
|
25
25
|
)
|
26
26
|
_query_url = APIHelper.clean_url _query_builder
|
27
27
|
|
@@ -43,7 +43,9 @@ module Square
|
|
43
43
|
# Return appropriate response type.
|
44
44
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
45
45
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
46
|
-
ApiResponse.new(
|
46
|
+
ApiResponse.new(
|
47
|
+
_response, data: decoded, errors: _errors
|
48
|
+
)
|
47
49
|
end
|
48
50
|
end
|
49
51
|
end
|
@@ -38,7 +38,9 @@ module Square
|
|
38
38
|
# Return appropriate response type.
|
39
39
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
40
40
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
41
|
-
ApiResponse.new(
|
41
|
+
ApiResponse.new(
|
42
|
+
_response, data: decoded, errors: _errors
|
43
|
+
)
|
42
44
|
end
|
43
45
|
|
44
46
|
# Creates a new customer group for a business.
|
@@ -71,7 +73,9 @@ module Square
|
|
71
73
|
# Return appropriate response type.
|
72
74
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
73
75
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
74
|
-
ApiResponse.new(
|
76
|
+
ApiResponse.new(
|
77
|
+
_response, data: decoded, errors: _errors
|
78
|
+
)
|
75
79
|
end
|
76
80
|
|
77
81
|
# Deletes a customer group as identified by the `group_id` value.
|
@@ -84,7 +88,7 @@ module Square
|
|
84
88
|
_query_builder << '/v2/customers/groups/{group_id}'
|
85
89
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
86
90
|
_query_builder,
|
87
|
-
'group_id' => group_id
|
91
|
+
'group_id' => { 'value' => group_id, 'encode' => true }
|
88
92
|
)
|
89
93
|
_query_url = APIHelper.clean_url _query_builder
|
90
94
|
|
@@ -104,7 +108,9 @@ module Square
|
|
104
108
|
# Return appropriate response type.
|
105
109
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
106
110
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
107
|
-
ApiResponse.new(
|
111
|
+
ApiResponse.new(
|
112
|
+
_response, data: decoded, errors: _errors
|
113
|
+
)
|
108
114
|
end
|
109
115
|
|
110
116
|
# Retrieves a specific customer group as identified by the `group_id` value.
|
@@ -117,7 +123,7 @@ module Square
|
|
117
123
|
_query_builder << '/v2/customers/groups/{group_id}'
|
118
124
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
119
125
|
_query_builder,
|
120
|
-
'group_id' => group_id
|
126
|
+
'group_id' => { 'value' => group_id, 'encode' => true }
|
121
127
|
)
|
122
128
|
_query_url = APIHelper.clean_url _query_builder
|
123
129
|
|
@@ -137,7 +143,9 @@ module Square
|
|
137
143
|
# Return appropriate response type.
|
138
144
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
139
145
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
140
|
-
ApiResponse.new(
|
146
|
+
ApiResponse.new(
|
147
|
+
_response, data: decoded, errors: _errors
|
148
|
+
)
|
141
149
|
end
|
142
150
|
|
143
151
|
# Updates a customer group as identified by the `group_id` value.
|
@@ -154,7 +162,7 @@ module Square
|
|
154
162
|
_query_builder << '/v2/customers/groups/{group_id}'
|
155
163
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
156
164
|
_query_builder,
|
157
|
-
'group_id' => group_id
|
165
|
+
'group_id' => { 'value' => group_id, 'encode' => true }
|
158
166
|
)
|
159
167
|
_query_url = APIHelper.clean_url _query_builder
|
160
168
|
|
@@ -176,7 +184,9 @@ module Square
|
|
176
184
|
# Return appropriate response type.
|
177
185
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
178
186
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
179
|
-
ApiResponse.new(
|
187
|
+
ApiResponse.new(
|
188
|
+
_response, data: decoded, errors: _errors
|
189
|
+
)
|
180
190
|
end
|
181
191
|
end
|
182
192
|
end
|
@@ -9,8 +9,8 @@ module Square
|
|
9
9
|
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
10
10
|
# previous calls to __ListCustomerSegments__. Used to retrieve the next set
|
11
11
|
# of query results. See the [Pagination
|
12
|
-
# guide](https://developer.squareup.com/docs/
|
13
|
-
#
|
12
|
+
# guide](https://developer.squareup.com/docs/working-with-apis/pagination)
|
13
|
+
# for more information.
|
14
14
|
# @return [ListCustomerSegmentsResponse Hash] response from the API call
|
15
15
|
def list_customer_segments(cursor: nil)
|
16
16
|
# Prepare query url.
|
@@ -38,7 +38,9 @@ module Square
|
|
38
38
|
# Return appropriate response type.
|
39
39
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
40
40
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
41
|
-
ApiResponse.new(
|
41
|
+
ApiResponse.new(
|
42
|
+
_response, data: decoded, errors: _errors
|
43
|
+
)
|
42
44
|
end
|
43
45
|
|
44
46
|
# Retrieves a specific customer segment as identified by the `segment_id`
|
@@ -52,7 +54,7 @@ module Square
|
|
52
54
|
_query_builder << '/v2/customers/segments/{segment_id}'
|
53
55
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
54
56
|
_query_builder,
|
55
|
-
'segment_id' => segment_id
|
57
|
+
'segment_id' => { 'value' => segment_id, 'encode' => true }
|
56
58
|
)
|
57
59
|
_query_url = APIHelper.clean_url _query_builder
|
58
60
|
|
@@ -72,7 +74,9 @@ module Square
|
|
72
74
|
# Return appropriate response type.
|
73
75
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
74
76
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
75
|
-
ApiResponse.new(
|
77
|
+
ApiResponse.new(
|
78
|
+
_response, data: decoded, errors: _errors
|
79
|
+
)
|
76
80
|
end
|
77
81
|
end
|
78
82
|
end
|
@@ -10,7 +10,7 @@ module Square
|
|
10
10
|
# profiles become available
|
11
11
|
# for the listing operation in well under 30 seconds. Occasionally,
|
12
12
|
# propagation of the new or updated
|
13
|
-
# profiles can take closer to one minute or longer,
|
13
|
+
# profiles can take closer to one minute or longer, especially during
|
14
14
|
# network incidents and outages.
|
15
15
|
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
16
16
|
# a previous call to this endpoint. Provide this to retrieve the next set of
|
@@ -53,7 +53,9 @@ module Square
|
|
53
53
|
# Return appropriate response type.
|
54
54
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
55
55
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
56
|
-
ApiResponse.new(
|
56
|
+
ApiResponse.new(
|
57
|
+
_response, data: decoded, errors: _errors
|
58
|
+
)
|
57
59
|
end
|
58
60
|
|
59
61
|
# Creates a new customer for a business, which can have associated cards on
|
@@ -94,11 +96,13 @@ module Square
|
|
94
96
|
# Return appropriate response type.
|
95
97
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
96
98
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
97
|
-
ApiResponse.new(
|
99
|
+
ApiResponse.new(
|
100
|
+
_response, data: decoded, errors: _errors
|
101
|
+
)
|
98
102
|
end
|
99
103
|
|
100
|
-
# Searches the customer profiles associated with a Square account using
|
101
|
-
#
|
104
|
+
# Searches the customer profiles associated with a Square account using a
|
105
|
+
# supported query filter.
|
102
106
|
# Calling `SearchCustomers` without any explicit query filter returns all
|
103
107
|
# customer profiles ordered alphabetically based on `given_name` and
|
104
108
|
# `family_name`.
|
@@ -106,7 +110,7 @@ module Square
|
|
106
110
|
# profiles become available
|
107
111
|
# for the search operation in well under 30 seconds. Occasionally,
|
108
112
|
# propagation of the new or updated
|
109
|
-
# profiles can take closer to one minute or longer,
|
113
|
+
# profiles can take closer to one minute or longer, especially during
|
110
114
|
# network incidents and outages.
|
111
115
|
# @param [SearchCustomersRequest] body Required parameter: An object
|
112
116
|
# containing the fields to POST for the request. See the corresponding
|
@@ -136,7 +140,9 @@ module Square
|
|
136
140
|
# Return appropriate response type.
|
137
141
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
138
142
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
139
|
-
ApiResponse.new(
|
143
|
+
ApiResponse.new(
|
144
|
+
_response, data: decoded, errors: _errors
|
145
|
+
)
|
140
146
|
end
|
141
147
|
|
142
148
|
# Deletes a customer from a business, along with any linked cards on file.
|
@@ -153,7 +159,7 @@ module Square
|
|
153
159
|
_query_builder << '/v2/customers/{customer_id}'
|
154
160
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
155
161
|
_query_builder,
|
156
|
-
'customer_id' => customer_id
|
162
|
+
'customer_id' => { 'value' => customer_id, 'encode' => true }
|
157
163
|
)
|
158
164
|
_query_url = APIHelper.clean_url _query_builder
|
159
165
|
|
@@ -173,7 +179,9 @@ module Square
|
|
173
179
|
# Return appropriate response type.
|
174
180
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
175
181
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
176
|
-
ApiResponse.new(
|
182
|
+
ApiResponse.new(
|
183
|
+
_response, data: decoded, errors: _errors
|
184
|
+
)
|
177
185
|
end
|
178
186
|
|
179
187
|
# Returns details for a single customer.
|
@@ -186,7 +194,7 @@ module Square
|
|
186
194
|
_query_builder << '/v2/customers/{customer_id}'
|
187
195
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
188
196
|
_query_builder,
|
189
|
-
'customer_id' => customer_id
|
197
|
+
'customer_id' => { 'value' => customer_id, 'encode' => true }
|
190
198
|
)
|
191
199
|
_query_url = APIHelper.clean_url _query_builder
|
192
200
|
|
@@ -206,7 +214,9 @@ module Square
|
|
206
214
|
# Return appropriate response type.
|
207
215
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
208
216
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
209
|
-
ApiResponse.new(
|
217
|
+
ApiResponse.new(
|
218
|
+
_response, data: decoded, errors: _errors
|
219
|
+
)
|
210
220
|
end
|
211
221
|
|
212
222
|
# Updates the details of an existing customer. When two profiles are merged
|
@@ -216,9 +226,9 @@ module Square
|
|
216
226
|
# You cannot edit a customer's cards on file with this endpoint. To make
|
217
227
|
# changes
|
218
228
|
# to a card on file, you must delete the existing card on file with the
|
219
|
-
# [DeleteCustomerCard](#endpoint-deletecustomercard) endpoint,
|
220
|
-
# new one with the
|
221
|
-
# [CreateCustomerCard](#endpoint-createcustomercard) endpoint.
|
229
|
+
# [DeleteCustomerCard](#endpoint-Customers-deletecustomercard) endpoint,
|
230
|
+
# then create a new one with the
|
231
|
+
# [CreateCustomerCard](#endpoint-Customers-createcustomercard) endpoint.
|
222
232
|
# @param [String] customer_id Required parameter: The ID of the customer to
|
223
233
|
# update.
|
224
234
|
# @param [UpdateCustomerRequest] body Required parameter: An object
|
@@ -232,7 +242,7 @@ module Square
|
|
232
242
|
_query_builder << '/v2/customers/{customer_id}'
|
233
243
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
234
244
|
_query_builder,
|
235
|
-
'customer_id' => customer_id
|
245
|
+
'customer_id' => { 'value' => customer_id, 'encode' => true }
|
236
246
|
)
|
237
247
|
_query_url = APIHelper.clean_url _query_builder
|
238
248
|
|
@@ -254,7 +264,9 @@ module Square
|
|
254
264
|
# Return appropriate response type.
|
255
265
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
256
266
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
257
|
-
ApiResponse.new(
|
267
|
+
ApiResponse.new(
|
268
|
+
_response, data: decoded, errors: _errors
|
269
|
+
)
|
258
270
|
end
|
259
271
|
|
260
272
|
# Adds a card on file to an existing customer.
|
@@ -275,7 +287,7 @@ module Square
|
|
275
287
|
_query_builder << '/v2/customers/{customer_id}/cards'
|
276
288
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
277
289
|
_query_builder,
|
278
|
-
'customer_id' => customer_id
|
290
|
+
'customer_id' => { 'value' => customer_id, 'encode' => true }
|
279
291
|
)
|
280
292
|
_query_url = APIHelper.clean_url _query_builder
|
281
293
|
|
@@ -297,7 +309,9 @@ module Square
|
|
297
309
|
# Return appropriate response type.
|
298
310
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
299
311
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
300
|
-
ApiResponse.new(
|
312
|
+
ApiResponse.new(
|
313
|
+
_response, data: decoded, errors: _errors
|
314
|
+
)
|
301
315
|
end
|
302
316
|
|
303
317
|
# Removes a card on file from a customer.
|
@@ -313,8 +327,8 @@ module Square
|
|
313
327
|
_query_builder << '/v2/customers/{customer_id}/cards/{card_id}'
|
314
328
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
315
329
|
_query_builder,
|
316
|
-
'customer_id' => customer_id,
|
317
|
-
'card_id' => card_id
|
330
|
+
'customer_id' => { 'value' => customer_id, 'encode' => true },
|
331
|
+
'card_id' => { 'value' => card_id, 'encode' => true }
|
318
332
|
)
|
319
333
|
_query_url = APIHelper.clean_url _query_builder
|
320
334
|
|
@@ -334,7 +348,9 @@ module Square
|
|
334
348
|
# Return appropriate response type.
|
335
349
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
336
350
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
337
|
-
ApiResponse.new(
|
351
|
+
ApiResponse.new(
|
352
|
+
_response, data: decoded, errors: _errors
|
353
|
+
)
|
338
354
|
end
|
339
355
|
|
340
356
|
# Removes a group membership from a customer.
|
@@ -352,8 +368,8 @@ module Square
|
|
352
368
|
_query_builder << '/v2/customers/{customer_id}/groups/{group_id}'
|
353
369
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
354
370
|
_query_builder,
|
355
|
-
'customer_id' => customer_id,
|
356
|
-
'group_id' => group_id
|
371
|
+
'customer_id' => { 'value' => customer_id, 'encode' => true },
|
372
|
+
'group_id' => { 'value' => group_id, 'encode' => true }
|
357
373
|
)
|
358
374
|
_query_url = APIHelper.clean_url _query_builder
|
359
375
|
|
@@ -373,7 +389,9 @@ module Square
|
|
373
389
|
# Return appropriate response type.
|
374
390
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
375
391
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
376
|
-
ApiResponse.new(
|
392
|
+
ApiResponse.new(
|
393
|
+
_response, data: decoded, errors: _errors
|
394
|
+
)
|
377
395
|
end
|
378
396
|
|
379
397
|
# Adds a group membership to a customer.
|
@@ -391,8 +409,8 @@ module Square
|
|
391
409
|
_query_builder << '/v2/customers/{customer_id}/groups/{group_id}'
|
392
410
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
393
411
|
_query_builder,
|
394
|
-
'customer_id' => customer_id,
|
395
|
-
'group_id' => group_id
|
412
|
+
'customer_id' => { 'value' => customer_id, 'encode' => true },
|
413
|
+
'group_id' => { 'value' => group_id, 'encode' => true }
|
396
414
|
)
|
397
415
|
_query_url = APIHelper.clean_url _query_builder
|
398
416
|
|
@@ -412,7 +430,9 @@ module Square
|
|
412
430
|
# Return appropriate response type.
|
413
431
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
414
432
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
415
|
-
ApiResponse.new(
|
433
|
+
ApiResponse.new(
|
434
|
+
_response, data: decoded, errors: _errors
|
435
|
+
)
|
416
436
|
end
|
417
437
|
end
|
418
438
|
end
|