square.rb 26.0.0.20221214 → 26.2.0.20230315
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/lib/square/api/apple_pay_api.rb +14 -30
- data/lib/square/api/bank_accounts_api.rb +40 -90
- data/lib/square/api/base_api.rb +42 -42
- data/lib/square/api/booking_custom_attributes_api.rb +164 -329
- data/lib/square/api/bookings_api.rb +135 -260
- data/lib/square/api/cards_api.rb +56 -118
- data/lib/square/api/cash_drawers_api.rb +47 -103
- data/lib/square/api/catalog_api.rb +197 -423
- data/lib/square/api/checkout_api.rb +85 -175
- data/lib/square/api/customer_custom_attributes_api.rb +150 -303
- data/lib/square/api/customer_groups_api.rb +69 -145
- data/lib/square/api/customer_segments_api.rb +26 -61
- data/lib/square/api/customers_api.rb +147 -294
- data/lib/square/api/devices_api.rb +42 -89
- data/lib/square/api/disputes_api.rb +130 -288
- data/lib/square/api/employees_api.rb +28 -63
- data/lib/square/api/gift_card_activities_api.rb +33 -65
- data/lib/square/api/gift_cards_api.rb +103 -202
- data/lib/square/api/inventory_api.rb +179 -366
- data/lib/square/api/invoices_api.rb +118 -237
- data/lib/square/api/labor_api.rb +223 -459
- data/lib/square/api/location_custom_attributes_api.rb +419 -0
- data/lib/square/api/locations_api.rb +54 -112
- data/lib/square/api/loyalty_api.rb +259 -512
- data/lib/square/api/merchants_api.rb +25 -60
- data/lib/square/api/mobile_authorization_api.rb +14 -30
- data/lib/square/api/o_auth_api.rb +54 -109
- data/lib/square/api/order_custom_attributes_api.rb +168 -333
- data/lib/square/api/orders_api.rb +115 -222
- data/lib/square/api/payments_api.rb +106 -208
- data/lib/square/api/payouts_api.rb +47 -100
- data/lib/square/api/refunds_api.rb +46 -93
- data/lib/square/api/sites_api.rb +11 -28
- data/lib/square/api/snippets_api.rb +42 -90
- data/lib/square/api/subscriptions_api.rb +150 -299
- data/lib/square/api/team_api.rb +114 -224
- data/lib/square/api/terminal_api.rb +162 -328
- data/lib/square/api/transactions_api.rb +62 -126
- data/lib/square/api/v1_transactions_api.rb +155 -296
- data/lib/square/api/vendors_api.rb +99 -192
- data/lib/square/api/webhook_subscriptions_api.rb +115 -235
- data/lib/square/api_helper.rb +1 -437
- data/lib/square/client.rb +82 -46
- data/lib/square/configuration.rb +28 -53
- data/lib/square/exceptions/api_exception.rb +1 -11
- data/lib/square/http/api_response.rb +13 -19
- data/lib/square/http/auth/o_auth2.rb +14 -7
- data/lib/square/http/http_call_back.rb +1 -15
- data/lib/square/http/http_method_enum.rb +1 -4
- data/lib/square/http/http_request.rb +1 -45
- data/lib/square/http/http_response.rb +1 -20
- data/lib/square/utilities/date_time_helper.rb +1 -146
- data/lib/square/utilities/file_wrapper.rb +5 -5
- data/lib/square.rb +7 -6
- data/spec/user_journey_spec.rb +2 -2
- data/test/api/api_test_base.rb +13 -5
- data/test/api/test_catalog_api.rb +5 -4
- data/test/api/test_customers_api.rb +3 -2
- data/test/api/test_employees_api.rb +4 -3
- data/test/api/test_labor_api.rb +6 -5
- data/test/api/test_locations_api.rb +3 -2
- data/test/api/test_merchants_api.rb +4 -3
- data/test/api/test_payments_api.rb +4 -3
- data/test/api/test_refunds_api.rb +4 -3
- metadata +12 -111
- data/lib/square/exceptions/validation_exception.rb +0 -13
- data/lib/square/http/faraday_client.rb +0 -93
- data/lib/square/http/http_client.rb +0 -118
- data/test/test_helper.rb +0 -89
@@ -1,10 +1,6 @@
|
|
1
1
|
module Square
|
2
2
|
# BookingsApi
|
3
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
4
|
# Retrieve a collection of bookings.
|
9
5
|
# To call this endpoint with buyer-level permissions, set
|
10
6
|
# `APPOINTMENTS_READ` for the OAuth scope.
|
@@ -34,42 +30,32 @@ module Square
|
|
34
30
|
location_id: nil,
|
35
31
|
start_at_min: nil,
|
36
32
|
start_at_max: nil)
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
}
|
55
|
-
|
56
|
-
# Prepare and execute HttpRequest.
|
57
|
-
_request = config.http_client.get(
|
58
|
-
_query_url,
|
59
|
-
headers: _headers
|
60
|
-
)
|
61
|
-
OAuth2.apply(config, _request)
|
62
|
-
_response = execute_request(_request)
|
63
|
-
|
64
|
-
# Return appropriate response type.
|
65
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
66
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
67
|
-
ApiResponse.new(
|
68
|
-
_response, data: decoded, errors: _errors
|
69
|
-
)
|
33
|
+
new_api_call_builder
|
34
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
35
|
+
'/v2/bookings',
|
36
|
+
'default')
|
37
|
+
.query_param(new_parameter(limit, key: 'limit'))
|
38
|
+
.query_param(new_parameter(cursor, key: 'cursor'))
|
39
|
+
.query_param(new_parameter(team_member_id, key: 'team_member_id'))
|
40
|
+
.query_param(new_parameter(location_id, key: 'location_id'))
|
41
|
+
.query_param(new_parameter(start_at_min, key: 'start_at_min'))
|
42
|
+
.query_param(new_parameter(start_at_max, key: 'start_at_max'))
|
43
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
44
|
+
.auth(Single.new('global')))
|
45
|
+
.response(new_response_handler
|
46
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
47
|
+
.is_api_response(true)
|
48
|
+
.convertor(ApiResponse.method(:create)))
|
49
|
+
.execute
|
70
50
|
end
|
71
51
|
|
72
52
|
# Creates a booking.
|
53
|
+
# The required input must include the following:
|
54
|
+
# - `Booking.location_id`,
|
55
|
+
# - `Booking.start_at`,
|
56
|
+
# - `Booking.team_member_id`
|
57
|
+
# - `Booking.AppointmentSegment.service_variation_id`
|
58
|
+
# - `Booking.AppointmentSegment.service_variation_version`
|
73
59
|
# To call this endpoint with buyer-level permissions, set
|
74
60
|
# `APPOINTMENTS_WRITE` for the OAuth scope.
|
75
61
|
# To call this endpoint with seller-level permissions, set
|
@@ -82,32 +68,20 @@ module Square
|
|
82
68
|
# object definition for field details.
|
83
69
|
# @return [CreateBookingResponse Hash] response from the API call
|
84
70
|
def create_booking(body:)
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
headers: _headers,
|
100
|
-
parameters: body.to_json
|
101
|
-
)
|
102
|
-
OAuth2.apply(config, _request)
|
103
|
-
_response = execute_request(_request)
|
104
|
-
|
105
|
-
# Return appropriate response type.
|
106
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
107
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
108
|
-
ApiResponse.new(
|
109
|
-
_response, data: decoded, errors: _errors
|
110
|
-
)
|
71
|
+
new_api_call_builder
|
72
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
73
|
+
'/v2/bookings',
|
74
|
+
'default')
|
75
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
76
|
+
.body_param(new_parameter(body))
|
77
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
78
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
79
|
+
.auth(Single.new('global')))
|
80
|
+
.response(new_response_handler
|
81
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
82
|
+
.is_api_response(true)
|
83
|
+
.convertor(ApiResponse.method(:create)))
|
84
|
+
.execute
|
111
85
|
end
|
112
86
|
|
113
87
|
# Searches for availabilities for booking.
|
@@ -120,61 +94,36 @@ module Square
|
|
120
94
|
# object definition for field details.
|
121
95
|
# @return [SearchAvailabilityResponse Hash] response from the API call
|
122
96
|
def search_availability(body:)
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
headers: _headers,
|
138
|
-
parameters: body.to_json
|
139
|
-
)
|
140
|
-
OAuth2.apply(config, _request)
|
141
|
-
_response = execute_request(_request)
|
142
|
-
|
143
|
-
# Return appropriate response type.
|
144
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
145
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
146
|
-
ApiResponse.new(
|
147
|
-
_response, data: decoded, errors: _errors
|
148
|
-
)
|
97
|
+
new_api_call_builder
|
98
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
99
|
+
'/v2/bookings/availability/search',
|
100
|
+
'default')
|
101
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
102
|
+
.body_param(new_parameter(body))
|
103
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
104
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
105
|
+
.auth(Single.new('global')))
|
106
|
+
.response(new_response_handler
|
107
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
108
|
+
.is_api_response(true)
|
109
|
+
.convertor(ApiResponse.method(:create)))
|
110
|
+
.execute
|
149
111
|
end
|
150
112
|
|
151
113
|
# Retrieves a seller's booking profile.
|
152
114
|
# @return [RetrieveBusinessBookingProfileResponse Hash] response from the API call
|
153
115
|
def retrieve_business_booking_profile
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
_request = config.http_client.get(
|
166
|
-
_query_url,
|
167
|
-
headers: _headers
|
168
|
-
)
|
169
|
-
OAuth2.apply(config, _request)
|
170
|
-
_response = execute_request(_request)
|
171
|
-
|
172
|
-
# Return appropriate response type.
|
173
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
174
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
175
|
-
ApiResponse.new(
|
176
|
-
_response, data: decoded, errors: _errors
|
177
|
-
)
|
116
|
+
new_api_call_builder
|
117
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
118
|
+
'/v2/bookings/business-booking-profile',
|
119
|
+
'default')
|
120
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
121
|
+
.auth(Single.new('global')))
|
122
|
+
.response(new_response_handler
|
123
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
124
|
+
.is_api_response(true)
|
125
|
+
.convertor(ApiResponse.method(:create)))
|
126
|
+
.execute
|
178
127
|
end
|
179
128
|
|
180
129
|
# Lists booking profiles for team members.
|
@@ -194,37 +143,21 @@ module Square
|
|
194
143
|
limit: nil,
|
195
144
|
cursor: nil,
|
196
145
|
location_id: nil)
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
}
|
213
|
-
|
214
|
-
# Prepare and execute HttpRequest.
|
215
|
-
_request = config.http_client.get(
|
216
|
-
_query_url,
|
217
|
-
headers: _headers
|
218
|
-
)
|
219
|
-
OAuth2.apply(config, _request)
|
220
|
-
_response = execute_request(_request)
|
221
|
-
|
222
|
-
# Return appropriate response type.
|
223
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
224
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
225
|
-
ApiResponse.new(
|
226
|
-
_response, data: decoded, errors: _errors
|
227
|
-
)
|
146
|
+
new_api_call_builder
|
147
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
148
|
+
'/v2/bookings/team-member-booking-profiles',
|
149
|
+
'default')
|
150
|
+
.query_param(new_parameter(bookable_only, key: 'bookable_only'))
|
151
|
+
.query_param(new_parameter(limit, key: 'limit'))
|
152
|
+
.query_param(new_parameter(cursor, key: 'cursor'))
|
153
|
+
.query_param(new_parameter(location_id, key: 'location_id'))
|
154
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
155
|
+
.auth(Single.new('global')))
|
156
|
+
.response(new_response_handler
|
157
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
158
|
+
.is_api_response(true)
|
159
|
+
.convertor(ApiResponse.method(:create)))
|
160
|
+
.execute
|
228
161
|
end
|
229
162
|
|
230
163
|
# Retrieves a team member's booking profile.
|
@@ -232,34 +165,19 @@ module Square
|
|
232
165
|
# member to retrieve.
|
233
166
|
# @return [RetrieveTeamMemberBookingProfileResponse Hash] response from the API call
|
234
167
|
def retrieve_team_member_booking_profile(team_member_id:)
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
# Prepare and execute HttpRequest.
|
250
|
-
_request = config.http_client.get(
|
251
|
-
_query_url,
|
252
|
-
headers: _headers
|
253
|
-
)
|
254
|
-
OAuth2.apply(config, _request)
|
255
|
-
_response = execute_request(_request)
|
256
|
-
|
257
|
-
# Return appropriate response type.
|
258
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
259
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
260
|
-
ApiResponse.new(
|
261
|
-
_response, data: decoded, errors: _errors
|
262
|
-
)
|
168
|
+
new_api_call_builder
|
169
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
170
|
+
'/v2/bookings/team-member-booking-profiles/{team_member_id}',
|
171
|
+
'default')
|
172
|
+
.template_param(new_parameter(team_member_id, key: 'team_member_id')
|
173
|
+
.should_encode(true))
|
174
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
175
|
+
.auth(Single.new('global')))
|
176
|
+
.response(new_response_handler
|
177
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
178
|
+
.is_api_response(true)
|
179
|
+
.convertor(ApiResponse.method(:create)))
|
180
|
+
.execute
|
263
181
|
end
|
264
182
|
|
265
183
|
# Retrieves a booking.
|
@@ -271,34 +189,19 @@ module Square
|
|
271
189
|
# [Booking]($m/Booking) object representing the to-be-retrieved booking.
|
272
190
|
# @return [RetrieveBookingResponse Hash] response from the API call
|
273
191
|
def retrieve_booking(booking_id:)
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
# Prepare and execute HttpRequest.
|
289
|
-
_request = config.http_client.get(
|
290
|
-
_query_url,
|
291
|
-
headers: _headers
|
292
|
-
)
|
293
|
-
OAuth2.apply(config, _request)
|
294
|
-
_response = execute_request(_request)
|
295
|
-
|
296
|
-
# Return appropriate response type.
|
297
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
298
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
299
|
-
ApiResponse.new(
|
300
|
-
_response, data: decoded, errors: _errors
|
301
|
-
)
|
192
|
+
new_api_call_builder
|
193
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
194
|
+
'/v2/bookings/{booking_id}',
|
195
|
+
'default')
|
196
|
+
.template_param(new_parameter(booking_id, key: 'booking_id')
|
197
|
+
.should_encode(true))
|
198
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
199
|
+
.auth(Single.new('global')))
|
200
|
+
.response(new_response_handler
|
201
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
202
|
+
.is_api_response(true)
|
203
|
+
.convertor(ApiResponse.method(:create)))
|
204
|
+
.execute
|
302
205
|
end
|
303
206
|
|
304
207
|
# Updates a booking.
|
@@ -317,36 +220,22 @@ module Square
|
|
317
220
|
# @return [UpdateBookingResponse Hash] response from the API call
|
318
221
|
def update_booking(booking_id:,
|
319
222
|
body:)
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
_request = config.http_client.put(
|
337
|
-
_query_url,
|
338
|
-
headers: _headers,
|
339
|
-
parameters: body.to_json
|
340
|
-
)
|
341
|
-
OAuth2.apply(config, _request)
|
342
|
-
_response = execute_request(_request)
|
343
|
-
|
344
|
-
# Return appropriate response type.
|
345
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
346
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
347
|
-
ApiResponse.new(
|
348
|
-
_response, data: decoded, errors: _errors
|
349
|
-
)
|
223
|
+
new_api_call_builder
|
224
|
+
.request(new_request_builder(HttpMethodEnum::PUT,
|
225
|
+
'/v2/bookings/{booking_id}',
|
226
|
+
'default')
|
227
|
+
.template_param(new_parameter(booking_id, key: 'booking_id')
|
228
|
+
.should_encode(true))
|
229
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
230
|
+
.body_param(new_parameter(body))
|
231
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
232
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
233
|
+
.auth(Single.new('global')))
|
234
|
+
.response(new_response_handler
|
235
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
236
|
+
.is_api_response(true)
|
237
|
+
.convertor(ApiResponse.method(:create)))
|
238
|
+
.execute
|
350
239
|
end
|
351
240
|
|
352
241
|
# Cancels an existing booking.
|
@@ -365,36 +254,22 @@ module Square
|
|
365
254
|
# @return [CancelBookingResponse Hash] response from the API call
|
366
255
|
def cancel_booking(booking_id:,
|
367
256
|
body:)
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
_request = config.http_client.post(
|
385
|
-
_query_url,
|
386
|
-
headers: _headers,
|
387
|
-
parameters: body.to_json
|
388
|
-
)
|
389
|
-
OAuth2.apply(config, _request)
|
390
|
-
_response = execute_request(_request)
|
391
|
-
|
392
|
-
# Return appropriate response type.
|
393
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
394
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
395
|
-
ApiResponse.new(
|
396
|
-
_response, data: decoded, errors: _errors
|
397
|
-
)
|
257
|
+
new_api_call_builder
|
258
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
259
|
+
'/v2/bookings/{booking_id}/cancel',
|
260
|
+
'default')
|
261
|
+
.template_param(new_parameter(booking_id, key: 'booking_id')
|
262
|
+
.should_encode(true))
|
263
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
264
|
+
.body_param(new_parameter(body))
|
265
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
266
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
267
|
+
.auth(Single.new('global')))
|
268
|
+
.response(new_response_handler
|
269
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
270
|
+
.is_api_response(true)
|
271
|
+
.convertor(ApiResponse.method(:create)))
|
272
|
+
.execute
|
398
273
|
end
|
399
274
|
end
|
400
275
|
end
|