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.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +34 -33
  3. data/lib/square.rb +61 -62
  4. data/lib/square/api/apple_pay_api.rb +5 -3
  5. data/lib/square/api/bank_accounts_api.rb +16 -19
  6. data/lib/square/api/base_api.rb +1 -1
  7. data/lib/square/api/bookings_api.rb +308 -0
  8. data/lib/square/api/cash_drawers_api.rb +13 -6
  9. data/lib/square/api/catalog_api.rb +68 -32
  10. data/lib/square/api/checkout_api.rb +4 -2
  11. data/lib/square/api/customer_groups_api.rb +18 -8
  12. data/lib/square/api/customer_segments_api.rb +9 -5
  13. data/lib/square/api/customers_api.rb +47 -27
  14. data/lib/square/api/devices_api.rb +17 -6
  15. data/lib/square/api/disputes_api.rb +71 -68
  16. data/lib/square/api/employees_api.rb +10 -5
  17. data/lib/square/api/inventory_api.rb +30 -15
  18. data/lib/square/api/invoices_api.rb +42 -38
  19. data/lib/square/api/labor_api.rb +131 -22
  20. data/lib/square/api/locations_api.rb +16 -13
  21. data/lib/square/api/loyalty_api.rb +60 -66
  22. data/lib/square/api/merchants_api.rb +7 -3
  23. data/lib/square/api/mobile_authorization_api.rb +5 -3
  24. data/lib/square/api/o_auth_api.rb +11 -8
  25. data/lib/square/api/orders_api.rb +111 -90
  26. data/lib/square/api/payments_api.rb +75 -65
  27. data/lib/square/api/refunds_api.rb +37 -27
  28. data/lib/square/api/subscriptions_api.rb +29 -28
  29. data/lib/square/api/team_api.rb +46 -30
  30. data/lib/square/api/terminal_api.rb +156 -7
  31. data/lib/square/api/transactions_api.rb +32 -18
  32. data/lib/square/api/v1_employees_api.rb +59 -31
  33. data/lib/square/api/v1_items_api.rb +195 -115
  34. data/lib/square/api/v1_transactions_api.rb +49 -27
  35. data/lib/square/api_helper.rb +14 -9
  36. data/lib/square/client.rb +14 -20
  37. data/lib/square/configuration.rb +2 -2
  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/api_test_base.rb +1 -6
  42. data/test/api/test_catalog_api.rb +1 -4
  43. data/test/api/test_customers_api.rb +1 -4
  44. data/test/api/test_employees_api.rb +1 -4
  45. data/test/api/test_labor_api.rb +2 -6
  46. data/test/api/test_locations_api.rb +22 -33
  47. data/test/api/test_merchants_api.rb +1 -4
  48. data/test/api/test_payments_api.rb +3 -6
  49. data/test/api/test_refunds_api.rb +3 -6
  50. data/test/http_response_catcher.rb +0 -5
  51. data/test/test_helper.rb +0 -5
  52. metadata +33 -16
  53. data/lib/square/api/reporting_api.rb +0 -138
  54. 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: 491aaaccfa43e7c8d9d17a2d48624c28207bbea80dc75359d525b3d4cd64b0cf
4
- data.tar.gz: 645d97dc4dcef2655903ad1f89dee5e361c6b072794bf2920d83fe66dfae1723
3
+ metadata.gz: 50abb148c3dd6d03e86147fc8f95f3f58eeafeabb22d81c65a5c58b87b0b1060
4
+ data.tar.gz: 26371d6cdfa25de275bfef471b8145e43eaeccc7dc661d0abac57f9b643645aa
5
5
  SHA512:
6
- metadata.gz: 41bc326ab367dae322de2187a0fb3d509384f5af88787e75ab37db42db1263833f65fd0bf39e48ecd60d437970752eb5380cba65eeee02a113c39ae48692e74d
7
- data.tar.gz: d2f6cd63f7a4475ae78c64a980831c4f3b2b23ca8e657deb6dc737b188906987f2b67a21966ed74f7001c25553d5590b1a619c923713f25e9000d199f6196e21
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
- [Locations]: doc/locations.md
306
- [Merchants]: doc/merchants.md
307
- [Orders]: doc/orders.md
308
- [Invoices]: doc/invoices.md
309
- [Apple Pay]: doc/apple-pay.md
310
- [Refunds]: doc/refunds.md
311
- [Reporting]: doc/reporting.md
312
- [Mobile Authorization]: doc/mobile-authorization.md
313
- [O Auth]: doc/o-auth.md
314
- [V1 Locations]: doc/v1-locations.md
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
@@ -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/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/reporting_api.rb'
53
- require_relative 'square/api/checkout_api.rb'
54
- require_relative 'square/api/orders_api.rb'
55
- require_relative 'square/api/transactions_api.rb'
56
- require_relative 'square/api/loyalty_api.rb'
57
- require_relative 'square/api/merchants_api.rb'
58
- require_relative 'square/api/payments_api.rb'
59
- require_relative 'square/api/refunds_api.rb'
60
- require_relative 'square/api/subscriptions_api.rb'
61
- require_relative 'square/api/team_api.rb'
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/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.2.0.20200812',
11
+ 'user-agent' => 'Square-Ruby-SDK/8.0.0.20201216',
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