square.rb 9.1.1.20210317 → 10.0.0.20210421

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,10 +5,10 @@ module Square
5
5
  super(config, http_call_back: http_call_back)
6
6
  end
7
7
 
8
- # Returns the [InventoryAdjustment](#type-inventoryadjustment) object
8
+ # Returns the [InventoryAdjustment]($m/InventoryAdjustment) object
9
9
  # with the provided `adjustment_id`.
10
10
  # @param [String] adjustment_id Required parameter: ID of the
11
- # [InventoryAdjustment](#type-inventoryadjustment) to retrieve.
11
+ # [InventoryAdjustment]($m/InventoryAdjustment) to retrieve.
12
12
  # @return [RetrieveInventoryAdjustmentResponse Hash] response from the API call
13
13
  def retrieve_inventory_adjustment(adjustment_id:)
14
14
  # Prepare query url.
@@ -118,8 +118,8 @@ module Square
118
118
  end
119
119
 
120
120
  # Returns current counts for the provided
121
- # [CatalogObject](#type-catalogobject)s at the requested
122
- # [Location](#type-location)s.
121
+ # [CatalogObject]($m/CatalogObject)s at the requested
122
+ # [Location]($m/Location)s.
123
123
  # Results are paginated and sorted in descending order according to their
124
124
  # `calculated_at` timestamp (newest first).
125
125
  # When `updated_after` is specified, only counts that have changed since
@@ -160,10 +160,10 @@ module Square
160
160
  )
161
161
  end
162
162
 
163
- # Returns the [InventoryPhysicalCount](#type-inventoryphysicalcount)
163
+ # Returns the [InventoryPhysicalCount]($m/InventoryPhysicalCount)
164
164
  # object with the provided `physical_count_id`.
165
165
  # @param [String] physical_count_id Required parameter: ID of the
166
- # [InventoryPhysicalCount](#type-inventoryphysicalcount) to retrieve.
166
+ # [InventoryPhysicalCount]($m/InventoryPhysicalCount) to retrieve.
167
167
  # @return [RetrieveInventoryPhysicalCountResponse Hash] response from the API call
168
168
  def retrieve_inventory_physical_count(physical_count_id:)
169
169
  # Prepare query url.
@@ -197,14 +197,14 @@ module Square
197
197
  end
198
198
 
199
199
  # Retrieves the current calculated stock count for a given
200
- # [CatalogObject](#type-catalogobject) at a given set of
201
- # [Location](#type-location)s. Responses are paginated and unsorted.
200
+ # [CatalogObject]($m/CatalogObject) at a given set of
201
+ # [Location]($m/Location)s. Responses are paginated and unsorted.
202
202
  # For more sophisticated queries, use a batch endpoint.
203
203
  # @param [String] catalog_object_id Required parameter: ID of the
204
- # [CatalogObject](#type-catalogobject) to retrieve.
204
+ # [CatalogObject]($m/CatalogObject) to retrieve.
205
205
  # @param [String] location_ids Optional parameter: The
206
- # [Location](#type-location) IDs to look up as a comma-separated list. An
207
- # empty list queries all locations.
206
+ # [Location]($m/Location) IDs to look up as a comma-separated list. An empty
207
+ # list queries all locations.
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
@@ -250,8 +250,8 @@ module Square
250
250
  end
251
251
 
252
252
  # Returns a set of physical counts and inventory adjustments for the
253
- # provided [CatalogObject](#type-catalogobject) at the requested
254
- # [Location](#type-location)s.
253
+ # provided [CatalogObject]($m/CatalogObject) at the requested
254
+ # [Location]($m/Location)s.
255
255
  # Results are paginated and sorted in descending order according to their
256
256
  # `occurred_at` timestamp (newest first).
257
257
  # There are no limits on how far back the caller can page. This endpoint can
@@ -259,10 +259,10 @@ module Square
259
259
  # used to display recent changes for a specific item. For more
260
260
  # sophisticated queries, use a batch endpoint.
261
261
  # @param [String] catalog_object_id Required parameter: ID of the
262
- # [CatalogObject](#type-catalogobject) to retrieve.
262
+ # [CatalogObject]($m/CatalogObject) to retrieve.
263
263
  # @param [String] location_ids Optional parameter: The
264
- # [Location](#type-location) IDs to look up as a comma-separated list. An
265
- # empty list queries all locations.
264
+ # [Location]($m/Location) IDs to look up as a comma-separated list. An empty
265
+ # list queries all locations.
266
266
  # @param [String] cursor Optional parameter: A pagination cursor returned by
267
267
  # a previous call to this endpoint. Provide this to retrieve the next set of
268
268
  # results for the original query. See the
@@ -7,7 +7,7 @@ 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 fetch the next set of invoices.
10
+ # use in a subsequent request to retrieve the next set of invoices.
11
11
  # @param [String] location_id Required parameter: The ID of the location for
12
12
  # which to list invoices.
13
13
  # @param [String] cursor Optional parameter: A pagination cursor returned by
@@ -16,7 +16,7 @@ module Square
16
16
  # [Pagination](https://developer.squareup.com/docs/working-with-apis/paginat
17
17
  # ion).
18
18
  # @param [Integer] limit Optional parameter: The maximum number of invoices
19
- # to return (200 is the maximum `limit`). If not provided, the server uses
19
+ # to return (200 is the maximum `limit`). If not provided, the server uses
20
20
  # a default limit of 100 invoices.
21
21
  # @return [ListInvoicesResponse Hash] response from the API call
22
22
  def list_invoices(location_id:,
@@ -54,7 +54,7 @@ module Square
54
54
  )
55
55
  end
56
56
 
57
- # Creates a draft [invoice](#type-invoice)
57
+ # Creates a draft [invoice]($m/Invoice)
58
58
  # for an order created using the Orders API.
59
59
  # A draft invoice remains in your account and no action is taken.
60
60
  # You must publish the invoice before Square can process it (send it to the
@@ -98,7 +98,7 @@ module Square
98
98
  # location and
99
99
  # optionally one customer.
100
100
  # The response is paginated. If truncated, the response includes a `cursor`
101
- # that you use in a subsequent request to fetch the next set of invoices.
101
+ # that you use in a subsequent request to retrieve the next set of invoices.
102
102
  # @param [SearchInvoicesRequest] body Required parameter: An object
103
103
  # containing the fields to POST for the request. See the corresponding
104
104
  # object definition for field details.
@@ -133,15 +133,15 @@ module Square
133
133
  end
134
134
 
135
135
  # Deletes the specified invoice. When an invoice is deleted, the
136
- # associated Order status changes to CANCELED. You can only delete a draft
136
+ # associated order status changes to CANCELED. You can only delete a draft
137
137
  # invoice (you cannot delete a published invoice, including one that is
138
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
142
- # [invoice](#type-invoice) to delete. If you do not know the version, you
143
- # can call [GetInvoice](#endpoint-Invoices-GetInvoice) or
144
- # [ListInvoices](#endpoint-Invoices-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).
145
145
  # @return [DeleteInvoiceResponse Hash] response from the API call
146
146
  def delete_invoice(invoice_id:,
147
147
  version: nil)
@@ -180,7 +180,7 @@ module Square
180
180
  end
181
181
 
182
182
  # Retrieves an invoice by invoice ID.
183
- # @param [String] invoice_id Required parameter: The id of the invoice to
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:)
@@ -216,10 +216,10 @@ module Square
216
216
 
217
217
  # Updates an invoice by modifying fields, clearing fields, or both. For most
218
218
  # updates, you can use a sparse
219
- # `Invoice` object to add fields or change values, and use the
219
+ # `Invoice` object to add fields or change values and use the
220
220
  # `fields_to_clear` field to specify fields to clear.
221
221
  # However, some restrictions apply. For example, you cannot change the
222
- # `order_id` or `location_id` field, and you
222
+ # `order_id` or `location_id` field and you
223
223
  # must provide the complete `custom_fields` list to update a custom field.
224
224
  # Published invoices have additional restrictions.
225
225
  # @param [String] invoice_id Required parameter: The ID of the invoice to
@@ -267,7 +267,7 @@ module Square
267
267
  # You cannot cancel an invoice in the `DRAFT` state or in a terminal state:
268
268
  # `PAID`, `REFUNDED`, `CANCELED`, or `FAILED`.
269
269
  # @param [String] invoice_id Required parameter: The ID of the
270
- # [invoice](#type-invoice) to cancel.
270
+ # [invoice]($m/Invoice) to cancel.
271
271
  # @param [CancelInvoiceRequest] body Required parameter: An object
272
272
  # containing the fields to POST for the request. See the corresponding
273
273
  # object definition for field details.
@@ -318,8 +318,8 @@ module Square
318
318
  # `UNPAID` if
319
319
  # Square emails the invoice or `PARTIALLY_PAID` if Square charge a card on
320
320
  # file for a portion of the
321
- # invoice amount).
322
- # @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
323
323
  # publish.
324
324
  # @param [PublishInvoiceRequest] body Required parameter: An object
325
325
  # containing the fields to POST for the request. See the corresponding
@@ -7,8 +7,7 @@ module Square
7
7
 
8
8
  # Provides information of all locations of a business.
9
9
  # Many Square API endpoints require a `location_id` parameter.
10
- # The `id` field of the [`Location`](#type-location) objects returned by
11
- # this
10
+ # The `id` field of the [`Location`]($m/Location) objects returned by this
12
11
  # endpoint correspond to that `location_id` parameter.
13
12
  # @return [ListLocationsResponse Hash] response from the API call
14
13
  def list_locations
@@ -5,7 +5,9 @@ module Square
5
5
  super(config, http_call_back: http_call_back)
6
6
  end
7
7
 
8
- # Creates a loyalty account.
8
+ # Creates a loyalty account. To create a loyalty account, you must provide
9
+ # the `program_id` and either the `mapping` field (preferred) or the
10
+ # `mappings` field.
9
11
  # @param [CreateLoyaltyAccountRequest] body Required parameter: An object
10
12
  # containing the fields to POST for the request. See the corresponding
11
13
  # object definition for field details.
@@ -79,7 +81,7 @@ module Square
79
81
 
80
82
  # Retrieves a loyalty account.
81
83
  # @param [String] account_id Required parameter: The ID of the [loyalty
82
- # account](#type-LoyaltyAccount) to retrieve.
84
+ # account]($m/LoyaltyAccount) to retrieve.
83
85
  # @return [RetrieveLoyaltyAccountResponse Hash] response from the API call
84
86
  def retrieve_loyalty_account(account_id:)
85
87
  # Prepare query url.
@@ -120,13 +122,13 @@ module Square
120
122
  # - If you are not using the Orders API to manage orders,
121
123
  # you first perform a client-side computation to compute the points.
122
124
  # For spend-based and visit-based programs, you can call
123
- # [CalculateLoyaltyPoints](#endpoint-Loyalty-CalculateLoyaltyPoints) to
124
- # compute the points. For more information,
125
+ # [CalculateLoyaltyPoints]($e/Loyalty/CalculateLoyaltyPoints) to compute the
126
+ # points. For more information,
125
127
  # see [Loyalty Program
126
128
  # Overview](https://developer.squareup.com/docs/loyalty/overview).
127
129
  # You then provide the points in a request to this endpoint.
128
130
  # @param [String] account_id Required parameter: The [loyalty
129
- # account](#type-LoyaltyAccount) ID to which to add the points.
131
+ # account]($m/LoyaltyAccount) ID to which to add the points.
130
132
  # @param [AccumulateLoyaltyPointsRequest] body Required parameter: An object
131
133
  # containing the fields to POST for the request. See the corresponding
132
134
  # object definition for field details.
@@ -168,10 +170,10 @@ module Square
168
170
  # Adds points to or subtracts points from a buyer's account.
169
171
  # Use this endpoint only when you need to manually adjust points. Otherwise,
170
172
  # in your application flow, you call
171
- # [AccumulateLoyaltyPoints](#endpoint-Loyalty-AccumulateLoyaltyPoints)
173
+ # [AccumulateLoyaltyPoints]($e/Loyalty/AccumulateLoyaltyPoints)
172
174
  # to add points when a buyer pays for the purchase.
173
175
  # @param [String] account_id Required parameter: The ID of the [loyalty
174
- # account](#type-LoyaltyAccount) in which to adjust the points.
176
+ # account]($m/LoyaltyAccount) in which to adjust the points.
175
177
  # @param [AdjustLoyaltyPointsRequest] body Required parameter: An object
176
178
  # containing the fields to POST for the request. See the corresponding
177
179
  # object definition for field details.
@@ -217,6 +219,7 @@ module Square
217
219
  # (for example, points earned, points redeemed, and points expired) is
218
220
  # recorded in the ledger. Using this endpoint, you can search the ledger for
219
221
  # events.
222
+ # Search results are sorted by `created_at` in descending order.
220
223
  # @param [SearchLoyaltyEventsRequest] body Required parameter: An object
221
224
  # containing the fields to POST for the request. See the corresponding
222
225
  # object definition for field details.
@@ -280,6 +283,48 @@ module Square
280
283
  )
281
284
  end
282
285
 
286
+ # Retrieves the loyalty program in a seller's account, specified by the
287
+ # program ID or the keyword `main`.
288
+ # Loyalty programs define how buyers can earn points and redeem points for
289
+ # rewards. Square sellers can have only one loyalty program, which is
290
+ # created and managed from the Seller Dashboard. For more information, see
291
+ # [Loyalty Program
292
+ # Overview](https://developer.squareup.com/docs/loyalty/overview).
293
+ # @param [String] program_id Required parameter: The ID of the loyalty
294
+ # program or the keyword `main`. Either value can be used to retrieve the
295
+ # single loyalty program that belongs to the seller.
296
+ # @return [RetrieveLoyaltyProgramResponse Hash] response from the API call
297
+ def retrieve_loyalty_program(program_id:)
298
+ # Prepare query url.
299
+ _query_builder = config.get_base_uri
300
+ _query_builder << '/v2/loyalty/programs/{program_id}'
301
+ _query_builder = APIHelper.append_url_with_template_parameters(
302
+ _query_builder,
303
+ 'program_id' => { 'value' => program_id, 'encode' => true }
304
+ )
305
+ _query_url = APIHelper.clean_url _query_builder
306
+
307
+ # Prepare headers.
308
+ _headers = {
309
+ 'accept' => 'application/json'
310
+ }
311
+
312
+ # Prepare and execute HttpRequest.
313
+ _request = config.http_client.get(
314
+ _query_url,
315
+ headers: _headers
316
+ )
317
+ OAuth2.apply(config, _request)
318
+ _response = execute_request(_request)
319
+
320
+ # Return appropriate response type.
321
+ decoded = APIHelper.json_deserialize(_response.raw_body)
322
+ _errors = APIHelper.map_response(decoded, ['errors'])
323
+ ApiResponse.new(
324
+ _response, data: decoded, errors: _errors
325
+ )
326
+ end
327
+
283
328
  # Calculates the points a purchase earns.
284
329
  # - If you are using the Orders API to manage orders, you provide `order_id`
285
330
  # in the request. The
@@ -291,7 +336,7 @@ module Square
291
336
  # can earn with the
292
337
  # specific purchase.
293
338
  # @param [String] program_id Required parameter: The [loyalty
294
- # program](#type-LoyaltyProgram) ID, which defines the rules for accruing
339
+ # program]($m/LoyaltyProgram) ID, which defines the rules for accruing
295
340
  # points.
296
341
  # @param [CalculateLoyaltyPointsRequest] body Required parameter: An object
297
342
  # containing the fields to POST for the request. See the corresponding
@@ -376,7 +421,8 @@ module Square
376
421
  # In the current implementation, the endpoint supports search by the reward
377
422
  # `status`.
378
423
  # If you know a reward ID, use the
379
- # [RetrieveLoyaltyReward](#endpoint-Loyalty-RetrieveLoyaltyReward) endpoint.
424
+ # [RetrieveLoyaltyReward]($e/Loyalty/RetrieveLoyaltyReward) endpoint.
425
+ # Search results are sorted by `updated_at` in descending order.
380
426
  # @param [SearchLoyaltyRewardsRequest] body Required parameter: An object
381
427
  # containing the fields to POST for the request. See the corresponding
382
428
  # object definition for field details.
@@ -413,12 +459,12 @@ module Square
413
459
  # Deletes a loyalty reward by doing the following:
414
460
  # - Returns the loyalty points back to the loyalty account.
415
461
  # - If an order ID was specified when the reward was created
416
- # (see [CreateLoyaltyReward](#endpoint-Loyalty-CreateLoyaltyReward)),
462
+ # (see [CreateLoyaltyReward]($e/Loyalty/CreateLoyaltyReward)),
417
463
  # it updates the order by removing the reward and related
418
464
  # discounts.
419
465
  # You cannot delete a reward that has reached the terminal state (REDEEMED).
420
466
  # @param [String] reward_id Required parameter: The ID of the [loyalty
421
- # reward](#type-LoyaltyReward) to delete.
467
+ # reward]($m/LoyaltyReward) to delete.
422
468
  # @return [DeleteLoyaltyRewardResponse Hash] response from the API call
423
469
  def delete_loyalty_reward(reward_id:)
424
470
  # Prepare query url.
@@ -453,7 +499,7 @@ module Square
453
499
 
454
500
  # Retrieves a loyalty reward.
455
501
  # @param [String] reward_id Required parameter: The ID of the [loyalty
456
- # reward](#type-LoyaltyReward) to retrieve.
502
+ # reward]($m/LoyaltyReward) to retrieve.
457
503
  # @return [RetrieveLoyaltyRewardResponse Hash] response from the API call
458
504
  def retrieve_loyalty_reward(reward_id:)
459
505
  # Prepare query url.
@@ -495,7 +541,7 @@ module Square
495
541
  # In other words, points used for the reward cannot be returned
496
542
  # to the account.
497
543
  # @param [String] reward_id Required parameter: The ID of the [loyalty
498
- # reward](#type-LoyaltyReward) to redeem.
544
+ # reward]($m/LoyaltyReward) to redeem.
499
545
  # @param [RedeemLoyaltyRewardRequest] body Required parameter: An object
500
546
  # containing the fields to POST for the request. See the corresponding
501
547
  # object definition for field details.
@@ -12,7 +12,7 @@ module Square
12
12
  # information or specify an OAuth token
13
13
  # to get the information for the merchant that granted you access.
14
14
  # If you know the merchant ID, you can also use the
15
- # [RetrieveMerchant](#endpoint-merchants-retrievemerchant)
15
+ # [RetrieveMerchant]($e/Merchants/RetrieveMerchant)
16
16
  # endpoint to get the merchant information.
17
17
  # @param [Integer] cursor Optional parameter: The cursor generated by the
18
18
  # previous response.
@@ -5,14 +5,15 @@ module Square
5
5
  super(config, http_call_back: http_call_back)
6
6
  end
7
7
 
8
- # Creates a new [Order](#type-order) which can include information on
9
- # products for
8
+ # Creates a new [Order]($m/Order) which can include information on products
9
+ # for
10
10
  # purchase and settings to apply to the purchase.
11
- # To pay for a created order, please refer to the [Pay for
11
+ # To pay for a created order, please refer to the
12
+ # [Pay for
12
13
  # Orders](https://developer.squareup.com/docs/orders-api/pay-for-orders)
13
14
  # guide.
14
- # You can modify open orders using the
15
- # [UpdateOrder](#endpoint-orders-updateorder) endpoint.
15
+ # You can modify open orders using the [UpdateOrder]($e/Orders/UpdateOrder)
16
+ # endpoint.
16
17
  # @param [CreateOrderRequest] body Required parameter: An object containing
17
18
  # the fields to POST for the request. See the corresponding object
18
19
  # definition for field details.
@@ -46,7 +47,7 @@ module Square
46
47
  )
47
48
  end
48
49
 
49
- # Retrieves a set of [Order](#type-order)s by their IDs.
50
+ # Retrieves a set of [Order]($m/Order)s by their IDs.
50
51
  # If a given Order ID does not exist, the ID is ignored instead of
51
52
  # generating an error.
52
53
  # @param [BatchRetrieveOrdersRequest] body Required parameter: An object
@@ -82,7 +83,7 @@ module Square
82
83
  )
83
84
  end
84
85
 
85
- # Calculates an [Order](#type-order).
86
+ # Enables applications to preview order pricing without creating an order.
86
87
  # @param [CalculateOrderRequest] body Required parameter: An object
87
88
  # containing the fields to POST for the request. See the corresponding
88
89
  # object definition for field details.
@@ -121,12 +122,12 @@ module Square
121
122
  # Ecosystem (e.g. Point of Sale, Invoices, Connect APIs, etc).
122
123
  # SearchOrders requests need to specify which locations to search and define
123
124
  # a
124
- # [`SearchOrdersQuery`](#type-searchordersquery) object which controls
125
+ # [`SearchOrdersQuery`]($m/SearchOrdersQuery) object which controls
125
126
  # how to sort or filter the results. Your SearchOrdersQuery can:
126
127
  # Set filter criteria.
127
128
  # Set sort order.
128
129
  # Determine whether to return results as complete Order objects, or as
129
- # [OrderEntry](#type-orderentry) objects.
130
+ # [OrderEntry]($m/OrderEntry) objects.
130
131
  # Note that details for orders processed with Square Point of Sale while in
131
132
  # offline mode may not be transmitted to Square for up to 72 hours. Offline
132
133
  # orders have a `created_at` value that reflects the time the order was
@@ -165,7 +166,7 @@ module Square
165
166
  )
166
167
  end
167
168
 
168
- # Retrieves an [Order](#type-order) by ID.
169
+ # Retrieves an [Order]($m/Order) by ID.
169
170
  # @param [String] order_id Required parameter: The ID of the order to
170
171
  # retrieve.
171
172
  # @return [RetrieveOrderResponse Hash] response from the API call
@@ -200,7 +201,7 @@ module Square
200
201
  )
201
202
  end
202
203
 
203
- # Updates an open [Order](#type-order) by adding, replacing, or deleting
204
+ # Updates an open [Order]($m/Order) by adding, replacing, or deleting
204
205
  # fields. Orders with a `COMPLETED` or `CANCELED` state cannot be updated.
205
206
  # An UpdateOrder request requires the following:
206
207
  # - The `order_id` in the endpoint path, identifying the order to update.
@@ -214,7 +215,8 @@ module Square
214
215
  # paths](https://developer.squareup.com/docs/orders-api/manage-orders#on-dot
215
216
  # -notation)
216
217
  # identifying fields to clear.
217
- # To pay for an order, please refer to the [Pay for
218
+ # To pay for an order, please refer to the
219
+ # [Pay for
218
220
  # Orders](https://developer.squareup.com/docs/orders-api/pay-for-orders)
219
221
  # guide.
220
222
  # @param [String] order_id Required parameter: The ID of the order to
@@ -257,8 +259,8 @@ module Square
257
259
  )
258
260
  end
259
261
 
260
- # Pay for an [order](#type-order) using one or more approved
261
- # [payments](#type-payment),
262
+ # Pay for an [order]($m/Order) using one or more approved
263
+ # [payments]($m/Payment),
262
264
  # or settle an order with a total of `0`.
263
265
  # The total of the `payment_ids` listed in the request must be equal to the
264
266
  # order
@@ -267,7 +269,7 @@ module Square
267
269
  # array of `payment_ids` in the request.
268
270
  # To be used with PayOrder, a payment must:
269
271
  # - Reference the order by specifying the `order_id` when [creating the
270
- # payment](#endpoint-payments-createpayment).
272
+ # payment]($e/Payments/CreatePayment).
271
273
  # Any approved payments that reference the same `order_id` not specified in
272
274
  # the
273
275
  # `payment_ids` will be canceled.