square.rb 6.5.0.20201028 → 9.1.0.20210317

Sign up to get free protection for your applications and to get access to all the features.
@@ -63,7 +63,8 @@ module Square
63
63
  end
64
64
 
65
65
  # Provides the summary details for a single cash drawer shift. See
66
- # RetrieveCashDrawerShiftEvents for a list of cash drawer shift events.
66
+ # [ListCashDrawerShiftEvents](#endpoint-CashDrawers-ListCashDrawerShiftEvent
67
+ # s) for a list of cash drawer shift events.
67
68
  # @param [String] location_id Required parameter: The ID of the location to
68
69
  # retrieve cash drawer shifts from.
69
70
  # @param [String] shift_id Required parameter: The shift ID.
@@ -239,9 +239,9 @@ module Square
239
239
  # `DISCOUNT`, `TAX`, `IMAGE`.
240
240
  # __Important:__ ListCatalog does not return deleted catalog items. To
241
241
  # retrieve
242
- # deleted catalog items, use SearchCatalogObjects and set
243
- # `include_deleted_objects`
244
- # to `true`.
242
+ # deleted catalog items, use
243
+ # [SearchCatalogObjects](#endpoint-Catalog-SearchCatalogObjects)
244
+ # and set the `include_deleted_objects` attribute value to `true`.
245
245
  # @param [String] cursor Optional parameter: The pagination cursor returned
246
246
  # in the previous response. Leave unset for an initial request. See
247
247
  # [Pagination](https://developer.squareup.com/docs/basics/api101/pagination)
@@ -251,16 +251,23 @@ module Square
251
251
  # `ITEM,ITEM_VARIATION,CATEGORY,IMAGE`. The legal values are taken from the
252
252
  # CatalogObjectType enum: `ITEM`, `ITEM_VARIATION`, `CATEGORY`, `DISCOUNT`,
253
253
  # `TAX`, `MODIFIER`, `MODIFIER_LIST`, or `IMAGE`.
254
+ # @param [Long] catalog_version Optional parameter: The specific version of
255
+ # the catalog objects to be included in the response. This allows you to
256
+ # retrieve historical versions of objects. The specified version value is
257
+ # matched against the [CatalogObject](#type-catalogobject)s' `version`
258
+ # attribute.
254
259
  # @return [ListCatalogResponse Hash] response from the API call
255
260
  def list_catalog(cursor: nil,
256
- types: nil)
261
+ types: nil,
262
+ catalog_version: nil)
257
263
  # Prepare query url.
258
264
  _query_builder = config.get_base_uri
259
265
  _query_builder << '/v2/catalog/list'
260
266
  _query_builder = APIHelper.append_url_with_query_parameters(
261
267
  _query_builder,
262
268
  'cursor' => cursor,
263
- 'types' => types
269
+ 'types' => types,
270
+ 'catalog_version' => catalog_version
264
271
  )
265
272
  _query_url = APIHelper.clean_url _query_builder
266
273
 
@@ -382,9 +389,15 @@ module Square
382
389
  # response contains a `CatalogItemVariation`, its parent `CatalogItem` will
383
390
  # be returned in the `related_objects` field of the response. Default
384
391
  # value: `false`
392
+ # @param [Long] catalog_version Optional parameter: Requests objects as of a
393
+ # specific version of the catalog. This allows you to retrieve historical
394
+ # versions of objects. The value to retrieve a specific version of an object
395
+ # can be found in the version field of
396
+ # [CatalogObject](#type-catalogobject)s.
385
397
  # @return [RetrieveCatalogObjectResponse Hash] response from the API call
386
398
  def retrieve_catalog_object(object_id:,
387
- include_related_objects: false)
399
+ include_related_objects: false,
400
+ catalog_version: nil)
388
401
  # Prepare query url.
389
402
  _query_builder = config.get_base_uri
390
403
  _query_builder << '/v2/catalog/object/{object_id}'
@@ -394,7 +407,8 @@ module Square
394
407
  )
395
408
  _query_builder = APIHelper.append_url_with_query_parameters(
396
409
  _query_builder,
397
- 'include_related_objects' => include_related_objects
410
+ 'include_related_objects' => include_related_objects,
411
+ 'catalog_version' => catalog_version
398
412
  )
399
413
  _query_url = APIHelper.clean_url _query_builder
400
414
 
@@ -419,10 +433,10 @@ module Square
419
433
  )
420
434
  end
421
435
 
422
- # Searches for [CatalogObject](#type-CatalogObject) of any types against
436
+ # Searches for [CatalogObject](#type-CatalogObject) of any type by matching
423
437
  # supported search attribute values,
424
438
  # excluding custom attribute values on items or item variations, against one
425
- # or more of the specified query expressions,
439
+ # or more of the specified query expressions.
426
440
  # This (`SearchCatalogObjects`) endpoint differs from the
427
441
  # [SearchCatalogItems](#endpoint-Catalog-SearchCatalogItems)
428
442
  # endpoint in the following aspects:
@@ -472,7 +486,7 @@ module Square
472
486
  # Searches for catalog items or item variations by matching supported search
473
487
  # attribute values, including
474
488
  # custom attribute values, against one or more of the specified query
475
- # expressions,
489
+ # expressions.
476
490
  # This (`SearchCatalogItems`) endpoint differs from the
477
491
  # [SearchCatalogObjects](#endpoint-Catalog-SearchCatalogObjects)
478
492
  # endpoint in the following aspects:
@@ -5,8 +5,8 @@ module Square
5
5
  super(config, http_call_back: http_call_back)
6
6
  end
7
7
 
8
- # Links a `checkoutId` to a `checkout_page_url` that customers will
9
- # be directed to in order to provide their payment information using a
8
+ # Links a `checkoutId` to a `checkout_page_url` that customers are
9
+ # directed to in order to provide their payment information using a
10
10
  # payment processing workflow hosted on connect.squareup.com.
11
11
  # @param [String] location_id Required parameter: The ID of the business
12
12
  # location to associate the checkout with.
@@ -9,8 +9,8 @@ module Square
9
9
  # @param [String] cursor Optional parameter: A pagination cursor returned by
10
10
  # previous calls to __ListCustomerSegments__. Used to retrieve the next set
11
11
  # of query results. See the [Pagination
12
- # guide](https://developer.squareup.com/docs/docs/working-with-apis/paginati
13
- # on) for more information.
12
+ # guide](https://developer.squareup.com/docs/working-with-apis/pagination)
13
+ # for more information.
14
14
  # @return [ListCustomerSegmentsResponse Hash] response from the API call
15
15
  def list_customer_segments(cursor: nil)
16
16
  # Prepare query url.
@@ -5,20 +5,19 @@ module Square
5
5
  super(config, http_call_back: http_call_back)
6
6
  end
7
7
 
8
- # Returns a list of disputes associated
9
- # with a particular account.
8
+ # Returns a list of disputes associated with a particular account.
10
9
  # @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 the original query. For more information, see
13
- # [Paginating](https://developer.squareup.com/docs/basics/api101/pagination)
10
+ # a previous call to this endpoint. Provide this cursor to retrieve the next
11
+ # set of results for the original query. For more information, see
12
+ # [Pagination](https://developer.squareup.com/docs/basics/api101/pagination)
14
13
  # .
15
14
  # @param [DisputeState] states Optional parameter: The dispute states to
16
15
  # filter the result. If not specified, the endpoint returns all open
17
- # disputes (dispute status is not `INQUIRY_CLOSED`, `WON`, or `LOST`).
16
+ # disputes (the dispute status is not `INQUIRY_CLOSED`, `WON`, or `LOST`).
18
17
  # @param [String] location_id Optional parameter: The ID of the location for
19
- # which to return a list of disputes. If not specified, the endpoint
20
- # returns all open disputes (dispute status is not `INQUIRY_CLOSED`, `WON`,
21
- # or `LOST`) associated with all locations.
18
+ # which to return a list of disputes. If not specified, the endpoint returns
19
+ # all open disputes (the dispute status is not `INQUIRY_CLOSED`, `WON`, or
20
+ # `LOST`) associated with all locations.
22
21
  # @return [ListDisputesResponse Hash] response from the API call
23
22
  def list_disputes(cursor: nil,
24
23
  states: nil,
@@ -55,7 +54,7 @@ module Square
55
54
  )
56
55
  end
57
56
 
58
- # Returns details of a specific dispute.
57
+ # Returns details about a specific dispute.
59
58
  # @param [String] dispute_id Required parameter: The ID of the dispute you
60
59
  # want more details about.
61
60
  # @return [RetrieveDisputeResponse Hash] response from the API call
@@ -90,14 +89,14 @@ module Square
90
89
  )
91
90
  end
92
91
 
93
- # Accepts loss on a dispute. Square returns
94
- # the disputed amount to the cardholder and updates the
95
- # dispute state to ACCEPTED.
96
- # Square debits the disputed amount from the seller’s Square
97
- # account. If the Square account balance does not have
98
- # sufficient funds, Square debits the associated bank account.
99
- # @param [String] dispute_id Required parameter: ID of the dispute you want
100
- # to accept.
92
+ # Accepts the loss on a dispute. Square returns the disputed amount to the
93
+ # cardholder and
94
+ # updates the dispute state to ACCEPTED.
95
+ # Square debits the disputed amount from the seller’s Square account. If the
96
+ # Square account
97
+ # does not have sufficient funds, Square debits the associated bank account.
98
+ # @param [String] dispute_id Required parameter: The ID of the dispute you
99
+ # want to accept.
101
100
  # @return [AcceptDisputeResponse Hash] response from the API call
102
101
  def accept_dispute(dispute_id:)
103
102
  # Prepare query url.
@@ -165,8 +164,8 @@ module Square
165
164
  end
166
165
 
167
166
  # Removes specified evidence from a dispute.
168
- # Square does not send the bank any evidence that
169
- # is removed. Also, you cannot remove evidence after
167
+ # Square does not send the bank any evidence that is removed. Also, you
168
+ # cannot remove evidence after
170
169
  # submitting it to the bank using
171
170
  # [SubmitEvidence](https://developer.squareup.com/docs/reference/square/disp
172
171
  # utes-api/submit-evidence).
@@ -210,8 +209,8 @@ module Square
210
209
 
211
210
  # Returns the specific evidence metadata associated with a specific dispute.
212
211
  # You must maintain a copy of the evidence you upload if you want to
213
- # reference it later. You cannot download the evidence
214
- # after you upload it.
212
+ # reference it later. You cannot
213
+ # download the evidence after you upload it.
215
214
  # @param [String] dispute_id Required parameter: The ID of the dispute that
216
215
  # you want to retrieve evidence from.
217
216
  # @param [String] evidence_id Required parameter: The ID of the evidence to
@@ -251,13 +250,13 @@ module Square
251
250
  end
252
251
 
253
252
  # Uploads a file to use as evidence in a dispute challenge. The endpoint
254
- # accepts
255
- # HTTP multipart/form-data file uploads in HEIC, HEIF, JPEG, PDF, PNG,
256
- # and TIFF formats.
257
- # @param [String] dispute_id Required parameter: ID of the dispute you want
258
- # to upload evidence for.
253
+ # accepts HTTP
254
+ # multipart/form-data file uploads in HEIC, HEIF, JPEG, PDF, PNG, and TIFF
255
+ # formats.
256
+ # @param [String] dispute_id Required parameter: The ID of the dispute you
257
+ # want to upload evidence for.
259
258
  # @param [CreateDisputeEvidenceFileRequest] request Optional parameter:
260
- # Defines parameters for a CreateDisputeEvidenceFile request.
259
+ # Defines the parameters for a `CreateDisputeEvidenceFile` request.
261
260
  # @param [File | UploadIO] image_file Optional parameter: Example:
262
261
  # @return [CreateDisputeEvidenceFileResponse Hash] response from the API call
263
262
  def create_dispute_evidence_file(dispute_id:,
@@ -358,16 +357,15 @@ module Square
358
357
 
359
358
  # Submits evidence to the cardholder's bank.
360
359
  # Before submitting evidence, Square compiles all available evidence. This
361
- # includes
362
- # evidence uploaded using the
360
+ # includes evidence uploaded
361
+ # using the
363
362
  # [CreateDisputeEvidenceFile](https://developer.squareup.com/docs/reference/
364
363
  # square/disputes-api/create-dispute-evidence-file) and
365
364
  # [CreateDisputeEvidenceText](https://developer.squareup.com/docs/reference/
366
- # square/disputes-api/create-dispute-evidence-text) endpoints,
367
- # and evidence automatically provided by Square, when
368
- # available.
369
- # @param [String] dispute_id Required parameter: The ID of the dispute you
370
- # want to submit evidence for.
365
+ # square/disputes-api/create-dispute-evidence-text) endpoints and
366
+ # evidence automatically provided by Square, when available.
367
+ # @param [String] dispute_id Required parameter: The ID of the dispute that
368
+ # you want to submit evidence for.
371
369
  # @return [SubmitEvidenceResponse Hash] response from the API call
372
370
  def submit_evidence(dispute_id:)
373
371
  # Prepare query url.
@@ -208,8 +208,8 @@ module Square
208
208
  # @param [String] cursor Optional parameter: A pagination cursor returned by
209
209
  # a previous call to this endpoint. Provide this to retrieve the next set of
210
210
  # results for the original query. See the
211
- # [Pagination](https://developer.squareup.com/docs/docs/working-with-apis/pa
212
- # gination) guide for more information.
211
+ # [Pagination](https://developer.squareup.com/docs/working-with-apis/paginat
212
+ # ion) guide for more information.
213
213
  # @return [RetrieveInventoryCountResponse Hash] response from the API call
214
214
  def retrieve_inventory_count(catalog_object_id:,
215
215
  location_ids: nil,
@@ -13,8 +13,8 @@ module Square
13
13
  # @param [String] cursor Optional parameter: A pagination cursor returned by
14
14
  # a previous call to this endpoint. Provide this cursor to retrieve the
15
15
  # next set of results for your original query. For more information, see
16
- # [Pagination](https://developer.squareup.com/docs/docs/working-with-apis/pa
17
- # gination).
16
+ # [Pagination](https://developer.squareup.com/docs/working-with-apis/paginat
17
+ # ion).
18
18
  # @param [Integer] limit Optional parameter: The maximum number of invoices
19
19
  # to return (200 is the maximum `limit`). If not provided, the server uses
20
20
  # a default limit of 100 invoices.
@@ -134,8 +134,8 @@ module Square
134
134
 
135
135
  # Deletes the specified invoice. When an invoice is deleted, the
136
136
  # associated Order status changes to CANCELED. You can only delete a draft
137
- # invoice (you cannot delete an invoice scheduled for publication, or a
138
- # published invoice).
137
+ # invoice (you cannot delete a published invoice, including one that is
138
+ # scheduled for processing).
139
139
  # @param [String] invoice_id Required parameter: The ID of the invoice to
140
140
  # delete.
141
141
  # @param [Integer] version Optional parameter: The version of the
@@ -214,12 +214,15 @@ module Square
214
214
  )
215
215
  end
216
216
 
217
- # Updates an invoice by modifying field values, clearing field values, or
218
- # both
219
- # as specified in the request.
220
- # There are no restrictions to updating an invoice in a draft state.
221
- # However, there are guidelines for updating a published invoice.
222
- # @param [String] invoice_id Required parameter: The id of the invoice to
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
223
226
  # update.
224
227
  # @param [UpdateInvoiceRequest] body Required parameter: An object
225
228
  # containing the fields to POST for the request. See the corresponding
@@ -261,8 +264,8 @@ module Square
261
264
 
262
265
  # Cancels an invoice. The seller cannot collect payments for
263
266
  # the canceled invoice.
264
- # You cannot cancel an invoice in a terminal state: `PAID`, `REFUNDED`,
265
- # `CANCELED`, or `FAILED`.
267
+ # You cannot cancel an invoice in the `DRAFT` state or in a terminal state:
268
+ # `PAID`, `REFUNDED`, `CANCELED`, or `FAILED`.
266
269
  # @param [String] invoice_id Required parameter: The ID of the
267
270
  # [invoice](#type-invoice) to cancel.
268
271
  # @param [CancelInvoiceRequest] body Required parameter: An object
@@ -123,7 +123,7 @@ module Square
123
123
  # [CalculateLoyaltyPoints](#endpoint-Loyalty-CalculateLoyaltyPoints) to
124
124
  # compute the points. For more information,
125
125
  # see [Loyalty Program
126
- # Overview](https://developer.squareup.com/docs/docs/loyalty/overview).
126
+ # Overview](https://developer.squareup.com/docs/loyalty/overview).
127
127
  # You then provide the points in a request to this endpoint.
128
128
  # @param [String] account_id Required parameter: The [loyalty
129
129
  # account](#type-LoyaltyAccount) ID to which to add the points.
@@ -16,8 +16,8 @@ module Square
16
16
  # ```
17
17
  # Replace `ACCESS_TOKEN` with a
18
18
  # [valid production authorization
19
- # credential](https://developer.squareup.com/docs/docs/build-basics/access-t
20
- # okens).
19
+ # credential](https://developer.squareup.com/docs/build-basics/access-tokens
20
+ # ).
21
21
  # @param [CreateMobileAuthorizationCodeRequest] body Required parameter: An
22
22
  # object containing the fields to POST for the request. See the
23
23
  # corresponding object definition for field details.
@@ -85,7 +85,7 @@ module Square
85
85
  # ```
86
86
  # Replace `APPLICATION_SECRET` with the application secret on the
87
87
  # Credentials
88
- # page in the [application dashboard](https://connect.squareup.com/apps).
88
+ # page in the [Developer Dashboard](https://developer.squareup.com/apps).
89
89
  # @param [RevokeTokenRequest] body Required parameter: An object containing
90
90
  # the fields to POST for the request. See the corresponding object
91
91
  # definition for field details.
@@ -126,9 +126,6 @@ module Square
126
126
  # The endpoint supports distinct methods of obtaining OAuth access tokens.
127
127
  # Applications specify a method by adding the `grant_type` parameter
128
128
  # in the request and also provide relevant information.
129
- # For more information, see [OAuth access token
130
- # management](https://developer.squareup.com/docs/authz/oauth/how-it-works#o
131
- # auth-access-token-management).
132
129
  # __Note:__ Regardless of the method application specified,
133
130
  # the endpoint always returns two items; an OAuth access token and
134
131
  # a refresh token in the response.
@@ -83,16 +83,14 @@ module Square
83
83
  )
84
84
  end
85
85
 
86
- # Charges a payment source (for example, a card
87
- # represented by customer's card on file or a card nonce). In addition
88
- # to the payment source, the request must include the
89
- # amount to accept for the payment.
90
- # There are several optional parameters that you can include in the request
91
- # (for example, tip money, whether to autocomplete the payment, or a
92
- # reference ID
93
- # to correlate this payment with another system).
94
- # The `PAYMENTS_WRITE_ADDITIONAL_RECIPIENTS` OAuth permission is required
95
- # to enable application fees.
86
+ # Creates a payment using the provided source. You can use this endpoint
87
+ # to charge a card (credit/debit card or
88
+ # Square gift card) or record a payment that the seller received outside of
89
+ # Square
90
+ # (cash payment from a buyer or a payment that an external entity
91
+ # procesed on behalf of the seller).
92
+ # The endpoint creates a
93
+ # `Payment` object and returns it in the response.
96
94
  # @param [CreatePaymentRequest] body Required parameter: An object
97
95
  # containing the fields to POST for the request. See the corresponding
98
96
  # object definition for field details.
@@ -209,11 +207,53 @@ module Square
209
207
  )
210
208
  end
211
209
 
212
- # Cancels (voids) a payment. If you set `autocomplete` to `false` when
213
- # creating a payment,
214
- # you can cancel the payment using this endpoint.
215
- # @param [String] payment_id Required parameter: The `payment_id`
216
- # identifying the payment to be canceled.
210
+ # Updates a payment with the APPROVED status.
211
+ # You can update the `amount_money` and `tip_money` using this endpoint.
212
+ # @param [String] payment_id Required parameter: The ID of the payment to
213
+ # update.
214
+ # @param [UpdatePaymentRequest] body Required parameter: An object
215
+ # containing the fields to POST for the request. See the corresponding
216
+ # object definition for field details.
217
+ # @return [UpdatePaymentResponse Hash] response from the API call
218
+ def update_payment(payment_id:,
219
+ body:)
220
+ # Prepare query url.
221
+ _query_builder = config.get_base_uri
222
+ _query_builder << '/v2/payments/{payment_id}'
223
+ _query_builder = APIHelper.append_url_with_template_parameters(
224
+ _query_builder,
225
+ 'payment_id' => { 'value' => payment_id, 'encode' => true }
226
+ )
227
+ _query_url = APIHelper.clean_url _query_builder
228
+
229
+ # Prepare headers.
230
+ _headers = {
231
+ 'accept' => 'application/json',
232
+ 'content-type' => 'application/json; charset=utf-8'
233
+ }
234
+
235
+ # Prepare and execute HttpRequest.
236
+ _request = config.http_client.put(
237
+ _query_url,
238
+ headers: _headers,
239
+ parameters: body.to_json
240
+ )
241
+ OAuth2.apply(config, _request)
242
+ _response = execute_request(_request)
243
+
244
+ # Return appropriate response type.
245
+ decoded = APIHelper.json_deserialize(_response.raw_body)
246
+ _errors = APIHelper.map_response(decoded, ['errors'])
247
+ ApiResponse.new(
248
+ _response, data: decoded, errors: _errors
249
+ )
250
+ end
251
+
252
+ # Cancels (voids) a payment. You can use this endpoint to cancel a payment
253
+ # with
254
+ # the APPROVED `status`.
255
+ # @param [String] payment_id Required parameter: The ID of the payment to
256
+ # cancel.
217
257
  # @return [CancelPaymentResponse Hash] response from the API call
218
258
  def cancel_payment(payment_id:)
219
259
  # Prepare query url.
@@ -249,9 +289,8 @@ module Square
249
289
  # Completes (captures) a payment.
250
290
  # By default, payments are set to complete immediately after they are
251
291
  # created.
252
- # If you set `autocomplete` to `false` when creating a payment, you can
253
- # complete (capture)
254
- # the payment using this endpoint.
292
+ # You can use this endpoint to complete a payment with the APPROVED
293
+ # `status`.
255
294
  # @param [String] payment_id Required parameter: The unique ID identifying
256
295
  # the payment to be completed.
257
296
  # @return [CompletePaymentResponse Hash] response from the API call