square.rb 8.0.0.20201216 → 26.1.0.20230119
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +79 -221
- data/lib/square/api/apple_pay_api.rb +15 -8
- data/lib/square/api/bank_accounts_api.rb +5 -5
- data/lib/square/api/base_api.rb +27 -9
- data/lib/square/api/booking_custom_attributes_api.rb +555 -0
- data/lib/square/api/bookings_api.rb +107 -15
- data/lib/square/api/cards_api.rb +171 -0
- data/lib/square/api/cash_drawers_api.rb +2 -2
- data/lib/square/api/catalog_api.rb +167 -73
- data/lib/square/api/checkout_api.rb +205 -3
- data/lib/square/api/customer_custom_attributes_api.rb +561 -0
- data/lib/square/api/customer_groups_api.rb +17 -8
- data/lib/square/api/customer_segments_api.rb +15 -6
- data/lib/square/api/customers_api.rb +67 -33
- data/lib/square/api/devices_api.rb +3 -2
- data/lib/square/api/disputes_api.rb +109 -105
- data/lib/square/api/gift_card_activities_api.rb +132 -0
- data/lib/square/api/gift_cards_api.rb +298 -0
- data/lib/square/api/inventory_api.rb +263 -24
- data/lib/square/api/invoices_api.rb +21 -21
- data/lib/square/api/labor_api.rb +70 -68
- data/lib/square/api/location_custom_attributes_api.rb +584 -0
- data/lib/square/api/locations_api.rb +21 -14
- data/lib/square/api/loyalty_api.rb +333 -50
- data/lib/square/api/merchants_api.rb +11 -9
- data/lib/square/api/mobile_authorization_api.rb +4 -4
- data/lib/square/api/o_auth_api.rb +78 -25
- data/lib/square/api/order_custom_attributes_api.rb +601 -0
- data/lib/square/api/orders_api.rb +84 -45
- data/lib/square/api/payments_api.rb +72 -24
- data/lib/square/api/payouts_api.rb +173 -0
- data/lib/square/api/refunds_api.rb +18 -7
- data/lib/square/api/sites_api.rb +43 -0
- data/lib/square/api/snippets_api.rb +146 -0
- data/lib/square/api/subscriptions_api.rb +190 -15
- data/lib/square/api/team_api.rb +46 -46
- data/lib/square/api/terminal_api.rb +172 -22
- data/lib/square/api/transactions_api.rb +15 -191
- data/lib/square/api/v1_transactions_api.rb +52 -124
- data/lib/square/api/vendors_api.rb +257 -0
- data/lib/square/api/webhook_subscriptions_api.rb +327 -0
- data/lib/square/api_helper.rb +217 -57
- data/lib/square/client.rb +90 -18
- data/lib/square/configuration.rb +64 -20
- data/lib/square/exceptions/validation_exception.rb +13 -0
- data/lib/square/http/api_response.rb +7 -9
- data/lib/square/http/faraday_client.rb +40 -9
- data/lib/square/http/http_client.rb +31 -12
- data/lib/square/http/http_request.rb +6 -2
- data/lib/square/utilities/date_time_helper.rb +151 -0
- data/lib/square/utilities/file_wrapper.rb +1 -2
- data/lib/square.rb +56 -44
- data/test/api/test_locations_api.rb +2 -5
- data/test/test_helper.rb +2 -2
- metadata +83 -15
- data/lib/square/api/v1_employees_api.rb +0 -751
- data/lib/square/api/v1_items_api.rb +0 -1766
@@ -5,7 +5,78 @@ module Square
|
|
5
5
|
super(config, http_call_back: http_call_back)
|
6
6
|
end
|
7
7
|
|
8
|
+
# Retrieve a collection of bookings.
|
9
|
+
# To call this endpoint with buyer-level permissions, set
|
10
|
+
# `APPOINTMENTS_READ` for the OAuth scope.
|
11
|
+
# To call this endpoint with seller-level permissions, set
|
12
|
+
# `APPOINTMENTS_ALL_READ` and `APPOINTMENTS_READ` for the OAuth scope.
|
13
|
+
# @param [Integer] limit Optional parameter: The maximum number of results
|
14
|
+
# per page to return in a paged response.
|
15
|
+
# @param [String] cursor Optional parameter: The pagination cursor from the
|
16
|
+
# preceding response to return the next page of the results. Do not set this
|
17
|
+
# when retrieving the first page of the results.
|
18
|
+
# @param [String] team_member_id Optional parameter: The team member for
|
19
|
+
# whom to retrieve bookings. If this is not set, bookings of all members are
|
20
|
+
# retrieved.
|
21
|
+
# @param [String] location_id Optional parameter: The location for which to
|
22
|
+
# retrieve bookings. If this is not set, all locations' bookings are
|
23
|
+
# retrieved.
|
24
|
+
# @param [String] start_at_min Optional parameter: The RFC 3339 timestamp
|
25
|
+
# specifying the earliest of the start time. If this is not set, the current
|
26
|
+
# time is used.
|
27
|
+
# @param [String] start_at_max Optional parameter: The RFC 3339 timestamp
|
28
|
+
# specifying the latest of the start time. If this is not set, the time of
|
29
|
+
# 31 days after `start_at_min` is used.
|
30
|
+
# @return [ListBookingsResponse Hash] response from the API call
|
31
|
+
def list_bookings(limit: nil,
|
32
|
+
cursor: nil,
|
33
|
+
team_member_id: nil,
|
34
|
+
location_id: nil,
|
35
|
+
start_at_min: nil,
|
36
|
+
start_at_max: nil)
|
37
|
+
# Prepare query url.
|
38
|
+
_query_builder = config.get_base_uri
|
39
|
+
_query_builder << '/v2/bookings'
|
40
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
41
|
+
_query_builder,
|
42
|
+
'limit' => limit,
|
43
|
+
'cursor' => cursor,
|
44
|
+
'team_member_id' => team_member_id,
|
45
|
+
'location_id' => location_id,
|
46
|
+
'start_at_min' => start_at_min,
|
47
|
+
'start_at_max' => start_at_max
|
48
|
+
)
|
49
|
+
_query_url = APIHelper.clean_url _query_builder
|
50
|
+
|
51
|
+
# Prepare headers.
|
52
|
+
_headers = {
|
53
|
+
'accept' => 'application/json'
|
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
|
+
)
|
70
|
+
end
|
71
|
+
|
8
72
|
# Creates a booking.
|
73
|
+
# To call this endpoint with buyer-level permissions, set
|
74
|
+
# `APPOINTMENTS_WRITE` for the OAuth scope.
|
75
|
+
# To call this endpoint with seller-level permissions, set
|
76
|
+
# `APPOINTMENTS_ALL_WRITE` and `APPOINTMENTS_WRITE` for the OAuth scope.
|
77
|
+
# For calls to this endpoint with seller-level permissions to succeed, the
|
78
|
+
# seller must have subscribed to *Appointments Plus*
|
79
|
+
# or *Appointments Premium*.
|
9
80
|
# @param [CreateBookingRequest] body Required parameter: An object
|
10
81
|
# containing the fields to POST for the request. See the corresponding
|
11
82
|
# object definition for field details.
|
@@ -19,7 +90,7 @@ module Square
|
|
19
90
|
# Prepare headers.
|
20
91
|
_headers = {
|
21
92
|
'accept' => 'application/json',
|
22
|
-
'
|
93
|
+
'Content-Type' => 'application/json'
|
23
94
|
}
|
24
95
|
|
25
96
|
# Prepare and execute HttpRequest.
|
@@ -40,6 +111,10 @@ module Square
|
|
40
111
|
end
|
41
112
|
|
42
113
|
# Searches for availabilities for booking.
|
114
|
+
# To call this endpoint with buyer-level permissions, set
|
115
|
+
# `APPOINTMENTS_READ` for the OAuth scope.
|
116
|
+
# To call this endpoint with seller-level permissions, set
|
117
|
+
# `APPOINTMENTS_ALL_READ` and `APPOINTMENTS_READ` for the OAuth scope.
|
43
118
|
# @param [SearchAvailabilityRequest] body Required parameter: An object
|
44
119
|
# containing the fields to POST for the request. See the corresponding
|
45
120
|
# object definition for field details.
|
@@ -53,7 +128,7 @@ module Square
|
|
53
128
|
# Prepare headers.
|
54
129
|
_headers = {
|
55
130
|
'accept' => 'application/json',
|
56
|
-
'
|
131
|
+
'Content-Type' => 'application/json'
|
57
132
|
}
|
58
133
|
|
59
134
|
# Prepare and execute HttpRequest.
|
@@ -103,13 +178,14 @@ module Square
|
|
103
178
|
end
|
104
179
|
|
105
180
|
# Lists booking profiles for team members.
|
106
|
-
# @param [
|
107
|
-
# include only bookable team members in the returned result
|
108
|
-
# (`false`).
|
181
|
+
# @param [TrueClass|FalseClass] bookable_only Optional parameter: Indicates
|
182
|
+
# whether to include only bookable team members in the returned result
|
183
|
+
# (`true`) or not (`false`).
|
109
184
|
# @param [Integer] limit Optional parameter: The maximum number of results
|
110
|
-
# to return.
|
111
|
-
# @param [String] cursor Optional parameter: The cursor
|
112
|
-
#
|
185
|
+
# to return in a paged response.
|
186
|
+
# @param [String] cursor Optional parameter: The pagination cursor from the
|
187
|
+
# preceding response to return the next page of the results. Do not set this
|
188
|
+
# when retrieving the first page of the results.
|
113
189
|
# @param [String] location_id Optional parameter: Indicates whether to
|
114
190
|
# include only team members enabled at the given location in the returned
|
115
191
|
# result.
|
@@ -187,9 +263,12 @@ module Square
|
|
187
263
|
end
|
188
264
|
|
189
265
|
# Retrieves a booking.
|
266
|
+
# To call this endpoint with buyer-level permissions, set
|
267
|
+
# `APPOINTMENTS_READ` for the OAuth scope.
|
268
|
+
# To call this endpoint with seller-level permissions, set
|
269
|
+
# `APPOINTMENTS_ALL_READ` and `APPOINTMENTS_READ` for the OAuth scope.
|
190
270
|
# @param [String] booking_id Required parameter: The ID of the
|
191
|
-
# [Booking](
|
192
|
-
# booking.
|
271
|
+
# [Booking]($m/Booking) object representing the to-be-retrieved booking.
|
193
272
|
# @return [RetrieveBookingResponse Hash] response from the API call
|
194
273
|
def retrieve_booking(booking_id:)
|
195
274
|
# Prepare query url.
|
@@ -223,8 +302,15 @@ module Square
|
|
223
302
|
end
|
224
303
|
|
225
304
|
# Updates a booking.
|
305
|
+
# To call this endpoint with buyer-level permissions, set
|
306
|
+
# `APPOINTMENTS_WRITE` for the OAuth scope.
|
307
|
+
# To call this endpoint with seller-level permissions, set
|
308
|
+
# `APPOINTMENTS_ALL_WRITE` and `APPOINTMENTS_WRITE` for the OAuth scope.
|
309
|
+
# For calls to this endpoint with seller-level permissions to succeed, the
|
310
|
+
# seller must have subscribed to *Appointments Plus*
|
311
|
+
# or *Appointments Premium*.
|
226
312
|
# @param [String] booking_id Required parameter: The ID of the
|
227
|
-
# [Booking](
|
313
|
+
# [Booking]($m/Booking) object representing the to-be-updated booking.
|
228
314
|
# @param [UpdateBookingRequest] body Required parameter: An object
|
229
315
|
# containing the fields to POST for the request. See the corresponding
|
230
316
|
# object definition for field details.
|
@@ -243,7 +329,7 @@ module Square
|
|
243
329
|
# Prepare headers.
|
244
330
|
_headers = {
|
245
331
|
'accept' => 'application/json',
|
246
|
-
'
|
332
|
+
'Content-Type' => 'application/json'
|
247
333
|
}
|
248
334
|
|
249
335
|
# Prepare and execute HttpRequest.
|
@@ -264,9 +350,15 @@ module Square
|
|
264
350
|
end
|
265
351
|
|
266
352
|
# Cancels an existing booking.
|
353
|
+
# To call this endpoint with buyer-level permissions, set
|
354
|
+
# `APPOINTMENTS_WRITE` for the OAuth scope.
|
355
|
+
# To call this endpoint with seller-level permissions, set
|
356
|
+
# `APPOINTMENTS_ALL_WRITE` and `APPOINTMENTS_WRITE` for the OAuth scope.
|
357
|
+
# For calls to this endpoint with seller-level permissions to succeed, the
|
358
|
+
# seller must have subscribed to *Appointments Plus*
|
359
|
+
# or *Appointments Premium*.
|
267
360
|
# @param [String] booking_id Required parameter: The ID of the
|
268
|
-
# [Booking](
|
269
|
-
# booking.
|
361
|
+
# [Booking]($m/Booking) object representing the to-be-cancelled booking.
|
270
362
|
# @param [CancelBookingRequest] body Required parameter: An object
|
271
363
|
# containing the fields to POST for the request. See the corresponding
|
272
364
|
# object definition for field details.
|
@@ -285,7 +377,7 @@ module Square
|
|
285
377
|
# Prepare headers.
|
286
378
|
_headers = {
|
287
379
|
'accept' => 'application/json',
|
288
|
-
'
|
380
|
+
'Content-Type' => 'application/json'
|
289
381
|
}
|
290
382
|
|
291
383
|
# Prepare and execute HttpRequest.
|
@@ -0,0 +1,171 @@
|
|
1
|
+
module Square
|
2
|
+
# CardsApi
|
3
|
+
class CardsApi < BaseApi
|
4
|
+
def initialize(config, http_call_back: nil)
|
5
|
+
super(config, http_call_back: http_call_back)
|
6
|
+
end
|
7
|
+
|
8
|
+
# Retrieves a list of cards owned by the account making the request.
|
9
|
+
# A max of 25 cards will be returned.
|
10
|
+
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
11
|
+
# a previous call to this endpoint. Provide this to retrieve the next set of
|
12
|
+
# results for your original query. See
|
13
|
+
# [Pagination](https://developer.squareup.com/docs/basics/api101/pagination)
|
14
|
+
# for more information.
|
15
|
+
# @param [String] customer_id Optional parameter: Limit results to cards
|
16
|
+
# associated with the customer supplied. By default, all cards owned by the
|
17
|
+
# merchant are returned.
|
18
|
+
# @param [TrueClass|FalseClass] include_disabled Optional parameter:
|
19
|
+
# Includes disabled cards. By default, all enabled cards owned by the
|
20
|
+
# merchant are returned.
|
21
|
+
# @param [String] reference_id Optional parameter: Limit results to cards
|
22
|
+
# associated with the reference_id supplied.
|
23
|
+
# @param [SortOrder] sort_order Optional parameter: Sorts the returned list
|
24
|
+
# by when the card was created with the specified order. This field defaults
|
25
|
+
# to ASC.
|
26
|
+
# @return [ListCardsResponse Hash] response from the API call
|
27
|
+
def list_cards(cursor: nil,
|
28
|
+
customer_id: nil,
|
29
|
+
include_disabled: false,
|
30
|
+
reference_id: nil,
|
31
|
+
sort_order: nil)
|
32
|
+
# Prepare query url.
|
33
|
+
_query_builder = config.get_base_uri
|
34
|
+
_query_builder << '/v2/cards'
|
35
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
36
|
+
_query_builder,
|
37
|
+
'cursor' => cursor,
|
38
|
+
'customer_id' => customer_id,
|
39
|
+
'include_disabled' => include_disabled,
|
40
|
+
'reference_id' => reference_id,
|
41
|
+
'sort_order' => sort_order
|
42
|
+
)
|
43
|
+
_query_url = APIHelper.clean_url _query_builder
|
44
|
+
|
45
|
+
# Prepare headers.
|
46
|
+
_headers = {
|
47
|
+
'accept' => 'application/json'
|
48
|
+
}
|
49
|
+
|
50
|
+
# Prepare and execute HttpRequest.
|
51
|
+
_request = config.http_client.get(
|
52
|
+
_query_url,
|
53
|
+
headers: _headers
|
54
|
+
)
|
55
|
+
OAuth2.apply(config, _request)
|
56
|
+
_response = execute_request(_request)
|
57
|
+
|
58
|
+
# Return appropriate response type.
|
59
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
60
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
61
|
+
ApiResponse.new(
|
62
|
+
_response, data: decoded, errors: _errors
|
63
|
+
)
|
64
|
+
end
|
65
|
+
|
66
|
+
# Adds a card on file to an existing merchant.
|
67
|
+
# @param [CreateCardRequest] body Required parameter: An object containing
|
68
|
+
# the fields to POST for the request. See the corresponding object
|
69
|
+
# definition for field details.
|
70
|
+
# @return [CreateCardResponse Hash] response from the API call
|
71
|
+
def create_card(body:)
|
72
|
+
# Prepare query url.
|
73
|
+
_query_builder = config.get_base_uri
|
74
|
+
_query_builder << '/v2/cards'
|
75
|
+
_query_url = APIHelper.clean_url _query_builder
|
76
|
+
|
77
|
+
# Prepare headers.
|
78
|
+
_headers = {
|
79
|
+
'accept' => 'application/json',
|
80
|
+
'Content-Type' => 'application/json'
|
81
|
+
}
|
82
|
+
|
83
|
+
# Prepare and execute HttpRequest.
|
84
|
+
_request = config.http_client.post(
|
85
|
+
_query_url,
|
86
|
+
headers: _headers,
|
87
|
+
parameters: body.to_json
|
88
|
+
)
|
89
|
+
OAuth2.apply(config, _request)
|
90
|
+
_response = execute_request(_request)
|
91
|
+
|
92
|
+
# Return appropriate response type.
|
93
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
94
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
95
|
+
ApiResponse.new(
|
96
|
+
_response, data: decoded, errors: _errors
|
97
|
+
)
|
98
|
+
end
|
99
|
+
|
100
|
+
# Retrieves details for a specific Card.
|
101
|
+
# @param [String] card_id Required parameter: Unique ID for the desired
|
102
|
+
# Card.
|
103
|
+
# @return [RetrieveCardResponse Hash] response from the API call
|
104
|
+
def retrieve_card(card_id:)
|
105
|
+
# Prepare query url.
|
106
|
+
_query_builder = config.get_base_uri
|
107
|
+
_query_builder << '/v2/cards/{card_id}'
|
108
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
109
|
+
_query_builder,
|
110
|
+
'card_id' => { 'value' => card_id, 'encode' => true }
|
111
|
+
)
|
112
|
+
_query_url = APIHelper.clean_url _query_builder
|
113
|
+
|
114
|
+
# Prepare headers.
|
115
|
+
_headers = {
|
116
|
+
'accept' => 'application/json'
|
117
|
+
}
|
118
|
+
|
119
|
+
# Prepare and execute HttpRequest.
|
120
|
+
_request = config.http_client.get(
|
121
|
+
_query_url,
|
122
|
+
headers: _headers
|
123
|
+
)
|
124
|
+
OAuth2.apply(config, _request)
|
125
|
+
_response = execute_request(_request)
|
126
|
+
|
127
|
+
# Return appropriate response type.
|
128
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
129
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
130
|
+
ApiResponse.new(
|
131
|
+
_response, data: decoded, errors: _errors
|
132
|
+
)
|
133
|
+
end
|
134
|
+
|
135
|
+
# Disables the card, preventing any further updates or charges.
|
136
|
+
# Disabling an already disabled card is allowed but has no effect.
|
137
|
+
# @param [String] card_id Required parameter: Unique ID for the desired
|
138
|
+
# Card.
|
139
|
+
# @return [DisableCardResponse Hash] response from the API call
|
140
|
+
def disable_card(card_id:)
|
141
|
+
# Prepare query url.
|
142
|
+
_query_builder = config.get_base_uri
|
143
|
+
_query_builder << '/v2/cards/{card_id}/disable'
|
144
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
145
|
+
_query_builder,
|
146
|
+
'card_id' => { 'value' => card_id, 'encode' => true }
|
147
|
+
)
|
148
|
+
_query_url = APIHelper.clean_url _query_builder
|
149
|
+
|
150
|
+
# Prepare headers.
|
151
|
+
_headers = {
|
152
|
+
'accept' => 'application/json'
|
153
|
+
}
|
154
|
+
|
155
|
+
# Prepare and execute HttpRequest.
|
156
|
+
_request = config.http_client.post(
|
157
|
+
_query_url,
|
158
|
+
headers: _headers
|
159
|
+
)
|
160
|
+
OAuth2.apply(config, _request)
|
161
|
+
_response = execute_request(_request)
|
162
|
+
|
163
|
+
# Return appropriate response type.
|
164
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
165
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
166
|
+
ApiResponse.new(
|
167
|
+
_response, data: decoded, errors: _errors
|
168
|
+
)
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
@@ -63,8 +63,8 @@ module Square
|
|
63
63
|
end
|
64
64
|
|
65
65
|
# Provides the summary details for a single cash drawer shift. See
|
66
|
-
# [ListCashDrawerShiftEvents](
|
67
|
-
#
|
66
|
+
# [ListCashDrawerShiftEvents]($e/CashDrawers/ListCashDrawerShiftEvents) for
|
67
|
+
# a list of cash drawer shift events.
|
68
68
|
# @param [String] location_id Required parameter: The ID of the location to
|
69
69
|
# retrieve cash drawer shifts from.
|
70
70
|
# @param [String] shift_id Required parameter: The shift ID.
|