square.rb 6.3.0.20200826 → 17.1.0.20220120
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/LICENSE +1 -1
- data/README.md +86 -51
- data/lib/square/api/apple_pay_api.rb +12 -9
- data/lib/square/api/bank_accounts_api.rb +21 -24
- data/lib/square/api/base_api.rb +20 -9
- data/lib/square/api/bookings_api.rb +391 -0
- data/lib/square/api/cards_api.rb +170 -0
- data/lib/square/api/cash_drawers_api.rb +13 -6
- data/lib/square/api/catalog_api.rb +195 -85
- data/lib/square/api/checkout_api.rb +7 -5
- data/lib/square/api/customer_groups_api.rb +34 -16
- data/lib/square/api/customer_segments_api.rb +21 -9
- data/lib/square/api/customers_api.rb +102 -55
- data/lib/square/api/devices_api.rb +20 -8
- data/lib/square/api/disputes_api.rb +156 -144
- data/lib/square/api/employees_api.rb +7 -3
- data/lib/square/api/gift_card_activities_api.rb +133 -0
- data/lib/square/api/gift_cards_api.rb +297 -0
- data/lib/square/api/inventory_api.rb +290 -37
- data/lib/square/api/invoices_api.rb +61 -57
- data/lib/square/api/labor_api.rb +127 -93
- data/lib/square/api/locations_api.rb +36 -25
- data/lib/square/api/loyalty_api.rb +134 -87
- data/lib/square/api/merchants_api.rb +8 -4
- data/lib/square/api/mobile_authorization_api.rb +9 -7
- data/lib/square/api/o_auth_api.rb +41 -32
- data/lib/square/api/orders_api.rb +132 -54
- data/lib/square/api/payments_api.rb +133 -75
- data/lib/square/api/refunds_api.rb +51 -30
- data/lib/square/api/sites_api.rb +43 -0
- data/lib/square/api/snippets_api.rb +146 -0
- data/lib/square/api/subscriptions_api.rb +216 -26
- data/lib/square/api/team_api.rb +81 -65
- data/lib/square/api/terminal_api.rb +166 -16
- data/lib/square/api/transactions_api.rb +32 -194
- data/lib/square/api/v1_transactions_api.rb +53 -103
- data/lib/square/api_helper.rb +38 -43
- data/lib/square/client.rb +54 -24
- data/lib/square/configuration.rb +61 -21
- data/lib/square/http/api_response.rb +3 -1
- data/lib/square/http/faraday_client.rb +34 -5
- data/lib/square/utilities/date_time_helper.rb +151 -0
- data/lib/square/utilities/file_wrapper.rb +1 -2
- data/lib/square.rb +65 -61
- 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 +21 -35
- 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 +1 -6
- metadata +40 -18
- data/lib/square/api/v1_employees_api.rb +0 -723
- data/lib/square/api/v1_items_api.rb +0 -1686
- data/lib/square/api/v1_locations_api.rb +0 -65
@@ -0,0 +1,146 @@
|
|
1
|
+
module Square
|
2
|
+
# SnippetsApi
|
3
|
+
class SnippetsApi < BaseApi
|
4
|
+
def initialize(config, http_call_back: nil)
|
5
|
+
super(config, http_call_back: http_call_back)
|
6
|
+
end
|
7
|
+
|
8
|
+
# Removes your snippet from a Square Online site.
|
9
|
+
# You can call [ListSites]($e/Sites/ListSites) to get the IDs of the sites
|
10
|
+
# that belong to a seller.
|
11
|
+
# __Note:__ Square Online APIs are publicly available as part of an early
|
12
|
+
# access program. For more information, see [Early access program for Square
|
13
|
+
# Online
|
14
|
+
# APIs](https://developer.squareup.com/docs/online-api#early-access-program-
|
15
|
+
# for-square-online-apis).
|
16
|
+
# @param [String] site_id Required parameter: The ID of the site that
|
17
|
+
# contains the snippet.
|
18
|
+
# @return [DeleteSnippetResponse Hash] response from the API call
|
19
|
+
def delete_snippet(site_id:)
|
20
|
+
# Prepare query url.
|
21
|
+
_query_builder = config.get_base_uri
|
22
|
+
_query_builder << '/v2/sites/{site_id}/snippet'
|
23
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
24
|
+
_query_builder,
|
25
|
+
'site_id' => { 'value' => site_id, 'encode' => true }
|
26
|
+
)
|
27
|
+
_query_url = APIHelper.clean_url _query_builder
|
28
|
+
|
29
|
+
# Prepare headers.
|
30
|
+
_headers = {
|
31
|
+
'accept' => 'application/json'
|
32
|
+
}
|
33
|
+
|
34
|
+
# Prepare and execute HttpRequest.
|
35
|
+
_request = config.http_client.delete(
|
36
|
+
_query_url,
|
37
|
+
headers: _headers
|
38
|
+
)
|
39
|
+
OAuth2.apply(config, _request)
|
40
|
+
_response = execute_request(_request)
|
41
|
+
|
42
|
+
# Return appropriate response type.
|
43
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
44
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
45
|
+
ApiResponse.new(
|
46
|
+
_response, data: decoded, errors: _errors
|
47
|
+
)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Retrieves your snippet from a Square Online site. A site can contain
|
51
|
+
# snippets from multiple snippet applications, but you can retrieve only the
|
52
|
+
# snippet that was added by your application.
|
53
|
+
# You can call [ListSites]($e/Sites/ListSites) to get the IDs of the sites
|
54
|
+
# that belong to a seller.
|
55
|
+
# __Note:__ Square Online APIs are publicly available as part of an early
|
56
|
+
# access program. For more information, see [Early access program for Square
|
57
|
+
# Online
|
58
|
+
# APIs](https://developer.squareup.com/docs/online-api#early-access-program-
|
59
|
+
# for-square-online-apis).
|
60
|
+
# @param [String] site_id Required parameter: The ID of the site that
|
61
|
+
# contains the snippet.
|
62
|
+
# @return [RetrieveSnippetResponse Hash] response from the API call
|
63
|
+
def retrieve_snippet(site_id:)
|
64
|
+
# Prepare query url.
|
65
|
+
_query_builder = config.get_base_uri
|
66
|
+
_query_builder << '/v2/sites/{site_id}/snippet'
|
67
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
68
|
+
_query_builder,
|
69
|
+
'site_id' => { 'value' => site_id, 'encode' => true }
|
70
|
+
)
|
71
|
+
_query_url = APIHelper.clean_url _query_builder
|
72
|
+
|
73
|
+
# Prepare headers.
|
74
|
+
_headers = {
|
75
|
+
'accept' => 'application/json'
|
76
|
+
}
|
77
|
+
|
78
|
+
# Prepare and execute HttpRequest.
|
79
|
+
_request = config.http_client.get(
|
80
|
+
_query_url,
|
81
|
+
headers: _headers
|
82
|
+
)
|
83
|
+
OAuth2.apply(config, _request)
|
84
|
+
_response = execute_request(_request)
|
85
|
+
|
86
|
+
# Return appropriate response type.
|
87
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
88
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
89
|
+
ApiResponse.new(
|
90
|
+
_response, data: decoded, errors: _errors
|
91
|
+
)
|
92
|
+
end
|
93
|
+
|
94
|
+
# Adds a snippet to a Square Online site or updates the existing snippet on
|
95
|
+
# the site.
|
96
|
+
# The snippet code is appended to the end of the `head` element on every
|
97
|
+
# page of the site, except checkout pages. A snippet application can add one
|
98
|
+
# snippet to a given site.
|
99
|
+
# You can call [ListSites]($e/Sites/ListSites) to get the IDs of the sites
|
100
|
+
# that belong to a seller.
|
101
|
+
# __Note:__ Square Online APIs are publicly available as part of an early
|
102
|
+
# access program. For more information, see [Early access program for Square
|
103
|
+
# Online
|
104
|
+
# APIs](https://developer.squareup.com/docs/online-api#early-access-program-
|
105
|
+
# for-square-online-apis).
|
106
|
+
# @param [String] site_id Required parameter: The ID of the site where you
|
107
|
+
# want to add or update the snippet.
|
108
|
+
# @param [UpsertSnippetRequest] body Required parameter: An object
|
109
|
+
# containing the fields to POST for the request. See the corresponding
|
110
|
+
# object definition for field details.
|
111
|
+
# @return [UpsertSnippetResponse Hash] response from the API call
|
112
|
+
def upsert_snippet(site_id:,
|
113
|
+
body:)
|
114
|
+
# Prepare query url.
|
115
|
+
_query_builder = config.get_base_uri
|
116
|
+
_query_builder << '/v2/sites/{site_id}/snippet'
|
117
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
118
|
+
_query_builder,
|
119
|
+
'site_id' => { 'value' => site_id, 'encode' => true }
|
120
|
+
)
|
121
|
+
_query_url = APIHelper.clean_url _query_builder
|
122
|
+
|
123
|
+
# Prepare headers.
|
124
|
+
_headers = {
|
125
|
+
'accept' => 'application/json',
|
126
|
+
'Content-Type' => 'application/json'
|
127
|
+
}
|
128
|
+
|
129
|
+
# Prepare and execute HttpRequest.
|
130
|
+
_request = config.http_client.post(
|
131
|
+
_query_url,
|
132
|
+
headers: _headers,
|
133
|
+
parameters: body.to_json
|
134
|
+
)
|
135
|
+
OAuth2.apply(config, _request)
|
136
|
+
_response = execute_request(_request)
|
137
|
+
|
138
|
+
# Return appropriate response type.
|
139
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
140
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
141
|
+
ApiResponse.new(
|
142
|
+
_response, data: decoded, errors: _errors
|
143
|
+
)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
@@ -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
|
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
|
-
'
|
28
|
+
'Content-Type' => 'application/json'
|
29
29
|
}
|
30
30
|
|
31
31
|
# Prepare and execute HttpRequest.
|
@@ -40,7 +40,9 @@ module Square
|
|
40
40
|
# Return appropriate response type.
|
41
41
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
42
42
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
43
|
-
ApiResponse.new(
|
43
|
+
ApiResponse.new(
|
44
|
+
_response, data: decoded, errors: _errors
|
45
|
+
)
|
44
46
|
end
|
45
47
|
|
46
48
|
# Searches for subscriptions.
|
@@ -58,8 +60,8 @@ module Square
|
|
58
60
|
# customer by subscription creation date.
|
59
61
|
# For more information, see
|
60
62
|
# [Retrieve
|
61
|
-
# subscriptions](https://developer.squareup.com/docs/
|
62
|
-
#
|
63
|
+
# subscriptions](https://developer.squareup.com/docs/subscriptions-api/overv
|
64
|
+
# iew#retrieve-subscriptions).
|
63
65
|
# @param [SearchSubscriptionsRequest] body Required parameter: An object
|
64
66
|
# containing the fields to POST for the request. See the corresponding
|
65
67
|
# object definition for field details.
|
@@ -73,7 +75,7 @@ module Square
|
|
73
75
|
# Prepare headers.
|
74
76
|
_headers = {
|
75
77
|
'accept' => 'application/json',
|
76
|
-
'
|
78
|
+
'Content-Type' => 'application/json'
|
77
79
|
}
|
78
80
|
|
79
81
|
# Prepare and execute HttpRequest.
|
@@ -88,20 +90,31 @@ module Square
|
|
88
90
|
# Return appropriate response type.
|
89
91
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
90
92
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
91
|
-
ApiResponse.new(
|
93
|
+
ApiResponse.new(
|
94
|
+
_response, data: decoded, errors: _errors
|
95
|
+
)
|
92
96
|
end
|
93
97
|
|
94
98
|
# Retrieves a subscription.
|
95
99
|
# @param [String] subscription_id Required parameter: The ID of the
|
96
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.
|
97
105
|
# @return [RetrieveSubscriptionResponse Hash] response from the API call
|
98
|
-
def retrieve_subscription(subscription_id
|
106
|
+
def retrieve_subscription(subscription_id:,
|
107
|
+
include: nil)
|
99
108
|
# Prepare query url.
|
100
109
|
_query_builder = config.get_base_uri
|
101
110
|
_query_builder << '/v2/subscriptions/{subscription_id}'
|
102
111
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
103
112
|
_query_builder,
|
104
|
-
'subscription_id' => subscription_id
|
113
|
+
'subscription_id' => { 'value' => subscription_id, 'encode' => true }
|
114
|
+
)
|
115
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
116
|
+
_query_builder,
|
117
|
+
'include' => include
|
105
118
|
)
|
106
119
|
_query_url = APIHelper.clean_url _query_builder
|
107
120
|
|
@@ -121,12 +134,14 @@ module Square
|
|
121
134
|
# Return appropriate response type.
|
122
135
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
123
136
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
124
|
-
ApiResponse.new(
|
137
|
+
ApiResponse.new(
|
138
|
+
_response, data: decoded, errors: _errors
|
139
|
+
)
|
125
140
|
end
|
126
141
|
|
127
142
|
# Updates a subscription. You can set, modify, and clear the
|
128
143
|
# `subscription` field values.
|
129
|
-
# @param [String] subscription_id Required parameter: The ID
|
144
|
+
# @param [String] subscription_id Required parameter: The ID of the
|
130
145
|
# subscription to update.
|
131
146
|
# @param [UpdateSubscriptionRequest] body Required parameter: An object
|
132
147
|
# containing the fields to POST for the request. See the corresponding
|
@@ -139,14 +154,14 @@ module Square
|
|
139
154
|
_query_builder << '/v2/subscriptions/{subscription_id}'
|
140
155
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
141
156
|
_query_builder,
|
142
|
-
'subscription_id' => subscription_id
|
157
|
+
'subscription_id' => { 'value' => subscription_id, 'encode' => true }
|
143
158
|
)
|
144
159
|
_query_url = APIHelper.clean_url _query_builder
|
145
160
|
|
146
161
|
# Prepare headers.
|
147
162
|
_headers = {
|
148
163
|
'accept' => 'application/json',
|
149
|
-
'
|
164
|
+
'Content-Type' => 'application/json'
|
150
165
|
}
|
151
166
|
|
152
167
|
# Prepare and execute HttpRequest.
|
@@ -161,11 +176,55 @@ module Square
|
|
161
176
|
# Return appropriate response type.
|
162
177
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
163
178
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
164
|
-
ApiResponse.new(
|
179
|
+
ApiResponse.new(
|
180
|
+
_response, data: decoded, errors: _errors
|
181
|
+
)
|
165
182
|
end
|
166
183
|
|
167
|
-
#
|
168
|
-
#
|
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.
|
169
228
|
# @param [String] subscription_id Required parameter: The ID of the
|
170
229
|
# subscription to cancel.
|
171
230
|
# @return [CancelSubscriptionResponse Hash] response from the API call
|
@@ -175,7 +234,7 @@ module Square
|
|
175
234
|
_query_builder << '/v2/subscriptions/{subscription_id}/cancel'
|
176
235
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
177
236
|
_query_builder,
|
178
|
-
'subscription_id' => subscription_id
|
237
|
+
'subscription_id' => { 'value' => subscription_id, 'encode' => true }
|
179
238
|
)
|
180
239
|
_query_url = APIHelper.clean_url _query_builder
|
181
240
|
|
@@ -195,7 +254,9 @@ module Square
|
|
195
254
|
# Return appropriate response type.
|
196
255
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
197
256
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
198
|
-
ApiResponse.new(
|
257
|
+
ApiResponse.new(
|
258
|
+
_response, data: decoded, errors: _errors
|
259
|
+
)
|
199
260
|
end
|
200
261
|
|
201
262
|
# Lists all events for a specific subscription.
|
@@ -204,13 +265,15 @@ module Square
|
|
204
265
|
# returned.
|
205
266
|
# @param [String] subscription_id Required parameter: The ID of the
|
206
267
|
# subscription to retrieve the events for.
|
207
|
-
# @param [String] cursor Optional parameter:
|
208
|
-
#
|
209
|
-
#
|
210
|
-
#
|
211
|
-
#
|
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
|
273
|
+
# [Pagination](https://developer.squareup.com/docs/working-with-apis/paginat
|
274
|
+
# ion).
|
212
275
|
# @param [Integer] limit Optional parameter: The upper limit on the number
|
213
|
-
# of subscription events to return
|
276
|
+
# of subscription events to return in a paged response.
|
214
277
|
# @return [ListSubscriptionEventsResponse Hash] response from the API call
|
215
278
|
def list_subscription_events(subscription_id:,
|
216
279
|
cursor: nil,
|
@@ -220,7 +283,7 @@ module Square
|
|
220
283
|
_query_builder << '/v2/subscriptions/{subscription_id}/events'
|
221
284
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
222
285
|
_query_builder,
|
223
|
-
'subscription_id' => subscription_id
|
286
|
+
'subscription_id' => { 'value' => subscription_id, 'encode' => true }
|
224
287
|
)
|
225
288
|
_query_builder = APIHelper.append_url_with_query_parameters(
|
226
289
|
_query_builder,
|
@@ -245,7 +308,134 @@ module Square
|
|
245
308
|
# Return appropriate response type.
|
246
309
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
247
310
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
248
|
-
ApiResponse.new(
|
311
|
+
ApiResponse.new(
|
312
|
+
_response, data: decoded, errors: _errors
|
313
|
+
)
|
314
|
+
end
|
315
|
+
|
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.
|
359
|
+
# @param [String] subscription_id Required parameter: The ID of the
|
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.
|
364
|
+
# @return [ResumeSubscriptionResponse Hash] response from the API call
|
365
|
+
def resume_subscription(subscription_id:,
|
366
|
+
body:)
|
367
|
+
# Prepare query url.
|
368
|
+
_query_builder = config.get_base_uri
|
369
|
+
_query_builder << '/v2/subscriptions/{subscription_id}/resume'
|
370
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
371
|
+
_query_builder,
|
372
|
+
'subscription_id' => { 'value' => subscription_id, 'encode' => true }
|
373
|
+
)
|
374
|
+
_query_url = APIHelper.clean_url _query_builder
|
375
|
+
|
376
|
+
# Prepare headers.
|
377
|
+
_headers = {
|
378
|
+
'accept' => 'application/json',
|
379
|
+
'Content-Type' => 'application/json'
|
380
|
+
}
|
381
|
+
|
382
|
+
# Prepare and execute HttpRequest.
|
383
|
+
_request = config.http_client.post(
|
384
|
+
_query_url,
|
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
|
429
|
+
)
|
430
|
+
OAuth2.apply(config, _request)
|
431
|
+
_response = execute_request(_request)
|
432
|
+
|
433
|
+
# Return appropriate response type.
|
434
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
435
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
436
|
+
ApiResponse.new(
|
437
|
+
_response, data: decoded, errors: _errors
|
438
|
+
)
|
249
439
|
end
|
250
440
|
end
|
251
441
|
end
|