square.rb 6.5.0.20201028 → 9.1.0.20210317
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +42 -31
- data/lib/square.rb +1 -2
- data/lib/square/api/apple_pay_api.rb +8 -7
- data/lib/square/api/bank_accounts_api.rb +4 -4
- data/lib/square/api/base_api.rb +1 -1
- data/lib/square/api/bookings_api.rb +308 -0
- data/lib/square/api/cash_drawers_api.rb +2 -1
- data/lib/square/api/catalog_api.rb +24 -10
- data/lib/square/api/checkout_api.rb +2 -2
- data/lib/square/api/customer_segments_api.rb +2 -2
- data/lib/square/api/disputes_api.rb +33 -35
- data/lib/square/api/inventory_api.rb +2 -2
- data/lib/square/api/invoices_api.rb +15 -12
- data/lib/square/api/loyalty_api.rb +1 -1
- data/lib/square/api/mobile_authorization_api.rb +2 -2
- data/lib/square/api/o_auth_api.rb +1 -4
- data/lib/square/api/payments_api.rb +57 -18
- data/lib/square/api/refunds_api.rb +26 -21
- data/lib/square/api/subscriptions_api.rb +4 -4
- data/lib/square/api/team_api.rb +14 -14
- data/lib/square/api/terminal_api.rb +15 -14
- data/lib/square/api/v1_employees_api.rb +0 -394
- data/lib/square/api/v1_transactions_api.rb +2 -83
- data/lib/square/client.rb +10 -14
- data/lib/square/configuration.rb +21 -6
- data/lib/square/http/faraday_client.rb +8 -2
- metadata +4 -5
- data/lib/square/api/v1_items_api.rb +0 -1766
- data/lib/square/api/v1_locations_api.rb +0 -69
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0073c43aaa6518848223c41ea272fa28f77cf58b9ade77aae705423849a37bb3
|
4
|
+
data.tar.gz: 6d1f79d5fd9c6224e3a1b6769faf8c1c7b93b2a98357878a42a816a522d2a0a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d9da7a0178efe277fcacb6ea12c73b4c03aee542edd5ce2791eeda0d97f5e8787d467f1031f260321305c060b0bb59904bab13ecf5218507d2d236c0b5ab945
|
7
|
+
data.tar.gz: 54f48e7dd8de672b7eadc9282e4e1dfb41e8c925a60093b450b94d2e26f7e92859f61b59c7730e65b81b1510ff9bf9affa40b28b4e8a35807e811e2a0a816802
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -56,6 +56,9 @@ gem 'square.rb'
|
|
56
56
|
### Loyalty
|
57
57
|
* [Loyalty]
|
58
58
|
|
59
|
+
### Bookings
|
60
|
+
* [Bookings]
|
61
|
+
|
59
62
|
### Business
|
60
63
|
* [Merchants]
|
61
64
|
* [Locations]
|
@@ -75,7 +78,6 @@ gem 'square.rb'
|
|
75
78
|
* [O Auth]
|
76
79
|
|
77
80
|
### Deprecated APIs
|
78
|
-
* [V1 Locations]
|
79
81
|
* [V1 Employees]
|
80
82
|
* [V1 Transactions]
|
81
83
|
* [V1 Items]
|
@@ -194,6 +196,15 @@ client = Square::Client.new(
|
|
194
196
|
environment: 'production'
|
195
197
|
)
|
196
198
|
```
|
199
|
+
|
200
|
+
- To set a custom environment provide a `custom_url`, and set environment to `custom`:
|
201
|
+
|
202
|
+
```ruby
|
203
|
+
client = Square::Client.new(
|
204
|
+
access_token:'ACCESS TOKEN HERE',
|
205
|
+
environment: 'custom',
|
206
|
+
custom_url: 'https://your.customdomain.com'
|
207
|
+
)
|
197
208
|
|
198
209
|
### Get an Instance of an API object and call its methods
|
199
210
|
|
@@ -286,33 +297,33 @@ You can also use the Square API to create applications or services that work wit
|
|
286
297
|
[Square API]: https://squareup.com/developers
|
287
298
|
[sign up for a developer account]: https://squareup.com/signup?v=developers
|
288
299
|
[Client]: doc/client.md
|
289
|
-
[Devices]: doc/
|
290
|
-
[Disputes]: doc/
|
291
|
-
[Terminal]: doc/
|
292
|
-
[Team]: doc/
|
293
|
-
[Cash Drawers]: doc/
|
294
|
-
[Customer Groups]: doc/
|
295
|
-
[Customer Segments]: doc/
|
296
|
-
[Bank Accounts]: doc/
|
297
|
-
[Payments]: doc/
|
298
|
-
[Checkout]: doc/
|
299
|
-
[Catalog]: doc/
|
300
|
-
[Customers]: doc/
|
301
|
-
[Employees]: doc/
|
302
|
-
[Inventory]: doc/
|
303
|
-
[Labor]: doc/
|
304
|
-
[Loyalty]: doc/
|
305
|
-
[
|
306
|
-
[
|
307
|
-
[
|
308
|
-
[
|
309
|
-
[
|
310
|
-
[
|
311
|
-
[
|
312
|
-
[
|
313
|
-
[
|
314
|
-
[
|
315
|
-
[V1 Employees]: doc/
|
316
|
-
[V1 Transactions]: doc/
|
317
|
-
[V1 Items]: doc/
|
318
|
-
[Transactions]: doc/
|
300
|
+
[Devices]: doc/api/devices.md
|
301
|
+
[Disputes]: doc/api/disputes.md
|
302
|
+
[Terminal]: doc/api/terminal.md
|
303
|
+
[Team]: doc/api/team.md
|
304
|
+
[Cash Drawers]: doc/api/cash-drawers.md
|
305
|
+
[Customer Groups]: doc/api/customer-groups.md
|
306
|
+
[Customer Segments]: doc/api/customer-segments.md
|
307
|
+
[Bank Accounts]: doc/api/bank-accounts.md
|
308
|
+
[Payments]: doc/api/payments.md
|
309
|
+
[Checkout]: doc/api/checkout.md
|
310
|
+
[Catalog]: doc/api/catalog.md
|
311
|
+
[Customers]: doc/api/customers.md
|
312
|
+
[Employees]: doc/api/employees.md
|
313
|
+
[Inventory]: doc/api/inventory.md
|
314
|
+
[Labor]: doc/api/labor.md
|
315
|
+
[Loyalty]: doc/api/loyalty.md
|
316
|
+
[Bookings]: doc/api/bookings.md
|
317
|
+
[Locations]: doc/api/locations.md
|
318
|
+
[Merchants]: doc/api/merchants.md
|
319
|
+
[Orders]: doc/api/orders.md
|
320
|
+
[Invoices]: doc/api/invoices.md
|
321
|
+
[Apple Pay]: doc/api/apple-pay.md
|
322
|
+
[Refunds]: doc/api/refunds.md
|
323
|
+
[Subscriptions]: doc/api/subscriptions.md
|
324
|
+
[Mobile Authorization]: doc/api/mobile-authorization.md
|
325
|
+
[O Auth]: doc/api/o-auth.md
|
326
|
+
[V1 Employees]: doc/api/v1-employees.md
|
327
|
+
[V1 Transactions]: doc/api/v1-transactions.md
|
328
|
+
[V1 Items]: doc/api/v1-items.md
|
329
|
+
[Transactions]: doc/api/transactions.md
|
data/lib/square.rb
CHANGED
@@ -31,12 +31,11 @@ require_relative 'square/configuration.rb'
|
|
31
31
|
require_relative 'square/api/base_api.rb'
|
32
32
|
require_relative 'square/api/mobile_authorization_api.rb'
|
33
33
|
require_relative 'square/api/o_auth_api.rb'
|
34
|
-
require_relative 'square/api/v1_locations_api.rb'
|
35
34
|
require_relative 'square/api/v1_employees_api.rb'
|
36
35
|
require_relative 'square/api/v1_transactions_api.rb'
|
37
|
-
require_relative 'square/api/v1_items_api.rb'
|
38
36
|
require_relative 'square/api/apple_pay_api.rb'
|
39
37
|
require_relative 'square/api/bank_accounts_api.rb'
|
38
|
+
require_relative 'square/api/bookings_api.rb'
|
40
39
|
require_relative 'square/api/cash_drawers_api.rb'
|
41
40
|
require_relative 'square/api/catalog_api.rb'
|
42
41
|
require_relative 'square/api/customers_api.rb'
|
@@ -5,17 +5,18 @@ module Square
|
|
5
5
|
super(config, http_call_back: http_call_back)
|
6
6
|
end
|
7
7
|
|
8
|
-
# Activates a domain for use with
|
9
|
-
#
|
8
|
+
# Activates a domain for use with Apple Pay on the Web and Square. A
|
9
|
+
# validation
|
10
|
+
# is performed on this domain by Apple to ensure that it is properly set up
|
10
11
|
# as
|
11
12
|
# an Apple Pay enabled domain.
|
12
13
|
# This endpoint provides an easy way for platform developers to bulk
|
13
14
|
# activate
|
14
|
-
#
|
15
|
-
# To learn more about
|
16
|
-
# [
|
17
|
-
#
|
18
|
-
# -
|
15
|
+
# Apple Pay on the Web with Square for merchants using their platform.
|
16
|
+
# To learn more about Web Apple Pay, see
|
17
|
+
# [Add the Apple Pay on the Web
|
18
|
+
# Button](https://developer.squareup.com/docs/payment-form/add-digital-walle
|
19
|
+
# ts/apple-pay).
|
19
20
|
# @param [RegisterDomainRequest] body Required parameter: An object
|
20
21
|
# containing the fields to POST for the request. See the corresponding
|
21
22
|
# object definition for field details.
|
@@ -10,8 +10,8 @@ module Square
|
|
10
10
|
# @param [String] cursor Optional parameter: The pagination cursor returned
|
11
11
|
# by a previous call to this endpoint. Use it in the next `ListBankAccounts`
|
12
12
|
# request to retrieve the next set of results. See the
|
13
|
-
# [Pagination](https://developer.squareup.com/docs/
|
14
|
-
#
|
13
|
+
# [Pagination](https://developer.squareup.com/docs/working-with-apis/paginat
|
14
|
+
# ion) guide for more information.
|
15
15
|
# @param [Integer] limit Optional parameter: Upper limit on the number of
|
16
16
|
# bank accounts to return in the response. Currently, 1000 is the largest
|
17
17
|
# supported limit. You can specify a limit of up to 1000 bank accounts.
|
@@ -60,8 +60,8 @@ module Square
|
|
60
60
|
# @param [String] v1_bank_account_id Required parameter: Connect V1 ID of
|
61
61
|
# the desired `BankAccount`. For more information, see [Retrieve a bank
|
62
62
|
# account by using an ID issued by V1 Bank Accounts
|
63
|
-
# API](https://developer.squareup.com/docs/
|
64
|
-
# -
|
63
|
+
# API](https://developer.squareup.com/docs/bank-accounts-api#retrieve-a-bank
|
64
|
+
# -account-by-using-an-id-issued-by-v1-bank-accounts-api).
|
65
65
|
# @return [GetBankAccountByV1IdResponse Hash] response from the API call
|
66
66
|
def get_bank_account_by_v1_id(v1_bank_account_id:)
|
67
67
|
# Prepare query url.
|
data/lib/square/api/base_api.rb
CHANGED
@@ -0,0 +1,308 @@
|
|
1
|
+
module Square
|
2
|
+
# BookingsApi
|
3
|
+
class BookingsApi < BaseApi
|
4
|
+
def initialize(config, http_call_back: nil)
|
5
|
+
super(config, http_call_back: http_call_back)
|
6
|
+
end
|
7
|
+
|
8
|
+
# Creates a booking.
|
9
|
+
# @param [CreateBookingRequest] body Required parameter: An object
|
10
|
+
# containing the fields to POST for the request. See the corresponding
|
11
|
+
# object definition for field details.
|
12
|
+
# @return [CreateBookingResponse Hash] response from the API call
|
13
|
+
def create_booking(body:)
|
14
|
+
# Prepare query url.
|
15
|
+
_query_builder = config.get_base_uri
|
16
|
+
_query_builder << '/v2/bookings'
|
17
|
+
_query_url = APIHelper.clean_url _query_builder
|
18
|
+
|
19
|
+
# Prepare headers.
|
20
|
+
_headers = {
|
21
|
+
'accept' => 'application/json',
|
22
|
+
'content-type' => 'application/json; charset=utf-8'
|
23
|
+
}
|
24
|
+
|
25
|
+
# Prepare and execute HttpRequest.
|
26
|
+
_request = config.http_client.post(
|
27
|
+
_query_url,
|
28
|
+
headers: _headers,
|
29
|
+
parameters: body.to_json
|
30
|
+
)
|
31
|
+
OAuth2.apply(config, _request)
|
32
|
+
_response = execute_request(_request)
|
33
|
+
|
34
|
+
# Return appropriate response type.
|
35
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
36
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
37
|
+
ApiResponse.new(
|
38
|
+
_response, data: decoded, errors: _errors
|
39
|
+
)
|
40
|
+
end
|
41
|
+
|
42
|
+
# Searches for availabilities for booking.
|
43
|
+
# @param [SearchAvailabilityRequest] body Required parameter: An object
|
44
|
+
# containing the fields to POST for the request. See the corresponding
|
45
|
+
# object definition for field details.
|
46
|
+
# @return [SearchAvailabilityResponse Hash] response from the API call
|
47
|
+
def search_availability(body:)
|
48
|
+
# Prepare query url.
|
49
|
+
_query_builder = config.get_base_uri
|
50
|
+
_query_builder << '/v2/bookings/availability/search'
|
51
|
+
_query_url = APIHelper.clean_url _query_builder
|
52
|
+
|
53
|
+
# Prepare headers.
|
54
|
+
_headers = {
|
55
|
+
'accept' => 'application/json',
|
56
|
+
'content-type' => 'application/json; charset=utf-8'
|
57
|
+
}
|
58
|
+
|
59
|
+
# Prepare and execute HttpRequest.
|
60
|
+
_request = config.http_client.post(
|
61
|
+
_query_url,
|
62
|
+
headers: _headers,
|
63
|
+
parameters: body.to_json
|
64
|
+
)
|
65
|
+
OAuth2.apply(config, _request)
|
66
|
+
_response = execute_request(_request)
|
67
|
+
|
68
|
+
# Return appropriate response type.
|
69
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
70
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
71
|
+
ApiResponse.new(
|
72
|
+
_response, data: decoded, errors: _errors
|
73
|
+
)
|
74
|
+
end
|
75
|
+
|
76
|
+
# Retrieves a seller's booking profile.
|
77
|
+
# @return [RetrieveBusinessBookingProfileResponse Hash] response from the API call
|
78
|
+
def retrieve_business_booking_profile
|
79
|
+
# Prepare query url.
|
80
|
+
_query_builder = config.get_base_uri
|
81
|
+
_query_builder << '/v2/bookings/business-booking-profile'
|
82
|
+
_query_url = APIHelper.clean_url _query_builder
|
83
|
+
|
84
|
+
# Prepare headers.
|
85
|
+
_headers = {
|
86
|
+
'accept' => 'application/json'
|
87
|
+
}
|
88
|
+
|
89
|
+
# Prepare and execute HttpRequest.
|
90
|
+
_request = config.http_client.get(
|
91
|
+
_query_url,
|
92
|
+
headers: _headers
|
93
|
+
)
|
94
|
+
OAuth2.apply(config, _request)
|
95
|
+
_response = execute_request(_request)
|
96
|
+
|
97
|
+
# Return appropriate response type.
|
98
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
99
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
100
|
+
ApiResponse.new(
|
101
|
+
_response, data: decoded, errors: _errors
|
102
|
+
)
|
103
|
+
end
|
104
|
+
|
105
|
+
# Lists booking profiles for team members.
|
106
|
+
# @param [Boolean] bookable_only Optional parameter: Indicates whether to
|
107
|
+
# include only bookable team members in the returned result (`true`) or not
|
108
|
+
# (`false`).
|
109
|
+
# @param [Integer] limit Optional parameter: The maximum number of results
|
110
|
+
# to return.
|
111
|
+
# @param [String] cursor Optional parameter: The cursor for paginating
|
112
|
+
# through the results.
|
113
|
+
# @param [String] location_id Optional parameter: Indicates whether to
|
114
|
+
# include only team members enabled at the given location in the returned
|
115
|
+
# result.
|
116
|
+
# @return [ListTeamMemberBookingProfilesResponse Hash] response from the API call
|
117
|
+
def list_team_member_booking_profiles(bookable_only: false,
|
118
|
+
limit: nil,
|
119
|
+
cursor: nil,
|
120
|
+
location_id: nil)
|
121
|
+
# Prepare query url.
|
122
|
+
_query_builder = config.get_base_uri
|
123
|
+
_query_builder << '/v2/bookings/team-member-booking-profiles'
|
124
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
125
|
+
_query_builder,
|
126
|
+
'bookable_only' => bookable_only,
|
127
|
+
'limit' => limit,
|
128
|
+
'cursor' => cursor,
|
129
|
+
'location_id' => location_id
|
130
|
+
)
|
131
|
+
_query_url = APIHelper.clean_url _query_builder
|
132
|
+
|
133
|
+
# Prepare headers.
|
134
|
+
_headers = {
|
135
|
+
'accept' => 'application/json'
|
136
|
+
}
|
137
|
+
|
138
|
+
# Prepare and execute HttpRequest.
|
139
|
+
_request = config.http_client.get(
|
140
|
+
_query_url,
|
141
|
+
headers: _headers
|
142
|
+
)
|
143
|
+
OAuth2.apply(config, _request)
|
144
|
+
_response = execute_request(_request)
|
145
|
+
|
146
|
+
# Return appropriate response type.
|
147
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
148
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
149
|
+
ApiResponse.new(
|
150
|
+
_response, data: decoded, errors: _errors
|
151
|
+
)
|
152
|
+
end
|
153
|
+
|
154
|
+
# Retrieves a team member's booking profile.
|
155
|
+
# @param [String] team_member_id Required parameter: The ID of the team
|
156
|
+
# member to retrieve.
|
157
|
+
# @return [RetrieveTeamMemberBookingProfileResponse Hash] response from the API call
|
158
|
+
def retrieve_team_member_booking_profile(team_member_id:)
|
159
|
+
# Prepare query url.
|
160
|
+
_query_builder = config.get_base_uri
|
161
|
+
_query_builder << '/v2/bookings/team-member-booking-profiles/{team_member_id}'
|
162
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
163
|
+
_query_builder,
|
164
|
+
'team_member_id' => { 'value' => team_member_id, 'encode' => true }
|
165
|
+
)
|
166
|
+
_query_url = APIHelper.clean_url _query_builder
|
167
|
+
|
168
|
+
# Prepare headers.
|
169
|
+
_headers = {
|
170
|
+
'accept' => 'application/json'
|
171
|
+
}
|
172
|
+
|
173
|
+
# Prepare and execute HttpRequest.
|
174
|
+
_request = config.http_client.get(
|
175
|
+
_query_url,
|
176
|
+
headers: _headers
|
177
|
+
)
|
178
|
+
OAuth2.apply(config, _request)
|
179
|
+
_response = execute_request(_request)
|
180
|
+
|
181
|
+
# Return appropriate response type.
|
182
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
183
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
184
|
+
ApiResponse.new(
|
185
|
+
_response, data: decoded, errors: _errors
|
186
|
+
)
|
187
|
+
end
|
188
|
+
|
189
|
+
# Retrieves a booking.
|
190
|
+
# @param [String] booking_id Required parameter: The ID of the
|
191
|
+
# [Booking](#type-booking) object representing the to-be-retrieved
|
192
|
+
# booking.
|
193
|
+
# @return [RetrieveBookingResponse Hash] response from the API call
|
194
|
+
def retrieve_booking(booking_id:)
|
195
|
+
# Prepare query url.
|
196
|
+
_query_builder = config.get_base_uri
|
197
|
+
_query_builder << '/v2/bookings/{booking_id}'
|
198
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
199
|
+
_query_builder,
|
200
|
+
'booking_id' => { 'value' => booking_id, 'encode' => true }
|
201
|
+
)
|
202
|
+
_query_url = APIHelper.clean_url _query_builder
|
203
|
+
|
204
|
+
# Prepare headers.
|
205
|
+
_headers = {
|
206
|
+
'accept' => 'application/json'
|
207
|
+
}
|
208
|
+
|
209
|
+
# Prepare and execute HttpRequest.
|
210
|
+
_request = config.http_client.get(
|
211
|
+
_query_url,
|
212
|
+
headers: _headers
|
213
|
+
)
|
214
|
+
OAuth2.apply(config, _request)
|
215
|
+
_response = execute_request(_request)
|
216
|
+
|
217
|
+
# Return appropriate response type.
|
218
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
219
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
220
|
+
ApiResponse.new(
|
221
|
+
_response, data: decoded, errors: _errors
|
222
|
+
)
|
223
|
+
end
|
224
|
+
|
225
|
+
# Updates a booking.
|
226
|
+
# @param [String] booking_id Required parameter: The ID of the
|
227
|
+
# [Booking](#type-booking) object representing the to-be-updated booking.
|
228
|
+
# @param [UpdateBookingRequest] body Required parameter: An object
|
229
|
+
# containing the fields to POST for the request. See the corresponding
|
230
|
+
# object definition for field details.
|
231
|
+
# @return [UpdateBookingResponse Hash] response from the API call
|
232
|
+
def update_booking(booking_id:,
|
233
|
+
body:)
|
234
|
+
# Prepare query url.
|
235
|
+
_query_builder = config.get_base_uri
|
236
|
+
_query_builder << '/v2/bookings/{booking_id}'
|
237
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
238
|
+
_query_builder,
|
239
|
+
'booking_id' => { 'value' => booking_id, 'encode' => true }
|
240
|
+
)
|
241
|
+
_query_url = APIHelper.clean_url _query_builder
|
242
|
+
|
243
|
+
# Prepare headers.
|
244
|
+
_headers = {
|
245
|
+
'accept' => 'application/json',
|
246
|
+
'content-type' => 'application/json; charset=utf-8'
|
247
|
+
}
|
248
|
+
|
249
|
+
# Prepare and execute HttpRequest.
|
250
|
+
_request = config.http_client.put(
|
251
|
+
_query_url,
|
252
|
+
headers: _headers,
|
253
|
+
parameters: body.to_json
|
254
|
+
)
|
255
|
+
OAuth2.apply(config, _request)
|
256
|
+
_response = execute_request(_request)
|
257
|
+
|
258
|
+
# Return appropriate response type.
|
259
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
260
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
261
|
+
ApiResponse.new(
|
262
|
+
_response, data: decoded, errors: _errors
|
263
|
+
)
|
264
|
+
end
|
265
|
+
|
266
|
+
# Cancels an existing booking.
|
267
|
+
# @param [String] booking_id Required parameter: The ID of the
|
268
|
+
# [Booking](#type-booking) object representing the to-be-cancelled
|
269
|
+
# booking.
|
270
|
+
# @param [CancelBookingRequest] body Required parameter: An object
|
271
|
+
# containing the fields to POST for the request. See the corresponding
|
272
|
+
# object definition for field details.
|
273
|
+
# @return [CancelBookingResponse Hash] response from the API call
|
274
|
+
def cancel_booking(booking_id:,
|
275
|
+
body:)
|
276
|
+
# Prepare query url.
|
277
|
+
_query_builder = config.get_base_uri
|
278
|
+
_query_builder << '/v2/bookings/{booking_id}/cancel'
|
279
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
280
|
+
_query_builder,
|
281
|
+
'booking_id' => { 'value' => booking_id, 'encode' => true }
|
282
|
+
)
|
283
|
+
_query_url = APIHelper.clean_url _query_builder
|
284
|
+
|
285
|
+
# Prepare headers.
|
286
|
+
_headers = {
|
287
|
+
'accept' => 'application/json',
|
288
|
+
'content-type' => 'application/json; charset=utf-8'
|
289
|
+
}
|
290
|
+
|
291
|
+
# Prepare and execute HttpRequest.
|
292
|
+
_request = config.http_client.post(
|
293
|
+
_query_url,
|
294
|
+
headers: _headers,
|
295
|
+
parameters: body.to_json
|
296
|
+
)
|
297
|
+
OAuth2.apply(config, _request)
|
298
|
+
_response = execute_request(_request)
|
299
|
+
|
300
|
+
# Return appropriate response type.
|
301
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
302
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
303
|
+
ApiResponse.new(
|
304
|
+
_response, data: decoded, errors: _errors
|
305
|
+
)
|
306
|
+
end
|
307
|
+
end
|
308
|
+
end
|