square.rb 26.1.0.20230119 → 26.2.0.20230315
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/square/api/apple_pay_api.rb +14 -30
- data/lib/square/api/bank_accounts_api.rb +40 -90
- data/lib/square/api/base_api.rb +42 -42
- data/lib/square/api/booking_custom_attributes_api.rb +164 -329
- data/lib/square/api/bookings_api.rb +135 -260
- data/lib/square/api/cards_api.rb +56 -118
- data/lib/square/api/cash_drawers_api.rb +47 -103
- data/lib/square/api/catalog_api.rb +197 -423
- data/lib/square/api/checkout_api.rb +85 -175
- data/lib/square/api/customer_custom_attributes_api.rb +150 -303
- data/lib/square/api/customer_groups_api.rb +69 -145
- data/lib/square/api/customer_segments_api.rb +26 -61
- data/lib/square/api/customers_api.rb +147 -294
- data/lib/square/api/devices_api.rb +42 -89
- data/lib/square/api/disputes_api.rb +130 -288
- data/lib/square/api/employees_api.rb +28 -63
- data/lib/square/api/gift_card_activities_api.rb +33 -65
- data/lib/square/api/gift_cards_api.rb +103 -202
- data/lib/square/api/inventory_api.rb +179 -366
- data/lib/square/api/invoices_api.rb +118 -237
- data/lib/square/api/labor_api.rb +223 -459
- data/lib/square/api/location_custom_attributes_api.rb +166 -331
- data/lib/square/api/locations_api.rb +54 -112
- data/lib/square/api/loyalty_api.rb +259 -512
- data/lib/square/api/merchants_api.rb +25 -60
- data/lib/square/api/mobile_authorization_api.rb +14 -30
- data/lib/square/api/o_auth_api.rb +54 -109
- data/lib/square/api/order_custom_attributes_api.rb +168 -333
- data/lib/square/api/orders_api.rb +115 -222
- data/lib/square/api/payments_api.rb +106 -208
- data/lib/square/api/payouts_api.rb +47 -100
- data/lib/square/api/refunds_api.rb +46 -93
- data/lib/square/api/sites_api.rb +11 -28
- data/lib/square/api/snippets_api.rb +42 -90
- data/lib/square/api/subscriptions_api.rb +150 -299
- data/lib/square/api/team_api.rb +114 -224
- data/lib/square/api/terminal_api.rb +162 -328
- data/lib/square/api/transactions_api.rb +62 -126
- data/lib/square/api/v1_transactions_api.rb +155 -296
- data/lib/square/api/vendors_api.rb +99 -192
- data/lib/square/api/webhook_subscriptions_api.rb +115 -235
- data/lib/square/api_helper.rb +1 -437
- data/lib/square/client.rb +77 -47
- data/lib/square/configuration.rb +28 -53
- data/lib/square/exceptions/api_exception.rb +1 -11
- data/lib/square/http/api_response.rb +13 -19
- data/lib/square/http/auth/o_auth2.rb +14 -7
- data/lib/square/http/http_call_back.rb +1 -15
- data/lib/square/http/http_method_enum.rb +1 -4
- data/lib/square/http/http_request.rb +1 -45
- data/lib/square/http/http_response.rb +1 -20
- data/lib/square/utilities/date_time_helper.rb +1 -146
- data/lib/square/utilities/file_wrapper.rb +5 -5
- data/lib/square.rb +6 -6
- data/spec/user_journey_spec.rb +2 -2
- data/test/api/api_test_base.rb +13 -5
- data/test/api/test_catalog_api.rb +5 -4
- data/test/api/test_customers_api.rb +3 -2
- data/test/api/test_employees_api.rb +4 -3
- data/test/api/test_labor_api.rb +6 -5
- data/test/api/test_locations_api.rb +3 -2
- data/test/api/test_merchants_api.rb +4 -3
- data/test/api/test_payments_api.rb +4 -3
- data/test/api/test_refunds_api.rb +4 -3
- metadata +11 -111
- data/lib/square/exceptions/validation_exception.rb +0 -13
- data/lib/square/http/faraday_client.rb +0 -93
- data/lib/square/http/http_client.rb +0 -118
- data/test/test_helper.rb +0 -89
@@ -1,10 +1,6 @@
|
|
1
1
|
module Square
|
2
2
|
# LoyaltyApi
|
3
3
|
class LoyaltyApi < BaseApi
|
4
|
-
def initialize(config, http_call_back: nil)
|
5
|
-
super(config, http_call_back: http_call_back)
|
6
|
-
end
|
7
|
-
|
8
4
|
# Creates a loyalty account. To create a loyalty account, you must provide
|
9
5
|
# the `program_id` and a `mapping` with the `phone_number` of the buyer.
|
10
6
|
# @param [CreateLoyaltyAccountRequest] body Required parameter: An object
|
@@ -12,32 +8,20 @@ module Square
|
|
12
8
|
# object definition for field details.
|
13
9
|
# @return [CreateLoyaltyAccountResponse Hash] response from the API call
|
14
10
|
def create_loyalty_account(body:)
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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(
|
39
|
-
_response, data: decoded, errors: _errors
|
40
|
-
)
|
11
|
+
new_api_call_builder
|
12
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
13
|
+
'/v2/loyalty/accounts',
|
14
|
+
'default')
|
15
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
16
|
+
.body_param(new_parameter(body))
|
17
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
18
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
19
|
+
.auth(Single.new('global')))
|
20
|
+
.response(new_response_handler
|
21
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
22
|
+
.is_api_response(true)
|
23
|
+
.convertor(ApiResponse.method(:create)))
|
24
|
+
.execute
|
41
25
|
end
|
42
26
|
|
43
27
|
# Searches for loyalty accounts in a loyalty program.
|
@@ -50,32 +34,20 @@ module Square
|
|
50
34
|
# object definition for field details.
|
51
35
|
# @return [SearchLoyaltyAccountsResponse Hash] response from the API call
|
52
36
|
def search_loyalty_accounts(body:)
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
headers: _headers,
|
68
|
-
parameters: body.to_json
|
69
|
-
)
|
70
|
-
OAuth2.apply(config, _request)
|
71
|
-
_response = execute_request(_request)
|
72
|
-
|
73
|
-
# Return appropriate response type.
|
74
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
75
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
76
|
-
ApiResponse.new(
|
77
|
-
_response, data: decoded, errors: _errors
|
78
|
-
)
|
37
|
+
new_api_call_builder
|
38
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
39
|
+
'/v2/loyalty/accounts/search',
|
40
|
+
'default')
|
41
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
42
|
+
.body_param(new_parameter(body))
|
43
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
44
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
45
|
+
.auth(Single.new('global')))
|
46
|
+
.response(new_response_handler
|
47
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
48
|
+
.is_api_response(true)
|
49
|
+
.convertor(ApiResponse.method(:create)))
|
50
|
+
.execute
|
79
51
|
end
|
80
52
|
|
81
53
|
# Retrieves a loyalty account.
|
@@ -83,34 +55,19 @@ module Square
|
|
83
55
|
# account]($m/LoyaltyAccount) to retrieve.
|
84
56
|
# @return [RetrieveLoyaltyAccountResponse Hash] response from the API call
|
85
57
|
def retrieve_loyalty_account(account_id:)
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
# Prepare and execute HttpRequest.
|
101
|
-
_request = config.http_client.get(
|
102
|
-
_query_url,
|
103
|
-
headers: _headers
|
104
|
-
)
|
105
|
-
OAuth2.apply(config, _request)
|
106
|
-
_response = execute_request(_request)
|
107
|
-
|
108
|
-
# Return appropriate response type.
|
109
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
110
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
111
|
-
ApiResponse.new(
|
112
|
-
_response, data: decoded, errors: _errors
|
113
|
-
)
|
58
|
+
new_api_call_builder
|
59
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
60
|
+
'/v2/loyalty/accounts/{account_id}',
|
61
|
+
'default')
|
62
|
+
.template_param(new_parameter(account_id, key: 'account_id')
|
63
|
+
.should_encode(true))
|
64
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
65
|
+
.auth(Single.new('global')))
|
66
|
+
.response(new_response_handler
|
67
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
68
|
+
.is_api_response(true)
|
69
|
+
.convertor(ApiResponse.method(:create)))
|
70
|
+
.execute
|
114
71
|
end
|
115
72
|
|
116
73
|
# Adds points earned from a purchase to a [loyalty
|
@@ -146,36 +103,22 @@ module Square
|
|
146
103
|
# @return [AccumulateLoyaltyPointsResponse Hash] response from the API call
|
147
104
|
def accumulate_loyalty_points(account_id:,
|
148
105
|
body:)
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
_request = config.http_client.post(
|
166
|
-
_query_url,
|
167
|
-
headers: _headers,
|
168
|
-
parameters: body.to_json
|
169
|
-
)
|
170
|
-
OAuth2.apply(config, _request)
|
171
|
-
_response = execute_request(_request)
|
172
|
-
|
173
|
-
# Return appropriate response type.
|
174
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
175
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
176
|
-
ApiResponse.new(
|
177
|
-
_response, data: decoded, errors: _errors
|
178
|
-
)
|
106
|
+
new_api_call_builder
|
107
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
108
|
+
'/v2/loyalty/accounts/{account_id}/accumulate',
|
109
|
+
'default')
|
110
|
+
.template_param(new_parameter(account_id, key: 'account_id')
|
111
|
+
.should_encode(true))
|
112
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
113
|
+
.body_param(new_parameter(body))
|
114
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
115
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
116
|
+
.auth(Single.new('global')))
|
117
|
+
.response(new_response_handler
|
118
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
119
|
+
.is_api_response(true)
|
120
|
+
.convertor(ApiResponse.method(:create)))
|
121
|
+
.execute
|
179
122
|
end
|
180
123
|
|
181
124
|
# Adds points to or subtracts points from a buyer's account.
|
@@ -191,36 +134,22 @@ module Square
|
|
191
134
|
# @return [AdjustLoyaltyPointsResponse Hash] response from the API call
|
192
135
|
def adjust_loyalty_points(account_id:,
|
193
136
|
body:)
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
_request = config.http_client.post(
|
211
|
-
_query_url,
|
212
|
-
headers: _headers,
|
213
|
-
parameters: body.to_json
|
214
|
-
)
|
215
|
-
OAuth2.apply(config, _request)
|
216
|
-
_response = execute_request(_request)
|
217
|
-
|
218
|
-
# Return appropriate response type.
|
219
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
220
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
221
|
-
ApiResponse.new(
|
222
|
-
_response, data: decoded, errors: _errors
|
223
|
-
)
|
137
|
+
new_api_call_builder
|
138
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
139
|
+
'/v2/loyalty/accounts/{account_id}/adjust',
|
140
|
+
'default')
|
141
|
+
.template_param(new_parameter(account_id, key: 'account_id')
|
142
|
+
.should_encode(true))
|
143
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
144
|
+
.body_param(new_parameter(body))
|
145
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
146
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
147
|
+
.auth(Single.new('global')))
|
148
|
+
.response(new_response_handler
|
149
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
150
|
+
.is_api_response(true)
|
151
|
+
.convertor(ApiResponse.method(:create)))
|
152
|
+
.execute
|
224
153
|
end
|
225
154
|
|
226
155
|
# Searches for loyalty events.
|
@@ -236,32 +165,20 @@ module Square
|
|
236
165
|
# object definition for field details.
|
237
166
|
# @return [SearchLoyaltyEventsResponse Hash] response from the API call
|
238
167
|
def search_loyalty_events(body:)
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
headers: _headers,
|
254
|
-
parameters: body.to_json
|
255
|
-
)
|
256
|
-
OAuth2.apply(config, _request)
|
257
|
-
_response = execute_request(_request)
|
258
|
-
|
259
|
-
# Return appropriate response type.
|
260
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
261
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
262
|
-
ApiResponse.new(
|
263
|
-
_response, data: decoded, errors: _errors
|
264
|
-
)
|
168
|
+
new_api_call_builder
|
169
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
170
|
+
'/v2/loyalty/events/search',
|
171
|
+
'default')
|
172
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
173
|
+
.body_param(new_parameter(body))
|
174
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
175
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
176
|
+
.auth(Single.new('global')))
|
177
|
+
.response(new_response_handler
|
178
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
179
|
+
.is_api_response(true)
|
180
|
+
.convertor(ApiResponse.method(:create)))
|
181
|
+
.execute
|
265
182
|
end
|
266
183
|
|
267
184
|
# Returns a list of loyalty programs in the seller's account.
|
@@ -275,30 +192,17 @@ module Square
|
|
275
192
|
# @return [ListLoyaltyProgramsResponse Hash] response from the API call
|
276
193
|
def list_loyalty_programs
|
277
194
|
warn 'Endpoint list_loyalty_programs in LoyaltyApi is deprecated'
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
_request = config.http_client.get(
|
290
|
-
_query_url,
|
291
|
-
headers: _headers
|
292
|
-
)
|
293
|
-
OAuth2.apply(config, _request)
|
294
|
-
_response = execute_request(_request)
|
295
|
-
|
296
|
-
# Return appropriate response type.
|
297
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
298
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
299
|
-
ApiResponse.new(
|
300
|
-
_response, data: decoded, errors: _errors
|
301
|
-
)
|
195
|
+
new_api_call_builder
|
196
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
197
|
+
'/v2/loyalty/programs',
|
198
|
+
'default')
|
199
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
200
|
+
.auth(Single.new('global')))
|
201
|
+
.response(new_response_handler
|
202
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
203
|
+
.is_api_response(true)
|
204
|
+
.convertor(ApiResponse.method(:create)))
|
205
|
+
.execute
|
302
206
|
end
|
303
207
|
|
304
208
|
# Retrieves the loyalty program in a seller's account, specified by the
|
@@ -313,34 +217,19 @@ module Square
|
|
313
217
|
# single loyalty program that belongs to the seller.
|
314
218
|
# @return [RetrieveLoyaltyProgramResponse Hash] response from the API call
|
315
219
|
def retrieve_loyalty_program(program_id:)
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
# Prepare and execute HttpRequest.
|
331
|
-
_request = config.http_client.get(
|
332
|
-
_query_url,
|
333
|
-
headers: _headers
|
334
|
-
)
|
335
|
-
OAuth2.apply(config, _request)
|
336
|
-
_response = execute_request(_request)
|
337
|
-
|
338
|
-
# Return appropriate response type.
|
339
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
340
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
341
|
-
ApiResponse.new(
|
342
|
-
_response, data: decoded, errors: _errors
|
343
|
-
)
|
220
|
+
new_api_call_builder
|
221
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
222
|
+
'/v2/loyalty/programs/{program_id}',
|
223
|
+
'default')
|
224
|
+
.template_param(new_parameter(program_id, key: 'program_id')
|
225
|
+
.should_encode(true))
|
226
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
227
|
+
.auth(Single.new('global')))
|
228
|
+
.response(new_response_handler
|
229
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
230
|
+
.is_api_response(true)
|
231
|
+
.convertor(ApiResponse.method(:create)))
|
232
|
+
.execute
|
344
233
|
end
|
345
234
|
|
346
235
|
# Calculates the number of points a buyer can earn from a purchase.
|
@@ -376,36 +265,22 @@ module Square
|
|
376
265
|
# @return [CalculateLoyaltyPointsResponse Hash] response from the API call
|
377
266
|
def calculate_loyalty_points(program_id:,
|
378
267
|
body:)
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
_request = config.http_client.post(
|
396
|
-
_query_url,
|
397
|
-
headers: _headers,
|
398
|
-
parameters: body.to_json
|
399
|
-
)
|
400
|
-
OAuth2.apply(config, _request)
|
401
|
-
_response = execute_request(_request)
|
402
|
-
|
403
|
-
# Return appropriate response type.
|
404
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
405
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
406
|
-
ApiResponse.new(
|
407
|
-
_response, data: decoded, errors: _errors
|
408
|
-
)
|
268
|
+
new_api_call_builder
|
269
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
270
|
+
'/v2/loyalty/programs/{program_id}/calculate',
|
271
|
+
'default')
|
272
|
+
.template_param(new_parameter(program_id, key: 'program_id')
|
273
|
+
.should_encode(true))
|
274
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
275
|
+
.body_param(new_parameter(body))
|
276
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
277
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
278
|
+
.auth(Single.new('global')))
|
279
|
+
.response(new_response_handler
|
280
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
281
|
+
.is_api_response(true)
|
282
|
+
.convertor(ApiResponse.method(:create)))
|
283
|
+
.execute
|
409
284
|
end
|
410
285
|
|
411
286
|
# Lists the loyalty promotions associated with a [loyalty
|
@@ -436,40 +311,22 @@ module Square
|
|
436
311
|
status: nil,
|
437
312
|
cursor: nil,
|
438
313
|
limit: nil)
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
_headers = {
|
456
|
-
'accept' => 'application/json'
|
457
|
-
}
|
458
|
-
|
459
|
-
# Prepare and execute HttpRequest.
|
460
|
-
_request = config.http_client.get(
|
461
|
-
_query_url,
|
462
|
-
headers: _headers
|
463
|
-
)
|
464
|
-
OAuth2.apply(config, _request)
|
465
|
-
_response = execute_request(_request)
|
466
|
-
|
467
|
-
# Return appropriate response type.
|
468
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
469
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
470
|
-
ApiResponse.new(
|
471
|
-
_response, data: decoded, errors: _errors
|
472
|
-
)
|
314
|
+
new_api_call_builder
|
315
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
316
|
+
'/v2/loyalty/programs/{program_id}/promotions',
|
317
|
+
'default')
|
318
|
+
.template_param(new_parameter(program_id, key: 'program_id')
|
319
|
+
.should_encode(true))
|
320
|
+
.query_param(new_parameter(status, key: 'status'))
|
321
|
+
.query_param(new_parameter(cursor, key: 'cursor'))
|
322
|
+
.query_param(new_parameter(limit, key: 'limit'))
|
323
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
324
|
+
.auth(Single.new('global')))
|
325
|
+
.response(new_response_handler
|
326
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
327
|
+
.is_api_response(true)
|
328
|
+
.convertor(ApiResponse.method(:create)))
|
329
|
+
.execute
|
473
330
|
end
|
474
331
|
|
475
332
|
# Creates a loyalty promotion for a [loyalty program]($m/LoyaltyProgram). A
|
@@ -492,36 +349,22 @@ module Square
|
|
492
349
|
# @return [CreateLoyaltyPromotionResponse Hash] response from the API call
|
493
350
|
def create_loyalty_promotion(program_id:,
|
494
351
|
body:)
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
_request = config.http_client.post(
|
512
|
-
_query_url,
|
513
|
-
headers: _headers,
|
514
|
-
parameters: body.to_json
|
515
|
-
)
|
516
|
-
OAuth2.apply(config, _request)
|
517
|
-
_response = execute_request(_request)
|
518
|
-
|
519
|
-
# Return appropriate response type.
|
520
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
521
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
522
|
-
ApiResponse.new(
|
523
|
-
_response, data: decoded, errors: _errors
|
524
|
-
)
|
352
|
+
new_api_call_builder
|
353
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
354
|
+
'/v2/loyalty/programs/{program_id}/promotions',
|
355
|
+
'default')
|
356
|
+
.template_param(new_parameter(program_id, key: 'program_id')
|
357
|
+
.should_encode(true))
|
358
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
359
|
+
.body_param(new_parameter(body))
|
360
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
361
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
362
|
+
.auth(Single.new('global')))
|
363
|
+
.response(new_response_handler
|
364
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
365
|
+
.is_api_response(true)
|
366
|
+
.convertor(ApiResponse.method(:create)))
|
367
|
+
.execute
|
525
368
|
end
|
526
369
|
|
527
370
|
# Retrieves a loyalty promotion.
|
@@ -534,35 +377,21 @@ module Square
|
|
534
377
|
# @return [RetrieveLoyaltyPromotionResponse Hash] response from the API call
|
535
378
|
def retrieve_loyalty_promotion(promotion_id:,
|
536
379
|
program_id:)
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
# Prepare and execute HttpRequest.
|
553
|
-
_request = config.http_client.get(
|
554
|
-
_query_url,
|
555
|
-
headers: _headers
|
556
|
-
)
|
557
|
-
OAuth2.apply(config, _request)
|
558
|
-
_response = execute_request(_request)
|
559
|
-
|
560
|
-
# Return appropriate response type.
|
561
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
562
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
563
|
-
ApiResponse.new(
|
564
|
-
_response, data: decoded, errors: _errors
|
565
|
-
)
|
380
|
+
new_api_call_builder
|
381
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
382
|
+
'/v2/loyalty/programs/{program_id}/promotions/{promotion_id}',
|
383
|
+
'default')
|
384
|
+
.template_param(new_parameter(promotion_id, key: 'promotion_id')
|
385
|
+
.should_encode(true))
|
386
|
+
.template_param(new_parameter(program_id, key: 'program_id')
|
387
|
+
.should_encode(true))
|
388
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
389
|
+
.auth(Single.new('global')))
|
390
|
+
.response(new_response_handler
|
391
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
392
|
+
.is_api_response(true)
|
393
|
+
.convertor(ApiResponse.method(:create)))
|
394
|
+
.execute
|
566
395
|
end
|
567
396
|
|
568
397
|
# Cancels a loyalty promotion. Use this endpoint to cancel an `ACTIVE`
|
@@ -581,35 +410,21 @@ module Square
|
|
581
410
|
# @return [CancelLoyaltyPromotionResponse Hash] response from the API call
|
582
411
|
def cancel_loyalty_promotion(promotion_id:,
|
583
412
|
program_id:)
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
# Prepare and execute HttpRequest.
|
600
|
-
_request = config.http_client.post(
|
601
|
-
_query_url,
|
602
|
-
headers: _headers
|
603
|
-
)
|
604
|
-
OAuth2.apply(config, _request)
|
605
|
-
_response = execute_request(_request)
|
606
|
-
|
607
|
-
# Return appropriate response type.
|
608
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
609
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
610
|
-
ApiResponse.new(
|
611
|
-
_response, data: decoded, errors: _errors
|
612
|
-
)
|
413
|
+
new_api_call_builder
|
414
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
415
|
+
'/v2/loyalty/programs/{program_id}/promotions/{promotion_id}/cancel',
|
416
|
+
'default')
|
417
|
+
.template_param(new_parameter(promotion_id, key: 'promotion_id')
|
418
|
+
.should_encode(true))
|
419
|
+
.template_param(new_parameter(program_id, key: 'program_id')
|
420
|
+
.should_encode(true))
|
421
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
422
|
+
.auth(Single.new('global')))
|
423
|
+
.response(new_response_handler
|
424
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
425
|
+
.is_api_response(true)
|
426
|
+
.convertor(ApiResponse.method(:create)))
|
427
|
+
.execute
|
613
428
|
end
|
614
429
|
|
615
430
|
# Creates a loyalty reward. In the process, the endpoint does following:
|
@@ -625,32 +440,20 @@ module Square
|
|
625
440
|
# object definition for field details.
|
626
441
|
# @return [CreateLoyaltyRewardResponse Hash] response from the API call
|
627
442
|
def create_loyalty_reward(body:)
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
headers: _headers,
|
643
|
-
parameters: body.to_json
|
644
|
-
)
|
645
|
-
OAuth2.apply(config, _request)
|
646
|
-
_response = execute_request(_request)
|
647
|
-
|
648
|
-
# Return appropriate response type.
|
649
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
650
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
651
|
-
ApiResponse.new(
|
652
|
-
_response, data: decoded, errors: _errors
|
653
|
-
)
|
443
|
+
new_api_call_builder
|
444
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
445
|
+
'/v2/loyalty/rewards',
|
446
|
+
'default')
|
447
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
448
|
+
.body_param(new_parameter(body))
|
449
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
450
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
451
|
+
.auth(Single.new('global')))
|
452
|
+
.response(new_response_handler
|
453
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
454
|
+
.is_api_response(true)
|
455
|
+
.convertor(ApiResponse.method(:create)))
|
456
|
+
.execute
|
654
457
|
end
|
655
458
|
|
656
459
|
# Searches for loyalty rewards. This endpoint accepts a request with no
|
@@ -665,32 +468,20 @@ module Square
|
|
665
468
|
# object definition for field details.
|
666
469
|
# @return [SearchLoyaltyRewardsResponse Hash] response from the API call
|
667
470
|
def search_loyalty_rewards(body:)
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
headers: _headers,
|
683
|
-
parameters: body.to_json
|
684
|
-
)
|
685
|
-
OAuth2.apply(config, _request)
|
686
|
-
_response = execute_request(_request)
|
687
|
-
|
688
|
-
# Return appropriate response type.
|
689
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
690
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
691
|
-
ApiResponse.new(
|
692
|
-
_response, data: decoded, errors: _errors
|
693
|
-
)
|
471
|
+
new_api_call_builder
|
472
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
473
|
+
'/v2/loyalty/rewards/search',
|
474
|
+
'default')
|
475
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
476
|
+
.body_param(new_parameter(body))
|
477
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
478
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
479
|
+
.auth(Single.new('global')))
|
480
|
+
.response(new_response_handler
|
481
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
482
|
+
.is_api_response(true)
|
483
|
+
.convertor(ApiResponse.method(:create)))
|
484
|
+
.execute
|
694
485
|
end
|
695
486
|
|
696
487
|
# Deletes a loyalty reward by doing the following:
|
@@ -704,34 +495,19 @@ module Square
|
|
704
495
|
# reward]($m/LoyaltyReward) to delete.
|
705
496
|
# @return [DeleteLoyaltyRewardResponse Hash] response from the API call
|
706
497
|
def delete_loyalty_reward(reward_id:)
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
# Prepare and execute HttpRequest.
|
722
|
-
_request = config.http_client.delete(
|
723
|
-
_query_url,
|
724
|
-
headers: _headers
|
725
|
-
)
|
726
|
-
OAuth2.apply(config, _request)
|
727
|
-
_response = execute_request(_request)
|
728
|
-
|
729
|
-
# Return appropriate response type.
|
730
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
731
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
732
|
-
ApiResponse.new(
|
733
|
-
_response, data: decoded, errors: _errors
|
734
|
-
)
|
498
|
+
new_api_call_builder
|
499
|
+
.request(new_request_builder(HttpMethodEnum::DELETE,
|
500
|
+
'/v2/loyalty/rewards/{reward_id}',
|
501
|
+
'default')
|
502
|
+
.template_param(new_parameter(reward_id, key: 'reward_id')
|
503
|
+
.should_encode(true))
|
504
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
505
|
+
.auth(Single.new('global')))
|
506
|
+
.response(new_response_handler
|
507
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
508
|
+
.is_api_response(true)
|
509
|
+
.convertor(ApiResponse.method(:create)))
|
510
|
+
.execute
|
735
511
|
end
|
736
512
|
|
737
513
|
# Retrieves a loyalty reward.
|
@@ -739,34 +515,19 @@ module Square
|
|
739
515
|
# reward]($m/LoyaltyReward) to retrieve.
|
740
516
|
# @return [RetrieveLoyaltyRewardResponse Hash] response from the API call
|
741
517
|
def retrieve_loyalty_reward(reward_id:)
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
# Prepare and execute HttpRequest.
|
757
|
-
_request = config.http_client.get(
|
758
|
-
_query_url,
|
759
|
-
headers: _headers
|
760
|
-
)
|
761
|
-
OAuth2.apply(config, _request)
|
762
|
-
_response = execute_request(_request)
|
763
|
-
|
764
|
-
# Return appropriate response type.
|
765
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
766
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
767
|
-
ApiResponse.new(
|
768
|
-
_response, data: decoded, errors: _errors
|
769
|
-
)
|
518
|
+
new_api_call_builder
|
519
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
520
|
+
'/v2/loyalty/rewards/{reward_id}',
|
521
|
+
'default')
|
522
|
+
.template_param(new_parameter(reward_id, key: 'reward_id')
|
523
|
+
.should_encode(true))
|
524
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
525
|
+
.auth(Single.new('global')))
|
526
|
+
.response(new_response_handler
|
527
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
528
|
+
.is_api_response(true)
|
529
|
+
.convertor(ApiResponse.method(:create)))
|
530
|
+
.execute
|
770
531
|
end
|
771
532
|
|
772
533
|
# Redeems a loyalty reward.
|
@@ -785,36 +546,22 @@ module Square
|
|
785
546
|
# @return [RedeemLoyaltyRewardResponse Hash] response from the API call
|
786
547
|
def redeem_loyalty_reward(reward_id:,
|
787
548
|
body:)
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
_request = config.http_client.post(
|
805
|
-
_query_url,
|
806
|
-
headers: _headers,
|
807
|
-
parameters: body.to_json
|
808
|
-
)
|
809
|
-
OAuth2.apply(config, _request)
|
810
|
-
_response = execute_request(_request)
|
811
|
-
|
812
|
-
# Return appropriate response type.
|
813
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
814
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
815
|
-
ApiResponse.new(
|
816
|
-
_response, data: decoded, errors: _errors
|
817
|
-
)
|
549
|
+
new_api_call_builder
|
550
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
551
|
+
'/v2/loyalty/rewards/{reward_id}/redeem',
|
552
|
+
'default')
|
553
|
+
.template_param(new_parameter(reward_id, key: 'reward_id')
|
554
|
+
.should_encode(true))
|
555
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
556
|
+
.body_param(new_parameter(body))
|
557
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
558
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
559
|
+
.auth(Single.new('global')))
|
560
|
+
.response(new_response_handler
|
561
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
562
|
+
.is_api_response(true)
|
563
|
+
.convertor(ApiResponse.method(:create)))
|
564
|
+
.execute
|
818
565
|
end
|
819
566
|
end
|
820
567
|
end
|