square.rb 6.3.0.20200826 → 17.1.0.20220120
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/README.md +86 -51
- data/lib/square/api/apple_pay_api.rb +12 -9
- data/lib/square/api/bank_accounts_api.rb +21 -24
- data/lib/square/api/base_api.rb +20 -9
- data/lib/square/api/bookings_api.rb +391 -0
- data/lib/square/api/cards_api.rb +170 -0
- data/lib/square/api/cash_drawers_api.rb +13 -6
- data/lib/square/api/catalog_api.rb +195 -85
- data/lib/square/api/checkout_api.rb +7 -5
- data/lib/square/api/customer_groups_api.rb +34 -16
- data/lib/square/api/customer_segments_api.rb +21 -9
- data/lib/square/api/customers_api.rb +102 -55
- data/lib/square/api/devices_api.rb +20 -8
- data/lib/square/api/disputes_api.rb +156 -144
- data/lib/square/api/employees_api.rb +7 -3
- data/lib/square/api/gift_card_activities_api.rb +133 -0
- data/lib/square/api/gift_cards_api.rb +297 -0
- data/lib/square/api/inventory_api.rb +290 -37
- data/lib/square/api/invoices_api.rb +61 -57
- data/lib/square/api/labor_api.rb +127 -93
- data/lib/square/api/locations_api.rb +36 -25
- data/lib/square/api/loyalty_api.rb +134 -87
- data/lib/square/api/merchants_api.rb +8 -4
- data/lib/square/api/mobile_authorization_api.rb +9 -7
- data/lib/square/api/o_auth_api.rb +41 -32
- data/lib/square/api/orders_api.rb +132 -54
- data/lib/square/api/payments_api.rb +133 -75
- data/lib/square/api/refunds_api.rb +51 -30
- 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 +216 -26
- data/lib/square/api/team_api.rb +81 -65
- data/lib/square/api/terminal_api.rb +166 -16
- data/lib/square/api/transactions_api.rb +32 -194
- data/lib/square/api/v1_transactions_api.rb +53 -103
- data/lib/square/api_helper.rb +38 -43
- data/lib/square/client.rb +54 -24
- data/lib/square/configuration.rb +61 -21
- data/lib/square/http/api_response.rb +3 -1
- data/lib/square/http/faraday_client.rb +34 -5
- data/lib/square/utilities/date_time_helper.rb +151 -0
- data/lib/square/utilities/file_wrapper.rb +1 -2
- data/lib/square.rb +65 -61
- data/spec/user_journey_spec.rb +2 -5
- data/test/api/api_test_base.rb +1 -6
- data/test/api/test_catalog_api.rb +1 -4
- data/test/api/test_customers_api.rb +1 -4
- data/test/api/test_employees_api.rb +1 -4
- data/test/api/test_labor_api.rb +2 -6
- data/test/api/test_locations_api.rb +21 -35
- data/test/api/test_merchants_api.rb +1 -4
- data/test/api/test_payments_api.rb +3 -6
- data/test/api/test_refunds_api.rb +3 -6
- data/test/http_response_catcher.rb +0 -5
- data/test/test_helper.rb +1 -6
- metadata +40 -18
- data/lib/square/api/v1_employees_api.rb +0 -723
- data/lib/square/api/v1_items_api.rb +0 -1686
- data/lib/square/api/v1_locations_api.rb +0 -65
@@ -7,19 +7,16 @@ module Square
|
|
7
7
|
|
8
8
|
# Returns a list of invoices for a given location. The response
|
9
9
|
# is paginated. If truncated, the response includes a `cursor` that you
|
10
|
-
# use in a subsequent request to
|
11
|
-
# For more information about retrieving invoices, see [Retrieve
|
12
|
-
# invoices](https://developer.squareup.com/docs/docs/invoices-api/overview#r
|
13
|
-
# etrieve-invoices).
|
10
|
+
# use in a subsequent request to retrieve the next set of invoices.
|
14
11
|
# @param [String] location_id Required parameter: The ID of the location for
|
15
12
|
# which to list invoices.
|
16
13
|
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
17
14
|
# a previous call to this endpoint. Provide this cursor to retrieve the
|
18
15
|
# next set of results for your original query. For more information, see
|
19
|
-
# [Pagination](https://developer.squareup.com/docs/
|
20
|
-
#
|
16
|
+
# [Pagination](https://developer.squareup.com/docs/working-with-apis/paginat
|
17
|
+
# ion).
|
21
18
|
# @param [Integer] limit Optional parameter: The maximum number of invoices
|
22
|
-
# to return (200 is the maximum `limit`). If not provided, the server
|
19
|
+
# to return (200 is the maximum `limit`). If not provided, the server uses
|
23
20
|
# a default limit of 100 invoices.
|
24
21
|
# @return [ListInvoicesResponse Hash] response from the API call
|
25
22
|
def list_invoices(location_id:,
|
@@ -52,16 +49,16 @@ module Square
|
|
52
49
|
# Return appropriate response type.
|
53
50
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
54
51
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
55
|
-
ApiResponse.new(
|
52
|
+
ApiResponse.new(
|
53
|
+
_response, data: decoded, errors: _errors
|
54
|
+
)
|
56
55
|
end
|
57
56
|
|
58
|
-
# Creates a draft [invoice](
|
57
|
+
# Creates a draft [invoice]($m/Invoice)
|
59
58
|
# for an order created using the Orders API.
|
60
59
|
# A draft invoice remains in your account and no action is taken.
|
61
60
|
# You must publish the invoice before Square can process it (send it to the
|
62
61
|
# customer's email address or charge the customer’s card on file).
|
63
|
-
# For more information, see [Manage Invoices Using the Invoices
|
64
|
-
# API](https://developer.squareup.com/docs/docs/invoices-api/overview).
|
65
62
|
# @param [CreateInvoiceRequest] body Required parameter: An object
|
66
63
|
# containing the fields to POST for the request. See the corresponding
|
67
64
|
# object definition for field details.
|
@@ -75,7 +72,7 @@ module Square
|
|
75
72
|
# Prepare headers.
|
76
73
|
_headers = {
|
77
74
|
'accept' => 'application/json',
|
78
|
-
'
|
75
|
+
'Content-Type' => 'application/json'
|
79
76
|
}
|
80
77
|
|
81
78
|
# Prepare and execute HttpRequest.
|
@@ -90,7 +87,9 @@ module Square
|
|
90
87
|
# Return appropriate response type.
|
91
88
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
92
89
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
93
|
-
ApiResponse.new(
|
90
|
+
ApiResponse.new(
|
91
|
+
_response, data: decoded, errors: _errors
|
92
|
+
)
|
94
93
|
end
|
95
94
|
|
96
95
|
# Searches for invoices from a location specified in
|
@@ -99,10 +98,7 @@ module Square
|
|
99
98
|
# location and
|
100
99
|
# optionally one customer.
|
101
100
|
# The response is paginated. If truncated, the response includes a `cursor`
|
102
|
-
# that you use in a subsequent request to
|
103
|
-
# For more information about retrieving invoices, see [Retrieve
|
104
|
-
# invoices](https://developer.squareup.com/docs/docs/invoices-api/overview#r
|
105
|
-
# etrieve-invoices).
|
101
|
+
# that you use in a subsequent request to retrieve the next set of invoices.
|
106
102
|
# @param [SearchInvoicesRequest] body Required parameter: An object
|
107
103
|
# containing the fields to POST for the request. See the corresponding
|
108
104
|
# object definition for field details.
|
@@ -116,7 +112,7 @@ module Square
|
|
116
112
|
# Prepare headers.
|
117
113
|
_headers = {
|
118
114
|
'accept' => 'application/json',
|
119
|
-
'
|
115
|
+
'Content-Type' => 'application/json'
|
120
116
|
}
|
121
117
|
|
122
118
|
# Prepare and execute HttpRequest.
|
@@ -131,19 +127,21 @@ module Square
|
|
131
127
|
# Return appropriate response type.
|
132
128
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
133
129
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
134
|
-
ApiResponse.new(
|
130
|
+
ApiResponse.new(
|
131
|
+
_response, data: decoded, errors: _errors
|
132
|
+
)
|
135
133
|
end
|
136
134
|
|
137
135
|
# Deletes the specified invoice. When an invoice is deleted, the
|
138
|
-
# associated
|
139
|
-
# invoice (you cannot delete
|
140
|
-
#
|
136
|
+
# associated order status changes to CANCELED. You can only delete a draft
|
137
|
+
# invoice (you cannot delete a published invoice, including one that is
|
138
|
+
# scheduled for processing).
|
141
139
|
# @param [String] invoice_id Required parameter: The ID of the invoice to
|
142
140
|
# delete.
|
143
141
|
# @param [Integer] version Optional parameter: The version of the
|
144
|
-
# [invoice](
|
145
|
-
#
|
146
|
-
# [ListInvoices](
|
142
|
+
# [invoice]($m/Invoice) to delete. If you do not know the version, you can
|
143
|
+
# call [GetInvoice]($e/Invoices/GetInvoice) or
|
144
|
+
# [ListInvoices]($e/Invoices/ListInvoices).
|
147
145
|
# @return [DeleteInvoiceResponse Hash] response from the API call
|
148
146
|
def delete_invoice(invoice_id:,
|
149
147
|
version: nil)
|
@@ -152,7 +150,7 @@ module Square
|
|
152
150
|
_query_builder << '/v2/invoices/{invoice_id}'
|
153
151
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
154
152
|
_query_builder,
|
155
|
-
'invoice_id' => invoice_id
|
153
|
+
'invoice_id' => { 'value' => invoice_id, 'encode' => true }
|
156
154
|
)
|
157
155
|
_query_builder = APIHelper.append_url_with_query_parameters(
|
158
156
|
_query_builder,
|
@@ -176,11 +174,13 @@ module Square
|
|
176
174
|
# Return appropriate response type.
|
177
175
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
178
176
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
179
|
-
ApiResponse.new(
|
177
|
+
ApiResponse.new(
|
178
|
+
_response, data: decoded, errors: _errors
|
179
|
+
)
|
180
180
|
end
|
181
181
|
|
182
182
|
# Retrieves an invoice by invoice ID.
|
183
|
-
# @param [String] invoice_id Required parameter: The
|
183
|
+
# @param [String] invoice_id Required parameter: The ID of the invoice to
|
184
184
|
# retrieve.
|
185
185
|
# @return [GetInvoiceResponse Hash] response from the API call
|
186
186
|
def get_invoice(invoice_id:)
|
@@ -189,7 +189,7 @@ module Square
|
|
189
189
|
_query_builder << '/v2/invoices/{invoice_id}'
|
190
190
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
191
191
|
_query_builder,
|
192
|
-
'invoice_id' => invoice_id
|
192
|
+
'invoice_id' => { 'value' => invoice_id, 'encode' => true }
|
193
193
|
)
|
194
194
|
_query_url = APIHelper.clean_url _query_builder
|
195
195
|
|
@@ -209,18 +209,20 @@ module Square
|
|
209
209
|
# Return appropriate response type.
|
210
210
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
211
211
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
212
|
-
ApiResponse.new(
|
212
|
+
ApiResponse.new(
|
213
|
+
_response, data: decoded, errors: _errors
|
214
|
+
)
|
213
215
|
end
|
214
216
|
|
215
|
-
# Updates an invoice by modifying
|
216
|
-
#
|
217
|
-
#
|
218
|
-
#
|
219
|
-
# However,
|
220
|
-
#
|
221
|
-
#
|
222
|
-
#
|
223
|
-
# @param [String] invoice_id Required parameter: The
|
217
|
+
# Updates an invoice by modifying fields, clearing fields, or both. For most
|
218
|
+
# updates, you can use a sparse
|
219
|
+
# `Invoice` object to add fields or change values and use the
|
220
|
+
# `fields_to_clear` field to specify fields to clear.
|
221
|
+
# However, some restrictions apply. For example, you cannot change the
|
222
|
+
# `order_id` or `location_id` field and you
|
223
|
+
# must provide the complete `custom_fields` list to update a custom field.
|
224
|
+
# Published invoices have additional restrictions.
|
225
|
+
# @param [String] invoice_id Required parameter: The ID of the invoice to
|
224
226
|
# update.
|
225
227
|
# @param [UpdateInvoiceRequest] body Required parameter: An object
|
226
228
|
# containing the fields to POST for the request. See the corresponding
|
@@ -233,14 +235,14 @@ module Square
|
|
233
235
|
_query_builder << '/v2/invoices/{invoice_id}'
|
234
236
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
235
237
|
_query_builder,
|
236
|
-
'invoice_id' => invoice_id
|
238
|
+
'invoice_id' => { 'value' => invoice_id, 'encode' => true }
|
237
239
|
)
|
238
240
|
_query_url = APIHelper.clean_url _query_builder
|
239
241
|
|
240
242
|
# Prepare headers.
|
241
243
|
_headers = {
|
242
244
|
'accept' => 'application/json',
|
243
|
-
'
|
245
|
+
'Content-Type' => 'application/json'
|
244
246
|
}
|
245
247
|
|
246
248
|
# Prepare and execute HttpRequest.
|
@@ -255,15 +257,17 @@ module Square
|
|
255
257
|
# Return appropriate response type.
|
256
258
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
257
259
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
258
|
-
ApiResponse.new(
|
260
|
+
ApiResponse.new(
|
261
|
+
_response, data: decoded, errors: _errors
|
262
|
+
)
|
259
263
|
end
|
260
264
|
|
261
265
|
# Cancels an invoice. The seller cannot collect payments for
|
262
266
|
# the canceled invoice.
|
263
|
-
# You cannot cancel an invoice in a terminal state:
|
264
|
-
# `CANCELED`, or `FAILED`.
|
267
|
+
# You cannot cancel an invoice in the `DRAFT` state or in a terminal state:
|
268
|
+
# `PAID`, `REFUNDED`, `CANCELED`, or `FAILED`.
|
265
269
|
# @param [String] invoice_id Required parameter: The ID of the
|
266
|
-
# [invoice](
|
270
|
+
# [invoice]($m/Invoice) to cancel.
|
267
271
|
# @param [CancelInvoiceRequest] body Required parameter: An object
|
268
272
|
# containing the fields to POST for the request. See the corresponding
|
269
273
|
# object definition for field details.
|
@@ -275,14 +279,14 @@ module Square
|
|
275
279
|
_query_builder << '/v2/invoices/{invoice_id}/cancel'
|
276
280
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
277
281
|
_query_builder,
|
278
|
-
'invoice_id' => invoice_id
|
282
|
+
'invoice_id' => { 'value' => invoice_id, 'encode' => true }
|
279
283
|
)
|
280
284
|
_query_url = APIHelper.clean_url _query_builder
|
281
285
|
|
282
286
|
# Prepare headers.
|
283
287
|
_headers = {
|
284
288
|
'accept' => 'application/json',
|
285
|
-
'
|
289
|
+
'Content-Type' => 'application/json'
|
286
290
|
}
|
287
291
|
|
288
292
|
# Prepare and execute HttpRequest.
|
@@ -297,7 +301,9 @@ module Square
|
|
297
301
|
# Return appropriate response type.
|
298
302
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
299
303
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
300
|
-
ApiResponse.new(
|
304
|
+
ApiResponse.new(
|
305
|
+
_response, data: decoded, errors: _errors
|
306
|
+
)
|
301
307
|
end
|
302
308
|
|
303
309
|
# Publishes the specified draft invoice.
|
@@ -312,12 +318,8 @@ module Square
|
|
312
318
|
# `UNPAID` if
|
313
319
|
# Square emails the invoice or `PARTIALLY_PAID` if Square charge a card on
|
314
320
|
# file for a portion of the
|
315
|
-
# invoice amount
|
316
|
-
#
|
317
|
-
# [Create and publish an
|
318
|
-
# invoice](https://developer.squareup.com/docs/docs/invoices-api/overview#cr
|
319
|
-
# eate-and-publish-an-invoice).
|
320
|
-
# @param [String] invoice_id Required parameter: The id of the invoice to
|
321
|
+
# invoice amount.
|
322
|
+
# @param [String] invoice_id Required parameter: The ID of the invoice to
|
321
323
|
# publish.
|
322
324
|
# @param [PublishInvoiceRequest] body Required parameter: An object
|
323
325
|
# containing the fields to POST for the request. See the corresponding
|
@@ -330,14 +332,14 @@ module Square
|
|
330
332
|
_query_builder << '/v2/invoices/{invoice_id}/publish'
|
331
333
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
332
334
|
_query_builder,
|
333
|
-
'invoice_id' => invoice_id
|
335
|
+
'invoice_id' => { 'value' => invoice_id, 'encode' => true }
|
334
336
|
)
|
335
337
|
_query_url = APIHelper.clean_url _query_builder
|
336
338
|
|
337
339
|
# Prepare headers.
|
338
340
|
_headers = {
|
339
341
|
'accept' => 'application/json',
|
340
|
-
'
|
342
|
+
'Content-Type' => 'application/json'
|
341
343
|
}
|
342
344
|
|
343
345
|
# Prepare and execute HttpRequest.
|
@@ -352,7 +354,9 @@ module Square
|
|
352
354
|
# Return appropriate response type.
|
353
355
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
354
356
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
355
|
-
ApiResponse.new(
|
357
|
+
ApiResponse.new(
|
358
|
+
_response, data: decoded, errors: _errors
|
359
|
+
)
|
356
360
|
end
|
357
361
|
end
|
358
362
|
end
|