square.rb 6.4.0.20200923 → 9.0.0.20210226

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/README.md +43 -31
  4. data/lib/square.rb +60 -61
  5. data/lib/square/api/apple_pay_api.rb +5 -3
  6. data/lib/square/api/bank_accounts_api.rb +16 -19
  7. data/lib/square/api/base_api.rb +1 -1
  8. data/lib/square/api/bookings_api.rb +308 -0
  9. data/lib/square/api/cash_drawers_api.rb +13 -6
  10. data/lib/square/api/catalog_api.rb +71 -35
  11. data/lib/square/api/checkout_api.rb +4 -2
  12. data/lib/square/api/customer_groups_api.rb +18 -8
  13. data/lib/square/api/customer_segments_api.rb +9 -5
  14. data/lib/square/api/customers_api.rb +47 -27
  15. data/lib/square/api/devices_api.rb +17 -6
  16. data/lib/square/api/disputes_api.rb +70 -54
  17. data/lib/square/api/employees_api.rb +7 -3
  18. data/lib/square/api/inventory_api.rb +27 -13
  19. data/lib/square/api/invoices_api.rb +44 -25
  20. data/lib/square/api/labor_api.rb +57 -25
  21. data/lib/square/api/locations_api.rb +16 -13
  22. data/lib/square/api/loyalty_api.rb +60 -66
  23. data/lib/square/api/merchants_api.rb +7 -3
  24. data/lib/square/api/mobile_authorization_api.rb +5 -3
  25. data/lib/square/api/o_auth_api.rb +11 -8
  26. data/lib/square/api/orders_api.rb +55 -8
  27. data/lib/square/api/payments_api.rb +68 -55
  28. data/lib/square/api/refunds_api.rb +32 -26
  29. data/lib/square/api/subscriptions_api.rb +26 -14
  30. data/lib/square/api/team_api.rb +46 -30
  31. data/lib/square/api/terminal_api.rb +156 -7
  32. data/lib/square/api/transactions_api.rb +32 -18
  33. data/lib/square/api/v1_employees_api.rb +27 -389
  34. data/lib/square/api/v1_transactions_api.rb +42 -101
  35. data/lib/square/api_helper.rb +14 -9
  36. data/lib/square/client.rb +10 -14
  37. data/lib/square/configuration.rb +21 -6
  38. data/lib/square/http/api_response.rb +2 -0
  39. data/lib/square/http/faraday_client.rb +9 -2
  40. data/spec/user_journey_spec.rb +2 -5
  41. data/test/api/test_locations_api.rb +1 -1
  42. metadata +5 -6
  43. data/lib/square/api/v1_items_api.rb +0 -1686
  44. 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: ff331317ad3b1bea0c21cf6a6cc9bfd0b46296890792bf0f5d19d21be6ea8ddb
4
- data.tar.gz: dbf543ea3a0ebd7a70cd04e754ffc843d13575899c7e0fe1697c0a538d68fa0c
3
+ metadata.gz: d590e351e349cad97ee0e30e6f0c281f699e9357b68007ce847cdf3d69b86451
4
+ data.tar.gz: 5f89a1777603830bb3b6878f3e45041522c862a2b625e8bdda39c2893678e93d
5
5
  SHA512:
6
- metadata.gz: 15818b53efa7435cc292b14f3d504feef1ab423e3edafdba332694ad229910d8400eb08e6ba67906c19629ac2ecdc9a76251d29f85790fb3046a115aca3a566c
7
- data.tar.gz: 749326579ee962e569e387f932af7176f0137e6f6b175e7392bfa9b8e19e872092f34b7f2097fa9ce9d21cd744c2837cd23015e5c826b50510664887bd9ee546
6
+ metadata.gz: d460315ea4f40be58b73ae56ce056ae5a7e0d09f8ca3b8604e8e347987743054228243318d4e23cbb2cf876272c88e7c5ace6cd50ddf9ad2a116f84c20a378f0
7
+ data.tar.gz: 48da57deda485630006753f057fc6962caea914f058fca58d20884696e101b3e859b8cd5bf68a6d69817ed62b66fb743bddde49b5c15d9837ccca91fe40dc806
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2020 Square, Inc.
1
+ Copyright 2121 Square, Inc.
2
2
  Licensed under the Apache License, Version 2.0 (the "License");
3
3
  you may not use this file except in compliance with the License.
4
4
  You may obtain a copy of the License at
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
 
@@ -280,38 +291,39 @@ The Square Platform is built on the [Square API]. Square has a number of other S
280
291
 
281
292
  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).
282
293
 
294
+ [//]: # "Link anchor definitions"
283
295
  [Square Logo]: https://docs.connect.squareup.com/images/github/github-square-logo.svg
284
296
  [Developer Dashboard]: https://developer.squareup.com/apps
285
297
  [Square API]: https://squareup.com/developers
286
298
  [sign up for a developer account]: https://squareup.com/signup?v=developers
287
299
  [Client]: doc/client.md
288
- [Devices]: doc/devices.md
289
- [Disputes]: doc/disputes.md
290
- [Terminal]: doc/terminal.md
291
- [Team]: doc/team.md
292
- [Cash Drawers]: doc/cash-drawers.md
293
- [Customer Groups]: doc/customer-groups.md
294
- [Customer Segments]: doc/customer-segments.md
295
- [Bank Accounts]: doc/bank-accounts
296
- [Payments]: doc/payments.md
297
- [Checkout]: doc/checkout.md
298
- [Catalog]: doc/catalog.md
299
- [Customers]: doc/customers.md
300
- [Employees]: doc/employees.md
301
- [Inventory]: doc/inventory.md
302
- [Labor]: doc/labor.md
303
- [Loyalty]: doc/loyalty.md
304
- [Locations]: doc/locations.md
305
- [Merchants]: doc/merchants.md
306
- [Orders]: doc/orders.md
307
- [Invoices]: doc/invoices.md
308
- [Apple Pay]: doc/apple-pay.md
309
- [Refunds]: doc/refunds.md
310
- [Mobile Authorization]: doc/mobile-authorization.md
311
- [O Auth]: doc/o-auth.md
312
- [V1 Locations]: doc/v1-locations.md
313
- [V1 Employees]: doc/v1-employees.md
314
- [V1 Transactions]: doc/v1-transactions.md
315
- [V1 Items]: doc/v1-items.md
316
- [Transactions]: doc/transactions.md
317
- [Subscriptions]: doc/subscriptions.md
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
@@ -1,61 +1,60 @@
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_locations_api.rb'
35
- require_relative 'square/api/v1_employees_api.rb'
36
- require_relative 'square/api/v1_transactions_api.rb'
37
- require_relative 'square/api/v1_items_api.rb'
38
- require_relative 'square/api/apple_pay_api.rb'
39
- require_relative 'square/api/bank_accounts_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'
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/apple_pay_api.rb'
37
+ require_relative 'square/api/bank_accounts_api.rb'
38
+ require_relative 'square/api/bookings_api.rb'
39
+ require_relative 'square/api/cash_drawers_api.rb'
40
+ require_relative 'square/api/catalog_api.rb'
41
+ require_relative 'square/api/customers_api.rb'
42
+ require_relative 'square/api/customer_groups_api.rb'
43
+ require_relative 'square/api/customer_segments_api.rb'
44
+ require_relative 'square/api/devices_api.rb'
45
+ require_relative 'square/api/disputes_api.rb'
46
+ require_relative 'square/api/employees_api.rb'
47
+ require_relative 'square/api/inventory_api.rb'
48
+ require_relative 'square/api/invoices_api.rb'
49
+ require_relative 'square/api/labor_api.rb'
50
+ require_relative 'square/api/locations_api.rb'
51
+ require_relative 'square/api/checkout_api.rb'
52
+ require_relative 'square/api/transactions_api.rb'
53
+ require_relative 'square/api/loyalty_api.rb'
54
+ require_relative 'square/api/merchants_api.rb'
55
+ require_relative 'square/api/orders_api.rb'
56
+ require_relative 'square/api/payments_api.rb'
57
+ require_relative 'square/api/refunds_api.rb'
58
+ require_relative 'square/api/subscriptions_api.rb'
59
+ require_relative 'square/api/team_api.rb'
60
+ 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/docs/payment-form/payment
18
- # -form-walkthrough).
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(_response, data: decoded, errors: _errors)
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/docs/working-with-apis/pa
17
- # gination) guide for more information.
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(_response, data: decoded, errors: _errors)
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/docs/bank-accounts-api#retrieve-a
69
- # -bank-account-by-using-an-id-issued-by-v1-bank-accounts-api).
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(_response, data: decoded, errors: _errors)
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. For more information, see
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(_response, data: decoded, errors: _errors)
128
+ ApiResponse.new(
129
+ _response, data: decoded, errors: _errors
130
+ )
134
131
  end
135
132
  end
136
133
  end
@@ -8,7 +8,7 @@ module Square
8
8
  @http_call_back = http_call_back
9
9
 
10
10
  @global_headers = {
11
- 'user-agent' => 'Square-Ruby-SDK/6.4.0.20200923',
11
+ 'user-agent' => 'Square-Ruby-SDK/9.0.0.20210226',
12
12
  'Square-Version' => config.square_version
13
13
  }
14
14
  end
@@ -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