square.rb 6.2.0.20200812 → 8.0.0.20201216
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +34 -33
- data/lib/square.rb +61 -62
- data/lib/square/api/apple_pay_api.rb +5 -3
- data/lib/square/api/bank_accounts_api.rb +16 -19
- 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 +13 -6
- data/lib/square/api/catalog_api.rb +68 -32
- data/lib/square/api/checkout_api.rb +4 -2
- data/lib/square/api/customer_groups_api.rb +18 -8
- data/lib/square/api/customer_segments_api.rb +9 -5
- data/lib/square/api/customers_api.rb +47 -27
- data/lib/square/api/devices_api.rb +17 -6
- data/lib/square/api/disputes_api.rb +71 -68
- data/lib/square/api/employees_api.rb +10 -5
- data/lib/square/api/inventory_api.rb +30 -15
- data/lib/square/api/invoices_api.rb +42 -38
- data/lib/square/api/labor_api.rb +131 -22
- data/lib/square/api/locations_api.rb +16 -13
- data/lib/square/api/loyalty_api.rb +60 -66
- data/lib/square/api/merchants_api.rb +7 -3
- data/lib/square/api/mobile_authorization_api.rb +5 -3
- data/lib/square/api/o_auth_api.rb +11 -8
- data/lib/square/api/orders_api.rb +111 -90
- data/lib/square/api/payments_api.rb +75 -65
- data/lib/square/api/refunds_api.rb +37 -27
- data/lib/square/api/subscriptions_api.rb +29 -28
- data/lib/square/api/team_api.rb +46 -30
- data/lib/square/api/terminal_api.rb +156 -7
- data/lib/square/api/transactions_api.rb +32 -18
- data/lib/square/api/v1_employees_api.rb +59 -31
- data/lib/square/api/v1_items_api.rb +195 -115
- data/lib/square/api/v1_transactions_api.rb +49 -27
- data/lib/square/api_helper.rb +14 -9
- data/lib/square/client.rb +14 -20
- data/lib/square/configuration.rb +2 -2
- data/lib/square/http/api_response.rb +2 -0
- data/lib/square/http/faraday_client.rb +9 -2
- 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 +22 -33
- 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 +0 -5
- metadata +33 -16
- data/lib/square/api/reporting_api.rb +0 -138
- data/lib/square/api/v1_locations_api.rb +0 -65
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50abb148c3dd6d03e86147fc8f95f3f58eeafeabb22d81c65a5c58b87b0b1060
|
4
|
+
data.tar.gz: 26371d6cdfa25de275bfef471b8145e43eaeccc7dc661d0abac57f9b643645aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a404bd6129da3f1ed2cdeaa8080d05c4ec75fe2ae93913c9c6e01de706f8dfc8487fb8696d431072a87511d9036fa6fa7cc797e6765f326c382d45ba0658d719
|
7
|
+
data.tar.gz: 8000f93f083e58f8c6c820520f535cdf5015f1184ac0bd2febfb3a4448e0850a9ea168e997f7a42f54435255a3beba8a2c74615fd2a155e05fe8cb8bcd7c1652
|
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,12 +78,10 @@ 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]
|
82
84
|
* [Transactions]
|
83
|
-
* [Reporting]
|
84
85
|
|
85
86
|
## Usage
|
86
87
|
|
@@ -281,39 +282,39 @@ The Square Platform is built on the [Square API]. Square has a number of other S
|
|
281
282
|
|
282
283
|
You can also use the Square API to create applications or services that work with payments, orders, inventory, etc. that have been created and managed in Square’s in-person hardware products (Square Point of Sale and Square Register).
|
283
284
|
|
285
|
+
[//]: # "Link anchor definitions"
|
284
286
|
[Square Logo]: https://docs.connect.squareup.com/images/github/github-square-logo.svg
|
285
287
|
[Developer Dashboard]: https://developer.squareup.com/apps
|
286
288
|
[Square API]: https://squareup.com/developers
|
287
289
|
[sign up for a developer account]: https://squareup.com/signup?v=developers
|
288
290
|
[Client]: doc/client.md
|
289
|
-
[Devices]: doc/devices.md
|
290
|
-
[Disputes]: doc/disputes.md
|
291
|
-
[Terminal]: doc/terminal.md
|
292
|
-
[Team]: doc/team.md
|
293
|
-
[Cash Drawers]: doc/cash-drawers.md
|
294
|
-
[Customer Groups]: doc/customer-groups.md
|
295
|
-
[Customer Segments]: doc/customer-segments.md
|
296
|
-
[Bank Accounts]: doc/bank-accounts
|
297
|
-
[Payments]: doc/payments.md
|
298
|
-
[Checkout]: doc/checkout.md
|
299
|
-
[Catalog]: doc/catalog.md
|
300
|
-
[Customers]: doc/customers.md
|
301
|
-
[Employees]: doc/employees.md
|
302
|
-
[Inventory]: doc/inventory.md
|
303
|
-
[Labor]: doc/labor.md
|
304
|
-
[Loyalty]: doc/loyalty.md
|
305
|
-
[
|
306
|
-
[
|
307
|
-
[
|
308
|
-
[
|
309
|
-
[
|
310
|
-
[
|
311
|
-
[
|
312
|
-
[
|
313
|
-
[
|
314
|
-
[
|
315
|
-
[V1 Employees]: doc/v1-employees.md
|
316
|
-
[V1 Transactions]: doc/v1-transactions.md
|
317
|
-
[V1 Items]: doc/v1-items.md
|
318
|
-
[Transactions]: doc/transactions.md
|
319
|
-
[Subscriptions]: doc/subscriptions.md
|
291
|
+
[Devices]: doc/api/devices.md
|
292
|
+
[Disputes]: doc/api/disputes.md
|
293
|
+
[Terminal]: doc/api/terminal.md
|
294
|
+
[Team]: doc/api/team.md
|
295
|
+
[Cash Drawers]: doc/api/cash-drawers.md
|
296
|
+
[Customer Groups]: doc/api/customer-groups.md
|
297
|
+
[Customer Segments]: doc/api/customer-segments.md
|
298
|
+
[Bank Accounts]: doc/api/bank-accounts.md
|
299
|
+
[Payments]: doc/api/payments.md
|
300
|
+
[Checkout]: doc/api/checkout.md
|
301
|
+
[Catalog]: doc/api/catalog.md
|
302
|
+
[Customers]: doc/api/customers.md
|
303
|
+
[Employees]: doc/api/employees.md
|
304
|
+
[Inventory]: doc/api/inventory.md
|
305
|
+
[Labor]: doc/api/labor.md
|
306
|
+
[Loyalty]: doc/api/loyalty.md
|
307
|
+
[Bookings]: doc/api/bookings.md
|
308
|
+
[Locations]: doc/api/locations.md
|
309
|
+
[Merchants]: doc/api/merchants.md
|
310
|
+
[Orders]: doc/api/orders.md
|
311
|
+
[Invoices]: doc/api/invoices.md
|
312
|
+
[Apple Pay]: doc/api/apple-pay.md
|
313
|
+
[Refunds]: doc/api/refunds.md
|
314
|
+
[Subscriptions]: doc/api/subscriptions.md
|
315
|
+
[Mobile Authorization]: doc/api/mobile-authorization.md
|
316
|
+
[O Auth]: doc/api/o-auth.md
|
317
|
+
[V1 Employees]: doc/api/v1-employees.md
|
318
|
+
[V1 Transactions]: doc/api/v1-transactions.md
|
319
|
+
[V1 Items]: doc/api/v1-items.md
|
320
|
+
[Transactions]: doc/api/transactions.md
|
data/lib/square.rb
CHANGED
@@ -1,62 +1,61 @@
|
|
1
|
-
require 'date'
|
2
|
-
require 'json'
|
3
|
-
require 'faraday'
|
4
|
-
require 'certifi'
|
5
|
-
require 'logging'
|
6
|
-
|
7
|
-
require_relative 'square/api_helper.rb'
|
8
|
-
require_relative 'square/client.rb'
|
9
|
-
|
10
|
-
# Utilities
|
11
|
-
require_relative 'square/utilities/file_wrapper.rb'
|
12
|
-
|
13
|
-
# Http
|
14
|
-
require_relative 'square/http/api_response.rb'
|
15
|
-
require_relative 'square/http/http_call_back.rb'
|
16
|
-
require_relative 'square/http/http_client.rb'
|
17
|
-
require_relative 'square/http/faraday_client.rb'
|
18
|
-
require_relative 'square/http/http_method_enum.rb'
|
19
|
-
require_relative 'square/http/http_request.rb'
|
20
|
-
require_relative 'square/http/http_response.rb'
|
21
|
-
require_relative 'square/http/auth/o_auth2.rb'
|
22
|
-
|
23
|
-
# Models
|
24
|
-
|
25
|
-
# Exceptions
|
26
|
-
require_relative 'square/exceptions/api_exception.rb'
|
27
|
-
|
28
|
-
require_relative 'square/configuration.rb'
|
29
|
-
|
30
|
-
# Controllers
|
31
|
-
require_relative 'square/api/base_api.rb'
|
32
|
-
require_relative 'square/api/mobile_authorization_api.rb'
|
33
|
-
require_relative 'square/api/o_auth_api.rb'
|
34
|
-
require_relative 'square/api/
|
35
|
-
require_relative 'square/api/
|
36
|
-
require_relative 'square/api/
|
37
|
-
require_relative 'square/api/
|
38
|
-
require_relative 'square/api/
|
39
|
-
require_relative 'square/api/
|
40
|
-
require_relative 'square/api/cash_drawers_api.rb'
|
41
|
-
require_relative 'square/api/catalog_api.rb'
|
42
|
-
require_relative 'square/api/customers_api.rb'
|
43
|
-
require_relative 'square/api/customer_groups_api.rb'
|
44
|
-
require_relative 'square/api/customer_segments_api.rb'
|
45
|
-
require_relative 'square/api/devices_api.rb'
|
46
|
-
require_relative 'square/api/disputes_api.rb'
|
47
|
-
require_relative 'square/api/employees_api.rb'
|
48
|
-
require_relative 'square/api/inventory_api.rb'
|
49
|
-
require_relative 'square/api/invoices_api.rb'
|
50
|
-
require_relative 'square/api/labor_api.rb'
|
51
|
-
require_relative 'square/api/locations_api.rb'
|
52
|
-
require_relative 'square/api/
|
53
|
-
require_relative 'square/api/
|
54
|
-
require_relative 'square/api/
|
55
|
-
require_relative 'square/api/
|
56
|
-
require_relative 'square/api/
|
57
|
-
require_relative 'square/api/
|
58
|
-
require_relative 'square/api/
|
59
|
-
require_relative 'square/api/
|
60
|
-
require_relative 'square/api/
|
61
|
-
require_relative 'square/api/
|
62
|
-
require_relative 'square/api/terminal_api.rb'
|
1
|
+
require 'date'
|
2
|
+
require 'json'
|
3
|
+
require 'faraday'
|
4
|
+
require 'certifi'
|
5
|
+
require 'logging'
|
6
|
+
|
7
|
+
require_relative 'square/api_helper.rb'
|
8
|
+
require_relative 'square/client.rb'
|
9
|
+
|
10
|
+
# Utilities
|
11
|
+
require_relative 'square/utilities/file_wrapper.rb'
|
12
|
+
|
13
|
+
# Http
|
14
|
+
require_relative 'square/http/api_response.rb'
|
15
|
+
require_relative 'square/http/http_call_back.rb'
|
16
|
+
require_relative 'square/http/http_client.rb'
|
17
|
+
require_relative 'square/http/faraday_client.rb'
|
18
|
+
require_relative 'square/http/http_method_enum.rb'
|
19
|
+
require_relative 'square/http/http_request.rb'
|
20
|
+
require_relative 'square/http/http_response.rb'
|
21
|
+
require_relative 'square/http/auth/o_auth2.rb'
|
22
|
+
|
23
|
+
# Models
|
24
|
+
|
25
|
+
# Exceptions
|
26
|
+
require_relative 'square/exceptions/api_exception.rb'
|
27
|
+
|
28
|
+
require_relative 'square/configuration.rb'
|
29
|
+
|
30
|
+
# Controllers
|
31
|
+
require_relative 'square/api/base_api.rb'
|
32
|
+
require_relative 'square/api/mobile_authorization_api.rb'
|
33
|
+
require_relative 'square/api/o_auth_api.rb'
|
34
|
+
require_relative 'square/api/v1_employees_api.rb'
|
35
|
+
require_relative 'square/api/v1_transactions_api.rb'
|
36
|
+
require_relative 'square/api/v1_items_api.rb'
|
37
|
+
require_relative 'square/api/apple_pay_api.rb'
|
38
|
+
require_relative 'square/api/bank_accounts_api.rb'
|
39
|
+
require_relative 'square/api/bookings_api.rb'
|
40
|
+
require_relative 'square/api/cash_drawers_api.rb'
|
41
|
+
require_relative 'square/api/catalog_api.rb'
|
42
|
+
require_relative 'square/api/customers_api.rb'
|
43
|
+
require_relative 'square/api/customer_groups_api.rb'
|
44
|
+
require_relative 'square/api/customer_segments_api.rb'
|
45
|
+
require_relative 'square/api/devices_api.rb'
|
46
|
+
require_relative 'square/api/disputes_api.rb'
|
47
|
+
require_relative 'square/api/employees_api.rb'
|
48
|
+
require_relative 'square/api/inventory_api.rb'
|
49
|
+
require_relative 'square/api/invoices_api.rb'
|
50
|
+
require_relative 'square/api/labor_api.rb'
|
51
|
+
require_relative 'square/api/locations_api.rb'
|
52
|
+
require_relative 'square/api/checkout_api.rb'
|
53
|
+
require_relative 'square/api/transactions_api.rb'
|
54
|
+
require_relative 'square/api/loyalty_api.rb'
|
55
|
+
require_relative 'square/api/merchants_api.rb'
|
56
|
+
require_relative 'square/api/orders_api.rb'
|
57
|
+
require_relative 'square/api/payments_api.rb'
|
58
|
+
require_relative 'square/api/refunds_api.rb'
|
59
|
+
require_relative 'square/api/subscriptions_api.rb'
|
60
|
+
require_relative 'square/api/team_api.rb'
|
61
|
+
require_relative 'square/api/terminal_api.rb'
|
@@ -14,8 +14,8 @@ module Square
|
|
14
14
|
# Web Apple Pay with Square for merchants using their platform.
|
15
15
|
# To learn more about Apple Pay on Web see the Apple Pay section in the
|
16
16
|
# [Square Payment Form
|
17
|
-
# Walkthrough](https://developer.squareup.com/docs/
|
18
|
-
# -
|
17
|
+
# Walkthrough](https://developer.squareup.com/docs/payment-form/payment-form
|
18
|
+
# -walkthrough).
|
19
19
|
# @param [RegisterDomainRequest] body Required parameter: An object
|
20
20
|
# containing the fields to POST for the request. See the corresponding
|
21
21
|
# object definition for field details.
|
@@ -44,7 +44,9 @@ module Square
|
|
44
44
|
# Return appropriate response type.
|
45
45
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
46
46
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
47
|
-
ApiResponse.new(
|
47
|
+
ApiResponse.new(
|
48
|
+
_response, data: decoded, errors: _errors
|
49
|
+
)
|
48
50
|
end
|
49
51
|
end
|
50
52
|
end
|
@@ -7,14 +7,11 @@ module Square
|
|
7
7
|
|
8
8
|
# Returns a list of [BankAccount](#type-bankaccount) objects linked to a
|
9
9
|
# Square account.
|
10
|
-
# For more information, see
|
11
|
-
# [Bank Accounts
|
12
|
-
# API](https://developer.squareup.com/docs/docs/bank-accounts-api).
|
13
10
|
# @param [String] cursor Optional parameter: The pagination cursor returned
|
14
11
|
# by a previous call to this endpoint. Use it in the next `ListBankAccounts`
|
15
12
|
# request to retrieve the next set of results. See the
|
16
|
-
# [Pagination](https://developer.squareup.com/docs/
|
17
|
-
#
|
13
|
+
# [Pagination](https://developer.squareup.com/docs/working-with-apis/paginat
|
14
|
+
# ion) guide for more information.
|
18
15
|
# @param [Integer] limit Optional parameter: Upper limit on the number of
|
19
16
|
# bank accounts to return in the response. Currently, 1000 is the largest
|
20
17
|
# supported limit. You can specify a limit of up to 1000 bank accounts.
|
@@ -53,20 +50,18 @@ module Square
|
|
53
50
|
# Return appropriate response type.
|
54
51
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
55
52
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
56
|
-
ApiResponse.new(
|
53
|
+
ApiResponse.new(
|
54
|
+
_response, data: decoded, errors: _errors
|
55
|
+
)
|
57
56
|
end
|
58
57
|
|
59
58
|
# Returns details of a [BankAccount](#type-bankaccount) identified by V1
|
60
59
|
# bank account ID.
|
61
|
-
# For more information, see
|
62
|
-
# [Retrieve a bank account by using an ID issued by V1 Bank Accounts
|
63
|
-
# API](https://developer.squareup.com/docs/docs/bank-accounts-api#retrieve-a
|
64
|
-
# -bank-account-by-using-an-id-issued-by-the-v1-bank-accounts-api).
|
65
60
|
# @param [String] v1_bank_account_id Required parameter: Connect V1 ID of
|
66
61
|
# the desired `BankAccount`. For more information, see [Retrieve a bank
|
67
62
|
# account by using an ID issued by V1 Bank Accounts
|
68
|
-
# API](https://developer.squareup.com/docs/
|
69
|
-
# -
|
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).
|
70
65
|
# @return [GetBankAccountByV1IdResponse Hash] response from the API call
|
71
66
|
def get_bank_account_by_v1_id(v1_bank_account_id:)
|
72
67
|
# Prepare query url.
|
@@ -74,7 +69,7 @@ module Square
|
|
74
69
|
_query_builder << '/v2/bank-accounts/by-v1-id/{v1_bank_account_id}'
|
75
70
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
76
71
|
_query_builder,
|
77
|
-
'v1_bank_account_id' => v1_bank_account_id
|
72
|
+
'v1_bank_account_id' => { 'value' => v1_bank_account_id, 'encode' => true }
|
78
73
|
)
|
79
74
|
_query_url = APIHelper.clean_url _query_builder
|
80
75
|
|
@@ -94,13 +89,13 @@ module Square
|
|
94
89
|
# Return appropriate response type.
|
95
90
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
96
91
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
97
|
-
ApiResponse.new(
|
92
|
+
ApiResponse.new(
|
93
|
+
_response, data: decoded, errors: _errors
|
94
|
+
)
|
98
95
|
end
|
99
96
|
|
100
97
|
# Returns details of a [BankAccount](#type-bankaccount)
|
101
|
-
# linked to a Square account.
|
102
|
-
# [Bank Accounts
|
103
|
-
# API](https://developer.squareup.com/docs/docs/bank-accounts-api).
|
98
|
+
# linked to a Square account.
|
104
99
|
# @param [String] bank_account_id Required parameter: Square-issued ID of
|
105
100
|
# the desired `BankAccount`.
|
106
101
|
# @return [GetBankAccountResponse Hash] response from the API call
|
@@ -110,7 +105,7 @@ module Square
|
|
110
105
|
_query_builder << '/v2/bank-accounts/{bank_account_id}'
|
111
106
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
112
107
|
_query_builder,
|
113
|
-
'bank_account_id' => bank_account_id
|
108
|
+
'bank_account_id' => { 'value' => bank_account_id, 'encode' => true }
|
114
109
|
)
|
115
110
|
_query_url = APIHelper.clean_url _query_builder
|
116
111
|
|
@@ -130,7 +125,9 @@ module Square
|
|
130
125
|
# Return appropriate response type.
|
131
126
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
132
127
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
133
|
-
ApiResponse.new(
|
128
|
+
ApiResponse.new(
|
129
|
+
_response, data: decoded, errors: _errors
|
130
|
+
)
|
134
131
|
end
|
135
132
|
end
|
136
133
|
end
|
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
|