square.rb 13.0.0.20210721 → 16.0.0.20211117

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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/README.md +38 -21
  4. data/lib/square/api/apple_pay_api.rb +1 -1
  5. data/lib/square/api/base_api.rb +5 -9
  6. data/lib/square/api/bookings_api.rb +64 -4
  7. data/lib/square/api/cards_api.rb +1 -1
  8. data/lib/square/api/catalog_api.rb +10 -10
  9. data/lib/square/api/checkout_api.rb +1 -1
  10. data/lib/square/api/customer_groups_api.rb +12 -4
  11. data/lib/square/api/customer_segments_api.rb +10 -2
  12. data/lib/square/api/customers_api.rb +15 -7
  13. data/lib/square/api/devices_api.rb +1 -1
  14. data/lib/square/api/disputes_api.rb +1 -1
  15. data/lib/square/api/gift_card_activities_api.rb +26 -20
  16. data/lib/square/api/gift_cards_api.rb +32 -26
  17. data/lib/square/api/inventory_api.rb +6 -6
  18. data/lib/square/api/invoices_api.rb +5 -5
  19. data/lib/square/api/labor_api.rb +70 -68
  20. data/lib/square/api/locations_api.rb +2 -2
  21. data/lib/square/api/loyalty_api.rb +9 -9
  22. data/lib/square/api/mobile_authorization_api.rb +1 -1
  23. data/lib/square/api/o_auth_api.rb +22 -15
  24. data/lib/square/api/orders_api.rb +43 -6
  25. data/lib/square/api/payments_api.rb +12 -6
  26. data/lib/square/api/refunds_api.rb +1 -1
  27. data/lib/square/api/sites_api.rb +2 -1
  28. data/lib/square/api/snippets_api.rb +1 -1
  29. data/lib/square/api/subscriptions_api.rb +159 -16
  30. data/lib/square/api/team_api.rb +6 -6
  31. data/lib/square/api/terminal_api.rb +4 -4
  32. data/lib/square/api/transactions_api.rb +0 -188
  33. data/lib/square/api/v1_transactions_api.rb +2 -2
  34. data/lib/square/api_helper.rb +19 -17
  35. data/lib/square/client.rb +6 -11
  36. data/lib/square/configuration.rb +19 -20
  37. data/lib/square/http/api_response.rb +1 -1
  38. data/lib/square/http/faraday_client.rb +21 -2
  39. data/lib/square/utilities/date_time_helper.rb +2 -2
  40. data/lib/square/utilities/file_wrapper.rb +1 -2
  41. data/lib/square.rb +48 -49
  42. metadata +11 -9
  43. data/lib/square/api/v1_employees_api.rb +0 -362
@@ -20,7 +20,7 @@ module Square
20
20
  # Prepare headers.
21
21
  _headers = {
22
22
  'accept' => 'application/json',
23
- 'content-type' => 'application/json; charset=utf-8'
23
+ 'Content-Type' => 'application/json'
24
24
  }
25
25
 
26
26
  # Prepare and execute HttpRequest.
@@ -58,7 +58,7 @@ module Square
58
58
  # Prepare headers.
59
59
  _headers = {
60
60
  'accept' => 'application/json',
61
- 'content-type' => 'application/json; charset=utf-8'
61
+ 'Content-Type' => 'application/json'
62
62
  }
63
63
 
64
64
  # Prepare and execute HttpRequest.
@@ -150,7 +150,7 @@ module Square
150
150
  # Prepare headers.
151
151
  _headers = {
152
152
  'accept' => 'application/json',
153
- 'content-type' => 'application/json; charset=utf-8'
153
+ 'Content-Type' => 'application/json'
154
154
  }
155
155
 
156
156
  # Prepare and execute HttpRequest.
@@ -195,7 +195,7 @@ module Square
195
195
  # Prepare headers.
196
196
  _headers = {
197
197
  'accept' => 'application/json',
198
- 'content-type' => 'application/json; charset=utf-8'
198
+ 'Content-Type' => 'application/json'
199
199
  }
200
200
 
201
201
  # Prepare and execute HttpRequest.
@@ -236,7 +236,7 @@ module Square
236
236
  # Prepare headers.
237
237
  _headers = {
238
238
  'accept' => 'application/json',
239
- 'content-type' => 'application/json; charset=utf-8'
239
+ 'Content-Type' => 'application/json'
240
240
  }
241
241
 
242
242
  # Prepare and execute HttpRequest.
@@ -372,7 +372,7 @@ module Square
372
372
  # Prepare headers.
373
373
  _headers = {
374
374
  'accept' => 'application/json',
375
- 'content-type' => 'application/json; charset=utf-8'
375
+ 'Content-Type' => 'application/json'
376
376
  }
377
377
 
378
378
  # Prepare and execute HttpRequest.
@@ -413,7 +413,7 @@ module Square
413
413
  # Prepare headers.
414
414
  _headers = {
415
415
  'accept' => 'application/json',
416
- 'content-type' => 'application/json; charset=utf-8'
416
+ 'Content-Type' => 'application/json'
417
417
  }
418
418
 
419
419
  # Prepare and execute HttpRequest.
@@ -452,7 +452,7 @@ module Square
452
452
  # Prepare headers.
453
453
  _headers = {
454
454
  'accept' => 'application/json',
455
- 'content-type' => 'application/json; charset=utf-8'
455
+ 'Content-Type' => 'application/json'
456
456
  }
457
457
 
458
458
  # Prepare and execute HttpRequest.
@@ -576,7 +576,7 @@ module Square
576
576
  # Prepare headers.
577
577
  _headers = {
578
578
  'accept' => 'application/json',
579
- 'content-type' => 'application/json; charset=utf-8'
579
+ 'Content-Type' => 'application/json'
580
580
  }
581
581
 
582
582
  # Prepare and execute HttpRequest.
@@ -31,7 +31,7 @@ module Square
31
31
  # Prepare headers.
32
32
  _headers = {
33
33
  'accept' => 'application/json',
34
- 'content-type' => 'application/json; charset=utf-8'
34
+ 'Content-Type' => 'application/json'
35
35
  }
36
36
 
37
37
  # Prepare and execute HttpRequest.
@@ -27,8 +27,8 @@ module Square
27
27
  # Credentials
28
28
  # page in the [developer dashboard](https://developer.squareup.com/apps).
29
29
  # @param [String] client_id Required parameter: Your application ID,
30
- # available from the [developer
31
- # dashboard](https://developer.squareup.com/apps).
30
+ # available from the OAuth page for your application on the Developer
31
+ # Dashboard.
32
32
  # @param [RenewTokenRequest] body Required parameter: An object containing
33
33
  # the fields to POST for the request. See the corresponding object
34
34
  # definition for field details.
@@ -51,7 +51,7 @@ module Square
51
51
  # Prepare headers.
52
52
  _headers = {
53
53
  'accept' => 'application/json',
54
- 'content-type' => 'application/json; charset=utf-8',
54
+ 'Content-Type' => 'application/json',
55
55
  'Authorization' => authorization
56
56
  }
57
57
 
@@ -84,7 +84,7 @@ module Square
84
84
  # Authorization: Client APPLICATION_SECRET
85
85
  # ```
86
86
  # Replace `APPLICATION_SECRET` with the application secret on the OAuth
87
- # page in the [developer dashboard](https://developer.squareup.com/apps).
87
+ # page for your application on the Developer Dashboard.
88
88
  # @param [RevokeTokenRequest] body Required parameter: An object containing
89
89
  # the fields to POST for the request. See the corresponding object
90
90
  # definition for field details.
@@ -101,7 +101,7 @@ module Square
101
101
  # Prepare headers.
102
102
  _headers = {
103
103
  'accept' => 'application/json',
104
- 'content-type' => 'application/json; charset=utf-8',
104
+ 'Content-Type' => 'application/json',
105
105
  'Authorization' => authorization
106
106
  }
107
107
 
@@ -121,15 +121,22 @@ module Square
121
121
  )
122
122
  end
123
123
 
124
- # Returns an OAuth access token.
125
- # The endpoint supports distinct methods of obtaining OAuth access tokens.
126
- # Applications specify a method by adding the `grant_type` parameter
127
- # in the request and also provide relevant information.
128
- # __Note:__ Regardless of the method application specified,
129
- # the endpoint always returns two items; an OAuth access token and
130
- # a refresh token in the response.
131
- # __OAuth tokens should only live on secure servers. Application clients
132
- # should never interact directly with OAuth tokens__.
124
+ # Returns an OAuth access token and a refresh token unless the
125
+ # `short_lived` parameter is set to `true`, in which case the endpoint
126
+ # returns only an access token.
127
+ # The `grant_type` parameter specifies the type of OAuth request. If
128
+ # `grant_type` is `authorization_code`, you must include the authorization
129
+ # code you received when a seller granted you authorization. If `grant_type`
130
+ # is `refresh_token`, you must provide a valid refresh token. If you are
131
+ # using
132
+ # an old version of the Square APIs (prior to March 13, 2019), `grant_type`
133
+ # can be `migration_token` and you must provide a valid migration token.
134
+ # You can use the `scopes` parameter to limit the set of permissions granted
135
+ # to the access token and refresh token. You can use the `short_lived`
136
+ # parameter
137
+ # to create an access token that expires in 24 hours.
138
+ # __Note:__ OAuth tokens should be encrypted and stored on a secure server.
139
+ # Application clients should never interact directly with OAuth tokens.
133
140
  # @param [ObtainTokenRequest] body Required parameter: An object containing
134
141
  # the fields to POST for the request. See the corresponding object
135
142
  # definition for field details.
@@ -143,7 +150,7 @@ module Square
143
150
  # Prepare headers.
144
151
  _headers = {
145
152
  'accept' => 'application/json',
146
- 'content-type' => 'application/json; charset=utf-8'
153
+ 'Content-Type' => 'application/json'
147
154
  }
148
155
 
149
156
  # Prepare and execute HttpRequest.
@@ -26,7 +26,7 @@ module Square
26
26
  # Prepare headers.
27
27
  _headers = {
28
28
  'accept' => 'application/json',
29
- 'content-type' => 'application/json; charset=utf-8'
29
+ 'Content-Type' => 'application/json'
30
30
  }
31
31
 
32
32
  # Prepare and execute HttpRequest.
@@ -62,7 +62,7 @@ module Square
62
62
  # Prepare headers.
63
63
  _headers = {
64
64
  'accept' => 'application/json',
65
- 'content-type' => 'application/json; charset=utf-8'
65
+ 'Content-Type' => 'application/json'
66
66
  }
67
67
 
68
68
  # Prepare and execute HttpRequest.
@@ -96,7 +96,44 @@ module Square
96
96
  # Prepare headers.
97
97
  _headers = {
98
98
  'accept' => 'application/json',
99
- 'content-type' => 'application/json; charset=utf-8'
99
+ 'Content-Type' => 'application/json'
100
+ }
101
+
102
+ # Prepare and execute HttpRequest.
103
+ _request = config.http_client.post(
104
+ _query_url,
105
+ headers: _headers,
106
+ parameters: body.to_json
107
+ )
108
+ OAuth2.apply(config, _request)
109
+ _response = execute_request(_request)
110
+
111
+ # Return appropriate response type.
112
+ decoded = APIHelper.json_deserialize(_response.raw_body)
113
+ _errors = APIHelper.map_response(decoded, ['errors'])
114
+ ApiResponse.new(
115
+ _response, data: decoded, errors: _errors
116
+ )
117
+ end
118
+
119
+ # Creates a new order, in the `DRAFT` state, by duplicating an existing
120
+ # order. The newly created order has
121
+ # only the core fields (such as line items, taxes, and discounts) copied
122
+ # from the original order.
123
+ # @param [CloneOrderRequest] body Required parameter: An object containing
124
+ # the fields to POST for the request. See the corresponding object
125
+ # definition for field details.
126
+ # @return [CloneOrderResponse Hash] response from the API call
127
+ def clone_order(body:)
128
+ # Prepare query url.
129
+ _query_builder = config.get_base_uri
130
+ _query_builder << '/v2/orders/clone'
131
+ _query_url = APIHelper.clean_url _query_builder
132
+
133
+ # Prepare headers.
134
+ _headers = {
135
+ 'accept' => 'application/json',
136
+ 'Content-Type' => 'application/json'
100
137
  }
101
138
 
102
139
  # Prepare and execute HttpRequest.
@@ -146,7 +183,7 @@ module Square
146
183
  # Prepare headers.
147
184
  _headers = {
148
185
  'accept' => 'application/json',
149
- 'content-type' => 'application/json; charset=utf-8'
186
+ 'Content-Type' => 'application/json'
150
187
  }
151
188
 
152
189
  # Prepare and execute HttpRequest.
@@ -239,7 +276,7 @@ module Square
239
276
  # Prepare headers.
240
277
  _headers = {
241
278
  'accept' => 'application/json',
242
- 'content-type' => 'application/json; charset=utf-8'
279
+ 'Content-Type' => 'application/json'
243
280
  }
244
281
 
245
282
  # Prepare and execute HttpRequest.
@@ -298,7 +335,7 @@ module Square
298
335
  # Prepare headers.
299
336
  _headers = {
300
337
  'accept' => 'application/json',
301
- 'content-type' => 'application/json; charset=utf-8'
338
+ 'Content-Type' => 'application/json'
302
339
  }
303
340
 
304
341
  # Prepare and execute HttpRequest.
@@ -107,7 +107,7 @@ module Square
107
107
  # Prepare headers.
108
108
  _headers = {
109
109
  'accept' => 'application/json',
110
- 'content-type' => 'application/json; charset=utf-8'
110
+ 'Content-Type' => 'application/json'
111
111
  }
112
112
 
113
113
  # Prepare and execute HttpRequest.
@@ -155,7 +155,7 @@ module Square
155
155
  # Prepare headers.
156
156
  _headers = {
157
157
  'accept' => 'application/json',
158
- 'content-type' => 'application/json; charset=utf-8'
158
+ 'Content-Type' => 'application/json'
159
159
  }
160
160
 
161
161
  # Prepare and execute HttpRequest.
@@ -232,7 +232,7 @@ module Square
232
232
  # Prepare headers.
233
233
  _headers = {
234
234
  'accept' => 'application/json',
235
- 'content-type' => 'application/json; charset=utf-8'
235
+ 'Content-Type' => 'application/json'
236
236
  }
237
237
 
238
238
  # Prepare and execute HttpRequest.
@@ -296,8 +296,12 @@ module Square
296
296
  # `status`.
297
297
  # @param [String] payment_id Required parameter: The unique ID identifying
298
298
  # the payment to be completed.
299
+ # @param [CompletePaymentRequest] body Required parameter: An object
300
+ # containing the fields to POST for the request. See the corresponding
301
+ # object definition for field details.
299
302
  # @return [CompletePaymentResponse Hash] response from the API call
300
- def complete_payment(payment_id:)
303
+ def complete_payment(payment_id:,
304
+ body:)
301
305
  # Prepare query url.
302
306
  _query_builder = config.get_base_uri
303
307
  _query_builder << '/v2/payments/{payment_id}/complete'
@@ -309,13 +313,15 @@ module Square
309
313
 
310
314
  # Prepare headers.
311
315
  _headers = {
312
- 'accept' => 'application/json'
316
+ 'accept' => 'application/json',
317
+ 'Content-Type' => 'application/json'
313
318
  }
314
319
 
315
320
  # Prepare and execute HttpRequest.
316
321
  _request = config.http_client.post(
317
322
  _query_url,
318
- headers: _headers
323
+ headers: _headers,
324
+ parameters: body.to_json
319
325
  )
320
326
  OAuth2.apply(config, _request)
321
327
  _response = execute_request(_request)
@@ -105,7 +105,7 @@ module Square
105
105
  # Prepare headers.
106
106
  _headers = {
107
107
  'accept' => 'application/json',
108
- 'content-type' => 'application/json; charset=utf-8'
108
+ 'Content-Type' => 'application/json'
109
109
  }
110
110
 
111
111
  # Prepare and execute HttpRequest.
@@ -5,7 +5,8 @@ module Square
5
5
  super(config, http_call_back: http_call_back)
6
6
  end
7
7
 
8
- # Lists the Square Online sites that belong to a seller.
8
+ # Lists the Square Online sites that belong to a seller. Sites are listed in
9
+ # descending order by the `created_at` date.
9
10
  # __Note:__ Square Online APIs are publicly available as part of an early
10
11
  # access program. For more information, see [Early access program for Square
11
12
  # Online
@@ -123,7 +123,7 @@ module Square
123
123
  # Prepare headers.
124
124
  _headers = {
125
125
  'accept' => 'application/json',
126
- 'content-type' => 'application/json; charset=utf-8'
126
+ 'Content-Type' => 'application/json'
127
127
  }
128
128
 
129
129
  # Prepare and execute HttpRequest.
@@ -5,7 +5,7 @@ module Square
5
5
  super(config, http_call_back: http_call_back)
6
6
  end
7
7
 
8
- # Creates a subscription for a customer to a subscription plan.
8
+ # Creates a subscription to a subscription plan by a customer.
9
9
  # If you provide a card on file in the request, Square charges the card for
10
10
  # the subscription. Otherwise, Square bills an invoice to the customer's
11
11
  # email
@@ -25,7 +25,7 @@ module Square
25
25
  # Prepare headers.
26
26
  _headers = {
27
27
  'accept' => 'application/json',
28
- 'content-type' => 'application/json; charset=utf-8'
28
+ 'Content-Type' => 'application/json'
29
29
  }
30
30
 
31
31
  # Prepare and execute HttpRequest.
@@ -75,7 +75,7 @@ module Square
75
75
  # Prepare headers.
76
76
  _headers = {
77
77
  'accept' => 'application/json',
78
- 'content-type' => 'application/json; charset=utf-8'
78
+ 'Content-Type' => 'application/json'
79
79
  }
80
80
 
81
81
  # Prepare and execute HttpRequest.
@@ -98,8 +98,13 @@ module Square
98
98
  # Retrieves a subscription.
99
99
  # @param [String] subscription_id Required parameter: The ID of the
100
100
  # subscription to retrieve.
101
+ # @param [String] include Optional parameter: A query parameter to specify
102
+ # related information to be included in the response. The supported query
103
+ # parameter values are: - `actions`: to include scheduled actions on the
104
+ # targeted subscription.
101
105
  # @return [RetrieveSubscriptionResponse Hash] response from the API call
102
- def retrieve_subscription(subscription_id:)
106
+ def retrieve_subscription(subscription_id:,
107
+ include: nil)
103
108
  # Prepare query url.
104
109
  _query_builder = config.get_base_uri
105
110
  _query_builder << '/v2/subscriptions/{subscription_id}'
@@ -107,6 +112,10 @@ module Square
107
112
  _query_builder,
108
113
  'subscription_id' => { 'value' => subscription_id, 'encode' => true }
109
114
  )
115
+ _query_builder = APIHelper.append_url_with_query_parameters(
116
+ _query_builder,
117
+ 'include' => include
118
+ )
110
119
  _query_url = APIHelper.clean_url _query_builder
111
120
 
112
121
  # Prepare headers.
@@ -132,7 +141,7 @@ module Square
132
141
 
133
142
  # Updates a subscription. You can set, modify, and clear the
134
143
  # `subscription` field values.
135
- # @param [String] subscription_id Required parameter: The ID for the
144
+ # @param [String] subscription_id Required parameter: The ID of the
136
145
  # subscription to update.
137
146
  # @param [UpdateSubscriptionRequest] body Required parameter: An object
138
147
  # containing the fields to POST for the request. See the corresponding
@@ -152,7 +161,7 @@ module Square
152
161
  # Prepare headers.
153
162
  _headers = {
154
163
  'accept' => 'application/json',
155
- 'content-type' => 'application/json; charset=utf-8'
164
+ 'Content-Type' => 'application/json'
156
165
  }
157
166
 
158
167
  # Prepare and execute HttpRequest.
@@ -172,8 +181,50 @@ module Square
172
181
  )
173
182
  end
174
183
 
175
- # Sets the `canceled_date` field to the end of the active billing period.
176
- # After this date, the status changes from ACTIVE to CANCELED.
184
+ # Deletes a scheduled action for a subscription.
185
+ # @param [String] subscription_id Required parameter: The ID of the
186
+ # subscription the targeted action is to act upon.
187
+ # @param [String] action_id Required parameter: The ID of the targeted
188
+ # action to be deleted.
189
+ # @return [DeleteSubscriptionActionResponse Hash] response from the API call
190
+ def delete_subscription_action(subscription_id:,
191
+ action_id:)
192
+ # Prepare query url.
193
+ _query_builder = config.get_base_uri
194
+ _query_builder << '/v2/subscriptions/{subscription_id}/actions/{action_id}'
195
+ _query_builder = APIHelper.append_url_with_template_parameters(
196
+ _query_builder,
197
+ 'subscription_id' => { 'value' => subscription_id, 'encode' => true },
198
+ 'action_id' => { 'value' => action_id, 'encode' => true }
199
+ )
200
+ _query_url = APIHelper.clean_url _query_builder
201
+
202
+ # Prepare headers.
203
+ _headers = {
204
+ 'accept' => 'application/json'
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
+ )
221
+ end
222
+
223
+ # Schedules a `CANCEL` action to cancel an active subscription
224
+ # by setting the `canceled_date` field to the end of the active billing
225
+ # period
226
+ # and changing the subscription status from ACTIVE to CANCELED after this
227
+ # date.
177
228
  # @param [String] subscription_id Required parameter: The ID of the
178
229
  # subscription to cancel.
179
230
  # @return [CancelSubscriptionResponse Hash] response from the API call
@@ -214,13 +265,15 @@ module Square
214
265
  # returned.
215
266
  # @param [String] subscription_id Required parameter: The ID of the
216
267
  # subscription to retrieve the events for.
217
- # @param [String] cursor Optional parameter: A pagination cursor returned by
218
- # a previous call to this endpoint. Provide this to retrieve the next set of
219
- # results for the original query. For more information, see
268
+ # @param [String] cursor Optional parameter: When the total number of
269
+ # resulting subscription events exceeds the limit of a paged response,
270
+ # specify the cursor returned from a preceding response here to fetch the
271
+ # next set of results. If the cursor is unset, the response contains the
272
+ # last page of the results. For more information, see
220
273
  # [Pagination](https://developer.squareup.com/docs/working-with-apis/paginat
221
274
  # ion).
222
275
  # @param [Integer] limit Optional parameter: The upper limit on the number
223
- # of subscription events to return in the response. Default: `200`
276
+ # of subscription events to return in a paged response.
224
277
  # @return [ListSubscriptionEventsResponse Hash] response from the API call
225
278
  def list_subscription_events(subscription_id:,
226
279
  cursor: nil,
@@ -260,11 +313,57 @@ module Square
260
313
  )
261
314
  end
262
315
 
263
- # Resumes a deactivated subscription.
316
+ # Schedules a `PAUSE` action to pause an active subscription.
317
+ # @param [String] subscription_id Required parameter: The ID of the
318
+ # subscription to pause.
319
+ # @param [PauseSubscriptionRequest] body Required parameter: An object
320
+ # containing the fields to POST for the request. See the corresponding
321
+ # object definition for field details.
322
+ # @return [PauseSubscriptionResponse Hash] response from the API call
323
+ def pause_subscription(subscription_id:,
324
+ body:)
325
+ # Prepare query url.
326
+ _query_builder = config.get_base_uri
327
+ _query_builder << '/v2/subscriptions/{subscription_id}/pause'
328
+ _query_builder = APIHelper.append_url_with_template_parameters(
329
+ _query_builder,
330
+ 'subscription_id' => { 'value' => subscription_id, 'encode' => true }
331
+ )
332
+ _query_url = APIHelper.clean_url _query_builder
333
+
334
+ # Prepare headers.
335
+ _headers = {
336
+ 'accept' => 'application/json',
337
+ 'Content-Type' => 'application/json'
338
+ }
339
+
340
+ # Prepare and execute HttpRequest.
341
+ _request = config.http_client.post(
342
+ _query_url,
343
+ headers: _headers,
344
+ parameters: body.to_json
345
+ )
346
+ OAuth2.apply(config, _request)
347
+ _response = execute_request(_request)
348
+
349
+ # Return appropriate response type.
350
+ decoded = APIHelper.json_deserialize(_response.raw_body)
351
+ _errors = APIHelper.map_response(decoded, ['errors'])
352
+ ApiResponse.new(
353
+ _response, data: decoded, errors: _errors
354
+ )
355
+ end
356
+
357
+ # Schedules a `RESUME` action to resume a paused or a deactivated
358
+ # subscription.
264
359
  # @param [String] subscription_id Required parameter: The ID of the
265
360
  # subscription to resume.
361
+ # @param [ResumeSubscriptionRequest] body Required parameter: An object
362
+ # containing the fields to POST for the request. See the corresponding
363
+ # object definition for field details.
266
364
  # @return [ResumeSubscriptionResponse Hash] response from the API call
267
- def resume_subscription(subscription_id:)
365
+ def resume_subscription(subscription_id:,
366
+ body:)
268
367
  # Prepare query url.
269
368
  _query_builder = config.get_base_uri
270
369
  _query_builder << '/v2/subscriptions/{subscription_id}/resume'
@@ -276,13 +375,57 @@ module Square
276
375
 
277
376
  # Prepare headers.
278
377
  _headers = {
279
- 'accept' => 'application/json'
378
+ 'accept' => 'application/json',
379
+ 'Content-Type' => 'application/json'
280
380
  }
281
381
 
282
382
  # Prepare and execute HttpRequest.
283
383
  _request = config.http_client.post(
284
384
  _query_url,
285
- headers: _headers
385
+ headers: _headers,
386
+ parameters: body.to_json
387
+ )
388
+ OAuth2.apply(config, _request)
389
+ _response = execute_request(_request)
390
+
391
+ # Return appropriate response type.
392
+ decoded = APIHelper.json_deserialize(_response.raw_body)
393
+ _errors = APIHelper.map_response(decoded, ['errors'])
394
+ ApiResponse.new(
395
+ _response, data: decoded, errors: _errors
396
+ )
397
+ end
398
+
399
+ # Schedules a `SWAP_PLAN` action to swap a subscription plan in an existing
400
+ # subscription.
401
+ # @param [String] subscription_id Required parameter: The ID of the
402
+ # subscription to swap the subscription plan for.
403
+ # @param [SwapPlanRequest] body Required parameter: An object containing the
404
+ # fields to POST for the request. See the corresponding object definition
405
+ # for field details.
406
+ # @return [SwapPlanResponse Hash] response from the API call
407
+ def swap_plan(subscription_id:,
408
+ body:)
409
+ # Prepare query url.
410
+ _query_builder = config.get_base_uri
411
+ _query_builder << '/v2/subscriptions/{subscription_id}/swap-plan'
412
+ _query_builder = APIHelper.append_url_with_template_parameters(
413
+ _query_builder,
414
+ 'subscription_id' => { 'value' => subscription_id, 'encode' => true }
415
+ )
416
+ _query_url = APIHelper.clean_url _query_builder
417
+
418
+ # Prepare headers.
419
+ _headers = {
420
+ 'accept' => 'application/json',
421
+ 'Content-Type' => 'application/json'
422
+ }
423
+
424
+ # Prepare and execute HttpRequest.
425
+ _request = config.http_client.post(
426
+ _query_url,
427
+ headers: _headers,
428
+ parameters: body.to_json
286
429
  )
287
430
  OAuth2.apply(config, _request)
288
431
  _response = execute_request(_request)
@@ -26,7 +26,7 @@ module Square
26
26
  # Prepare headers.
27
27
  _headers = {
28
28
  'accept' => 'application/json',
29
- 'content-type' => 'application/json; charset=utf-8'
29
+ 'Content-Type' => 'application/json'
30
30
  }
31
31
 
32
32
  # Prepare and execute HttpRequest.
@@ -69,7 +69,7 @@ module Square
69
69
  # Prepare headers.
70
70
  _headers = {
71
71
  'accept' => 'application/json',
72
- 'content-type' => 'application/json; charset=utf-8'
72
+ 'Content-Type' => 'application/json'
73
73
  }
74
74
 
75
75
  # Prepare and execute HttpRequest.
@@ -112,7 +112,7 @@ module Square
112
112
  # Prepare headers.
113
113
  _headers = {
114
114
  'accept' => 'application/json',
115
- 'content-type' => 'application/json; charset=utf-8'
115
+ 'Content-Type' => 'application/json'
116
116
  }
117
117
 
118
118
  # Prepare and execute HttpRequest.
@@ -149,7 +149,7 @@ module Square
149
149
  # Prepare headers.
150
150
  _headers = {
151
151
  'accept' => 'application/json',
152
- 'content-type' => 'application/json; charset=utf-8'
152
+ 'Content-Type' => 'application/json'
153
153
  }
154
154
 
155
155
  # Prepare and execute HttpRequest.
@@ -232,7 +232,7 @@ module Square
232
232
  # Prepare headers.
233
233
  _headers = {
234
234
  'accept' => 'application/json',
235
- 'content-type' => 'application/json; charset=utf-8'
235
+ 'Content-Type' => 'application/json'
236
236
  }
237
237
 
238
238
  # Prepare and execute HttpRequest.
@@ -319,7 +319,7 @@ module Square
319
319
  # Prepare headers.
320
320
  _headers = {
321
321
  'accept' => 'application/json',
322
- 'content-type' => 'application/json; charset=utf-8'
322
+ 'Content-Type' => 'application/json'
323
323
  }
324
324
 
325
325
  # Prepare and execute HttpRequest.