square.rb 26.1.0.20230119 → 26.2.0.20230315
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/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
|
# SubscriptionsApi
|
3
3
|
class SubscriptionsApi < 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 subscription to a subscription plan by a customer.
|
9
5
|
# If you provide a card on file in the request, Square charges the card for
|
10
6
|
# the subscription. Otherwise, Square bills an invoice to the customer's
|
@@ -17,32 +13,20 @@ module Square
|
|
17
13
|
# object definition for field details.
|
18
14
|
# @return [CreateSubscriptionResponse Hash] response from the API call
|
19
15
|
def create_subscription(body:)
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
headers: _headers,
|
35
|
-
parameters: body.to_json
|
36
|
-
)
|
37
|
-
OAuth2.apply(config, _request)
|
38
|
-
_response = execute_request(_request)
|
39
|
-
|
40
|
-
# Return appropriate response type.
|
41
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
42
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
43
|
-
ApiResponse.new(
|
44
|
-
_response, data: decoded, errors: _errors
|
45
|
-
)
|
16
|
+
new_api_call_builder
|
17
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
18
|
+
'/v2/subscriptions',
|
19
|
+
'default')
|
20
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
21
|
+
.body_param(new_parameter(body))
|
22
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
23
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
24
|
+
.auth(Single.new('global')))
|
25
|
+
.response(new_response_handler
|
26
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
27
|
+
.is_api_response(true)
|
28
|
+
.convertor(ApiResponse.method(:create)))
|
29
|
+
.execute
|
46
30
|
end
|
47
31
|
|
48
32
|
# Searches for subscriptions.
|
@@ -67,32 +51,20 @@ module Square
|
|
67
51
|
# object definition for field details.
|
68
52
|
# @return [SearchSubscriptionsResponse Hash] response from the API call
|
69
53
|
def search_subscriptions(body:)
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
headers: _headers,
|
85
|
-
parameters: body.to_json
|
86
|
-
)
|
87
|
-
OAuth2.apply(config, _request)
|
88
|
-
_response = execute_request(_request)
|
89
|
-
|
90
|
-
# Return appropriate response type.
|
91
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
92
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
93
|
-
ApiResponse.new(
|
94
|
-
_response, data: decoded, errors: _errors
|
95
|
-
)
|
54
|
+
new_api_call_builder
|
55
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
56
|
+
'/v2/subscriptions/search',
|
57
|
+
'default')
|
58
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
59
|
+
.body_param(new_parameter(body))
|
60
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
61
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
62
|
+
.auth(Single.new('global')))
|
63
|
+
.response(new_response_handler
|
64
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
65
|
+
.is_api_response(true)
|
66
|
+
.convertor(ApiResponse.method(:create)))
|
67
|
+
.execute
|
96
68
|
end
|
97
69
|
|
98
70
|
# Retrieves a subscription.
|
@@ -105,38 +77,20 @@ module Square
|
|
105
77
|
# @return [RetrieveSubscriptionResponse Hash] response from the API call
|
106
78
|
def retrieve_subscription(subscription_id:,
|
107
79
|
include: nil)
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
_headers = {
|
123
|
-
'accept' => 'application/json'
|
124
|
-
}
|
125
|
-
|
126
|
-
# Prepare and execute HttpRequest.
|
127
|
-
_request = config.http_client.get(
|
128
|
-
_query_url,
|
129
|
-
headers: _headers
|
130
|
-
)
|
131
|
-
OAuth2.apply(config, _request)
|
132
|
-
_response = execute_request(_request)
|
133
|
-
|
134
|
-
# Return appropriate response type.
|
135
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
136
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
137
|
-
ApiResponse.new(
|
138
|
-
_response, data: decoded, errors: _errors
|
139
|
-
)
|
80
|
+
new_api_call_builder
|
81
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
82
|
+
'/v2/subscriptions/{subscription_id}',
|
83
|
+
'default')
|
84
|
+
.template_param(new_parameter(subscription_id, key: 'subscription_id')
|
85
|
+
.should_encode(true))
|
86
|
+
.query_param(new_parameter(include, key: 'include'))
|
87
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
88
|
+
.auth(Single.new('global')))
|
89
|
+
.response(new_response_handler
|
90
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
91
|
+
.is_api_response(true)
|
92
|
+
.convertor(ApiResponse.method(:create)))
|
93
|
+
.execute
|
140
94
|
end
|
141
95
|
|
142
96
|
# Updates a subscription. You can set, modify, and clear the
|
@@ -149,36 +103,22 @@ module Square
|
|
149
103
|
# @return [UpdateSubscriptionResponse Hash] response from the API call
|
150
104
|
def update_subscription(subscription_id:,
|
151
105
|
body:)
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
_request = config.http_client.put(
|
169
|
-
_query_url,
|
170
|
-
headers: _headers,
|
171
|
-
parameters: body.to_json
|
172
|
-
)
|
173
|
-
OAuth2.apply(config, _request)
|
174
|
-
_response = execute_request(_request)
|
175
|
-
|
176
|
-
# Return appropriate response type.
|
177
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
178
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
179
|
-
ApiResponse.new(
|
180
|
-
_response, data: decoded, errors: _errors
|
181
|
-
)
|
106
|
+
new_api_call_builder
|
107
|
+
.request(new_request_builder(HttpMethodEnum::PUT,
|
108
|
+
'/v2/subscriptions/{subscription_id}',
|
109
|
+
'default')
|
110
|
+
.template_param(new_parameter(subscription_id, key: 'subscription_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
|
182
122
|
end
|
183
123
|
|
184
124
|
# Deletes a scheduled action for a subscription.
|
@@ -189,35 +129,21 @@ module Square
|
|
189
129
|
# @return [DeleteSubscriptionActionResponse Hash] response from the API call
|
190
130
|
def delete_subscription_action(subscription_id:,
|
191
131
|
action_id:)
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
# Prepare and execute HttpRequest.
|
208
|
-
_request = config.http_client.delete(
|
209
|
-
_query_url,
|
210
|
-
headers: _headers
|
211
|
-
)
|
212
|
-
OAuth2.apply(config, _request)
|
213
|
-
_response = execute_request(_request)
|
214
|
-
|
215
|
-
# Return appropriate response type.
|
216
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
217
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
218
|
-
ApiResponse.new(
|
219
|
-
_response, data: decoded, errors: _errors
|
220
|
-
)
|
132
|
+
new_api_call_builder
|
133
|
+
.request(new_request_builder(HttpMethodEnum::DELETE,
|
134
|
+
'/v2/subscriptions/{subscription_id}/actions/{action_id}',
|
135
|
+
'default')
|
136
|
+
.template_param(new_parameter(subscription_id, key: 'subscription_id')
|
137
|
+
.should_encode(true))
|
138
|
+
.template_param(new_parameter(action_id, key: 'action_id')
|
139
|
+
.should_encode(true))
|
140
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
141
|
+
.auth(Single.new('global')))
|
142
|
+
.response(new_response_handler
|
143
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
144
|
+
.is_api_response(true)
|
145
|
+
.convertor(ApiResponse.method(:create)))
|
146
|
+
.execute
|
221
147
|
end
|
222
148
|
|
223
149
|
# Schedules a `CANCEL` action to cancel an active subscription
|
@@ -229,41 +155,26 @@ module Square
|
|
229
155
|
# subscription to cancel.
|
230
156
|
# @return [CancelSubscriptionResponse Hash] response from the API call
|
231
157
|
def cancel_subscription(subscription_id:)
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
# Prepare and execute HttpRequest.
|
247
|
-
_request = config.http_client.post(
|
248
|
-
_query_url,
|
249
|
-
headers: _headers
|
250
|
-
)
|
251
|
-
OAuth2.apply(config, _request)
|
252
|
-
_response = execute_request(_request)
|
253
|
-
|
254
|
-
# Return appropriate response type.
|
255
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
256
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
257
|
-
ApiResponse.new(
|
258
|
-
_response, data: decoded, errors: _errors
|
259
|
-
)
|
158
|
+
new_api_call_builder
|
159
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
160
|
+
'/v2/subscriptions/{subscription_id}/cancel',
|
161
|
+
'default')
|
162
|
+
.template_param(new_parameter(subscription_id, key: 'subscription_id')
|
163
|
+
.should_encode(true))
|
164
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
165
|
+
.auth(Single.new('global')))
|
166
|
+
.response(new_response_handler
|
167
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
168
|
+
.is_api_response(true)
|
169
|
+
.convertor(ApiResponse.method(:create)))
|
170
|
+
.execute
|
260
171
|
end
|
261
172
|
|
262
173
|
# Lists all events for a specific subscription.
|
263
174
|
# @param [String] subscription_id Required parameter: The ID of the
|
264
175
|
# subscription to retrieve the events for.
|
265
176
|
# @param [String] cursor Optional parameter: When the total number of
|
266
|
-
# resulting subscription events exceeds the limit of a paged response,
|
177
|
+
# resulting subscription events exceeds the limit of a paged response,
|
267
178
|
# specify the cursor returned from a preceding response here to fetch the
|
268
179
|
# next set of results. If the cursor is unset, the response contains the
|
269
180
|
# last page of the results. For more information, see
|
@@ -275,39 +186,21 @@ module Square
|
|
275
186
|
def list_subscription_events(subscription_id:,
|
276
187
|
cursor: nil,
|
277
188
|
limit: nil)
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
_headers = {
|
294
|
-
'accept' => 'application/json'
|
295
|
-
}
|
296
|
-
|
297
|
-
# Prepare and execute HttpRequest.
|
298
|
-
_request = config.http_client.get(
|
299
|
-
_query_url,
|
300
|
-
headers: _headers
|
301
|
-
)
|
302
|
-
OAuth2.apply(config, _request)
|
303
|
-
_response = execute_request(_request)
|
304
|
-
|
305
|
-
# Return appropriate response type.
|
306
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
307
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
308
|
-
ApiResponse.new(
|
309
|
-
_response, data: decoded, errors: _errors
|
310
|
-
)
|
189
|
+
new_api_call_builder
|
190
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
191
|
+
'/v2/subscriptions/{subscription_id}/events',
|
192
|
+
'default')
|
193
|
+
.template_param(new_parameter(subscription_id, key: 'subscription_id')
|
194
|
+
.should_encode(true))
|
195
|
+
.query_param(new_parameter(cursor, key: 'cursor'))
|
196
|
+
.query_param(new_parameter(limit, key: 'limit'))
|
197
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
198
|
+
.auth(Single.new('global')))
|
199
|
+
.response(new_response_handler
|
200
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
201
|
+
.is_api_response(true)
|
202
|
+
.convertor(ApiResponse.method(:create)))
|
203
|
+
.execute
|
311
204
|
end
|
312
205
|
|
313
206
|
# Schedules a `PAUSE` action to pause an active subscription.
|
@@ -319,36 +212,22 @@ module Square
|
|
319
212
|
# @return [PauseSubscriptionResponse Hash] response from the API call
|
320
213
|
def pause_subscription(subscription_id:,
|
321
214
|
body:)
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
_request = config.http_client.post(
|
339
|
-
_query_url,
|
340
|
-
headers: _headers,
|
341
|
-
parameters: body.to_json
|
342
|
-
)
|
343
|
-
OAuth2.apply(config, _request)
|
344
|
-
_response = execute_request(_request)
|
345
|
-
|
346
|
-
# Return appropriate response type.
|
347
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
348
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
349
|
-
ApiResponse.new(
|
350
|
-
_response, data: decoded, errors: _errors
|
351
|
-
)
|
215
|
+
new_api_call_builder
|
216
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
217
|
+
'/v2/subscriptions/{subscription_id}/pause',
|
218
|
+
'default')
|
219
|
+
.template_param(new_parameter(subscription_id, key: 'subscription_id')
|
220
|
+
.should_encode(true))
|
221
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
222
|
+
.body_param(new_parameter(body))
|
223
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
224
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
225
|
+
.auth(Single.new('global')))
|
226
|
+
.response(new_response_handler
|
227
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
228
|
+
.is_api_response(true)
|
229
|
+
.convertor(ApiResponse.method(:create)))
|
230
|
+
.execute
|
352
231
|
end
|
353
232
|
|
354
233
|
# Schedules a `RESUME` action to resume a paused or a deactivated
|
@@ -361,36 +240,22 @@ module Square
|
|
361
240
|
# @return [ResumeSubscriptionResponse Hash] response from the API call
|
362
241
|
def resume_subscription(subscription_id:,
|
363
242
|
body:)
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
_request = config.http_client.post(
|
381
|
-
_query_url,
|
382
|
-
headers: _headers,
|
383
|
-
parameters: body.to_json
|
384
|
-
)
|
385
|
-
OAuth2.apply(config, _request)
|
386
|
-
_response = execute_request(_request)
|
387
|
-
|
388
|
-
# Return appropriate response type.
|
389
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
390
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
391
|
-
ApiResponse.new(
|
392
|
-
_response, data: decoded, errors: _errors
|
393
|
-
)
|
243
|
+
new_api_call_builder
|
244
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
245
|
+
'/v2/subscriptions/{subscription_id}/resume',
|
246
|
+
'default')
|
247
|
+
.template_param(new_parameter(subscription_id, key: 'subscription_id')
|
248
|
+
.should_encode(true))
|
249
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
250
|
+
.body_param(new_parameter(body))
|
251
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
252
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
253
|
+
.auth(Single.new('global')))
|
254
|
+
.response(new_response_handler
|
255
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
256
|
+
.is_api_response(true)
|
257
|
+
.convertor(ApiResponse.method(:create)))
|
258
|
+
.execute
|
394
259
|
end
|
395
260
|
|
396
261
|
# Schedules a `SWAP_PLAN` action to swap a subscription plan in an existing
|
@@ -403,36 +268,22 @@ module Square
|
|
403
268
|
# @return [SwapPlanResponse Hash] response from the API call
|
404
269
|
def swap_plan(subscription_id:,
|
405
270
|
body:)
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
_request = config.http_client.post(
|
423
|
-
_query_url,
|
424
|
-
headers: _headers,
|
425
|
-
parameters: body.to_json
|
426
|
-
)
|
427
|
-
OAuth2.apply(config, _request)
|
428
|
-
_response = execute_request(_request)
|
429
|
-
|
430
|
-
# Return appropriate response type.
|
431
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
432
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
433
|
-
ApiResponse.new(
|
434
|
-
_response, data: decoded, errors: _errors
|
435
|
-
)
|
271
|
+
new_api_call_builder
|
272
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
273
|
+
'/v2/subscriptions/{subscription_id}/swap-plan',
|
274
|
+
'default')
|
275
|
+
.template_param(new_parameter(subscription_id, key: 'subscription_id')
|
276
|
+
.should_encode(true))
|
277
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
278
|
+
.body_param(new_parameter(body))
|
279
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
280
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
281
|
+
.auth(Single.new('global')))
|
282
|
+
.response(new_response_handler
|
283
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
284
|
+
.is_api_response(true)
|
285
|
+
.convertor(ApiResponse.method(:create)))
|
286
|
+
.execute
|
436
287
|
end
|
437
288
|
end
|
438
289
|
end
|