square.rb 5.3.0.20200528 → 6.4.0.20200923

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.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +317 -285
  3. data/lib/square.rb +4 -2
  4. data/lib/square/api/base_api.rb +2 -2
  5. data/lib/square/api/catalog_api.rb +76 -57
  6. data/lib/square/api/disputes_api.rb +3 -26
  7. data/lib/square/api/employees_api.rb +3 -2
  8. data/lib/square/api/inventory_api.rb +5 -4
  9. data/lib/square/api/invoices_api.rb +343 -0
  10. data/lib/square/api/labor_api.rb +77 -0
  11. data/lib/square/api/locations_api.rb +7 -2
  12. data/lib/square/api/merchants_api.rb +2 -1
  13. data/lib/square/api/orders_api.rb +59 -85
  14. data/lib/square/api/payments_api.rb +15 -24
  15. data/lib/square/api/refunds_api.rb +12 -7
  16. data/lib/square/api/subscriptions_api.rb +251 -0
  17. data/lib/square/api/team_api.rb +326 -0
  18. data/lib/square/api/transactions_api.rb +0 -71
  19. data/lib/square/api/v1_employees_api.rb +3 -76
  20. data/lib/square/api/v1_items_api.rb +0 -360
  21. data/lib/square/api/v1_locations_api.rb +0 -18
  22. data/lib/square/api/v1_transactions_api.rb +1 -19
  23. data/lib/square/client.rb +29 -16
  24. data/lib/square/configuration.rb +12 -4
  25. data/test/api/api_test_base.rb +1 -6
  26. data/test/api/test_catalog_api.rb +1 -4
  27. data/test/api/test_customers_api.rb +1 -4
  28. data/test/api/test_employees_api.rb +1 -4
  29. data/test/api/test_labor_api.rb +2 -6
  30. data/test/api/test_locations_api.rb +21 -32
  31. data/test/api/test_merchants_api.rb +1 -4
  32. data/test/api/test_payments_api.rb +3 -6
  33. data/test/api/test_refunds_api.rb +3 -6
  34. data/test/http_response_catcher.rb +0 -5
  35. data/test/test_helper.rb +0 -5
  36. metadata +33 -13
  37. data/lib/square/api/reporting_api.rb +0 -138
@@ -209,6 +209,7 @@ module Square
209
209
  def list_employee_wages(employee_id: nil,
210
210
  limit: nil,
211
211
  cursor: nil)
212
+ warn 'Endpoint list_employee_wages in LaborApi is deprecated'
212
213
  # Prepare query url.
213
214
  _query_builder = config.get_base_uri
214
215
  _query_builder << '/v2/labor/employee-wages'
@@ -244,6 +245,7 @@ module Square
244
245
  # retrieved.
245
246
  # @return [GetEmployeeWageResponse Hash] response from the API call
246
247
  def get_employee_wage(id:)
248
+ warn 'Endpoint get_employee_wage in LaborApi is deprecated'
247
249
  # Prepare query url.
248
250
  _query_builder = config.get_base_uri
249
251
  _query_builder << '/v2/labor/employee-wages/{id}'
@@ -474,6 +476,81 @@ module Square
474
476
  ApiResponse.new(_response, data: decoded, errors: _errors)
475
477
  end
476
478
 
479
+ # Returns a paginated list of `TeamMemberWage` instances for a business.
480
+ # @param [String] team_member_id Optional parameter: Filter wages returned
481
+ # to only those that are associated with the specified team member.
482
+ # @param [Integer] limit Optional parameter: Maximum number of Team Member
483
+ # Wages to return per page. Can range between 1 and 200. The default is the
484
+ # maximum at 200.
485
+ # @param [String] cursor Optional parameter: Pointer to the next page of
486
+ # Employee Wage results to fetch.
487
+ # @return [ListTeamMemberWagesResponse Hash] response from the API call
488
+ def list_team_member_wages(team_member_id: nil,
489
+ limit: nil,
490
+ cursor: nil)
491
+ # Prepare query url.
492
+ _query_builder = config.get_base_uri
493
+ _query_builder << '/v2/labor/team-member-wages'
494
+ _query_builder = APIHelper.append_url_with_query_parameters(
495
+ _query_builder,
496
+ 'team_member_id' => team_member_id,
497
+ 'limit' => limit,
498
+ 'cursor' => cursor
499
+ )
500
+ _query_url = APIHelper.clean_url _query_builder
501
+
502
+ # Prepare headers.
503
+ _headers = {
504
+ 'accept' => 'application/json'
505
+ }
506
+
507
+ # Prepare and execute HttpRequest.
508
+ _request = config.http_client.get(
509
+ _query_url,
510
+ headers: _headers
511
+ )
512
+ OAuth2.apply(config, _request)
513
+ _response = execute_request(_request)
514
+
515
+ # Return appropriate response type.
516
+ decoded = APIHelper.json_deserialize(_response.raw_body)
517
+ _errors = APIHelper.map_response(decoded, ['errors'])
518
+ ApiResponse.new(_response, data: decoded, errors: _errors)
519
+ end
520
+
521
+ # Returns a single `TeamMemberWage` specified by id.
522
+ # @param [String] id Required parameter: UUID for the `TeamMemberWage` being
523
+ # retrieved.
524
+ # @return [GetTeamMemberWageResponse Hash] response from the API call
525
+ def get_team_member_wage(id:)
526
+ # Prepare query url.
527
+ _query_builder = config.get_base_uri
528
+ _query_builder << '/v2/labor/team-member-wages/{id}'
529
+ _query_builder = APIHelper.append_url_with_template_parameters(
530
+ _query_builder,
531
+ 'id' => id
532
+ )
533
+ _query_url = APIHelper.clean_url _query_builder
534
+
535
+ # Prepare headers.
536
+ _headers = {
537
+ 'accept' => 'application/json'
538
+ }
539
+
540
+ # Prepare and execute HttpRequest.
541
+ _request = config.http_client.get(
542
+ _query_url,
543
+ headers: _headers
544
+ )
545
+ OAuth2.apply(config, _request)
546
+ _response = execute_request(_request)
547
+
548
+ # Return appropriate response type.
549
+ decoded = APIHelper.json_deserialize(_response.raw_body)
550
+ _errors = APIHelper.map_response(decoded, ['errors'])
551
+ ApiResponse.new(_response, data: decoded, errors: _errors)
552
+ end
553
+
477
554
  # Returns a list of `WorkweekConfig` instances for a business.
478
555
  # @param [Integer] limit Optional parameter: Maximum number of Workweek
479
556
  # Configs to return per page.
@@ -71,9 +71,14 @@ module Square
71
71
  ApiResponse.new(_response, data: decoded, errors: _errors)
72
72
  end
73
73
 
74
- # Retrieves details of a location.
74
+ # Retrieves details of a location. You can specify "main"
75
+ # as the location ID to retrieve details of the
76
+ # main location. For more information,
77
+ # see [Locations API
78
+ # Overview](https://developer.squareup.com/docs/docs/locations-api).
75
79
  # @param [String] location_id Required parameter: The ID of the location to
76
- # retrieve.
80
+ # retrieve. If you specify the string "main", then the endpoint returns the
81
+ # main location.
77
82
  # @return [RetrieveLocationResponse Hash] response from the API call
78
83
  def retrieve_location(location_id:)
79
84
  # Prepare query url.
@@ -48,7 +48,8 @@ module Square
48
48
 
49
49
  # Retrieve a `Merchant` object for the given `merchant_id`.
50
50
  # @param [String] merchant_id Required parameter: The ID of the merchant to
51
- # retrieve.
51
+ # retrieve. If the string "me" is supplied as the ID, then retrieve the
52
+ # merchant that is currently accessible to this call.
52
53
  # @return [RetrieveMerchantResponse Hash] response from the API call
53
54
  def retrieve_merchant(merchant_id:)
54
55
  # Prepare query url.
@@ -13,24 +13,14 @@ module Square
13
13
  # guide.
14
14
  # You can modify open orders using the
15
15
  # [UpdateOrder](#endpoint-orders-updateorder) endpoint.
16
- # To learn more about the Orders API, see the
17
- # [Orders API
18
- # Overview](https://developer.squareup.com/docs/orders-api/what-it-does).
19
- # @param [String] location_id Required parameter: The ID of the business
20
- # location to associate the order with.
21
16
  # @param [CreateOrderRequest] body Required parameter: An object containing
22
17
  # the fields to POST for the request. See the corresponding object
23
18
  # definition for field details.
24
19
  # @return [CreateOrderResponse Hash] response from the API call
25
- def create_order(location_id:,
26
- body:)
20
+ def create_order(body:)
27
21
  # Prepare query url.
28
22
  _query_builder = config.get_base_uri
29
- _query_builder << '/v2/locations/{location_id}/orders'
30
- _query_builder = APIHelper.append_url_with_template_parameters(
31
- _query_builder,
32
- 'location_id' => location_id
33
- )
23
+ _query_builder << '/v2/orders'
34
24
  _query_url = APIHelper.clean_url _query_builder
35
25
 
36
26
  # Prepare headers.
@@ -57,21 +47,14 @@ module Square
57
47
  # Retrieves a set of [Order](#type-order)s by their IDs.
58
48
  # If a given Order ID does not exist, the ID is ignored instead of
59
49
  # generating an error.
60
- # @param [String] location_id Required parameter: The ID of the orders'
61
- # associated location.
62
50
  # @param [BatchRetrieveOrdersRequest] body Required parameter: An object
63
51
  # containing the fields to POST for the request. See the corresponding
64
52
  # object definition for field details.
65
53
  # @return [BatchRetrieveOrdersResponse Hash] response from the API call
66
- def batch_retrieve_orders(location_id:,
67
- body:)
54
+ def batch_retrieve_orders(body:)
68
55
  # Prepare query url.
69
56
  _query_builder = config.get_base_uri
70
- _query_builder << '/v2/locations/{location_id}/orders/batch-retrieve'
71
- _query_builder = APIHelper.append_url_with_template_parameters(
72
- _query_builder,
73
- 'location_id' => location_id
74
- )
57
+ _query_builder << '/v2/orders/batch-retrieve'
75
58
  _query_url = APIHelper.clean_url _query_builder
76
59
 
77
60
  # Prepare headers.
@@ -95,68 +78,6 @@ module Square
95
78
  ApiResponse.new(_response, data: decoded, errors: _errors)
96
79
  end
97
80
 
98
- # Updates an open [Order](#type-order) by adding, replacing, or deleting
99
- # fields. Orders with a `COMPLETED` or `CANCELED` state cannot be updated.
100
- # An UpdateOrder request requires the following:
101
- # - The `order_id` in the endpoint path, identifying the order to update.
102
- # - The latest `version` of the order to update.
103
- # - The [sparse
104
- # order](https://developer.squareup.com/docs/orders-api/manage-orders#sparse
105
- # -order-objects)
106
- # containing only the fields to update and the version the update is
107
- # being applied to.
108
- # - If deleting fields, the [dot notation
109
- # paths](https://developer.squareup.com/docs/orders-api/manage-orders#on-dot
110
- # -notation)
111
- # identifying fields to clear.
112
- # To pay for an order, please refer to the [Pay for
113
- # Orders](https://developer.squareup.com/docs/orders-api/pay-for-orders)
114
- # guide.
115
- # To learn more about the Orders API, see the
116
- # [Orders API
117
- # Overview](https://developer.squareup.com/docs/orders-api/what-it-does).
118
- # @param [String] location_id Required parameter: The ID of the order's
119
- # associated location.
120
- # @param [String] order_id Required parameter: The ID of the order to
121
- # update.
122
- # @param [UpdateOrderRequest] body Required parameter: An object containing
123
- # the fields to POST for the request. See the corresponding object
124
- # definition for field details.
125
- # @return [UpdateOrderResponse Hash] response from the API call
126
- def update_order(location_id:,
127
- order_id:,
128
- body:)
129
- # Prepare query url.
130
- _query_builder = config.get_base_uri
131
- _query_builder << '/v2/locations/{location_id}/orders/{order_id}'
132
- _query_builder = APIHelper.append_url_with_template_parameters(
133
- _query_builder,
134
- 'location_id' => location_id,
135
- 'order_id' => order_id
136
- )
137
- _query_url = APIHelper.clean_url _query_builder
138
-
139
- # Prepare headers.
140
- _headers = {
141
- 'accept' => 'application/json',
142
- 'content-type' => 'application/json; charset=utf-8'
143
- }
144
-
145
- # Prepare and execute HttpRequest.
146
- _request = config.http_client.put(
147
- _query_url,
148
- headers: _headers,
149
- parameters: body.to_json
150
- )
151
- OAuth2.apply(config, _request)
152
- _response = execute_request(_request)
153
-
154
- # Return appropriate response type.
155
- decoded = APIHelper.json_deserialize(_response.raw_body)
156
- _errors = APIHelper.map_response(decoded, ['errors'])
157
- ApiResponse.new(_response, data: decoded, errors: _errors)
158
- end
159
-
160
81
  # Calculates an [Order](#type-order).
161
82
  # @param [CalculateOrderRequest] body Required parameter: An object
162
83
  # containing the fields to POST for the request. See the corresponding
@@ -236,6 +157,61 @@ module Square
236
157
  ApiResponse.new(_response, data: decoded, errors: _errors)
237
158
  end
238
159
 
160
+ # Updates an open [Order](#type-order) by adding, replacing, or deleting
161
+ # fields. Orders with a `COMPLETED` or `CANCELED` state cannot be updated.
162
+ # An UpdateOrder request requires the following:
163
+ # - The `order_id` in the endpoint path, identifying the order to update.
164
+ # - The latest `version` of the order to update.
165
+ # - The [sparse
166
+ # order](https://developer.squareup.com/docs/orders-api/manage-orders#sparse
167
+ # -order-objects)
168
+ # containing only the fields to update and the version the update is
169
+ # being applied to.
170
+ # - If deleting fields, the [dot notation
171
+ # paths](https://developer.squareup.com/docs/orders-api/manage-orders#on-dot
172
+ # -notation)
173
+ # identifying fields to clear.
174
+ # To pay for an order, please refer to the [Pay for
175
+ # Orders](https://developer.squareup.com/docs/orders-api/pay-for-orders)
176
+ # guide.
177
+ # @param [String] order_id Required parameter: The ID of the order to
178
+ # update.
179
+ # @param [UpdateOrderRequest] body Required parameter: An object containing
180
+ # the fields to POST for the request. See the corresponding object
181
+ # definition for field details.
182
+ # @return [UpdateOrderResponse Hash] response from the API call
183
+ def update_order(order_id:,
184
+ body:)
185
+ # Prepare query url.
186
+ _query_builder = config.get_base_uri
187
+ _query_builder << '/v2/orders/{order_id}'
188
+ _query_builder = APIHelper.append_url_with_template_parameters(
189
+ _query_builder,
190
+ 'order_id' => order_id
191
+ )
192
+ _query_url = APIHelper.clean_url _query_builder
193
+
194
+ # Prepare headers.
195
+ _headers = {
196
+ 'accept' => 'application/json',
197
+ 'content-type' => 'application/json; charset=utf-8'
198
+ }
199
+
200
+ # Prepare and execute HttpRequest.
201
+ _request = config.http_client.put(
202
+ _query_url,
203
+ headers: _headers,
204
+ parameters: body.to_json
205
+ )
206
+ OAuth2.apply(config, _request)
207
+ _response = execute_request(_request)
208
+
209
+ # Return appropriate response type.
210
+ decoded = APIHelper.json_deserialize(_response.raw_body)
211
+ _errors = APIHelper.map_response(decoded, ['errors'])
212
+ ApiResponse.new(_response, data: decoded, errors: _errors)
213
+ end
214
+
239
215
  # Pay for an [order](#type-order) using one or more approved
240
216
  # [payments](#type-payment),
241
217
  # or settle an order with a total of `0`.
@@ -255,8 +231,6 @@ module Square
255
231
  # layed-capture).
256
232
  # Using a delayed capture payment with PayOrder will complete the approved
257
233
  # payment.
258
- # Learn how to [pay for orders with a single payment using the Payments
259
- # API](https://developer.squareup.com/docs/orders-api/pay-for-orders).
260
234
  # @param [String] order_id Required parameter: The ID of the order being
261
235
  # paid.
262
236
  # @param [PayOrderRequest] body Required parameter: An object containing the
@@ -22,14 +22,18 @@ module Square
22
22
  # [Pagination](https://developer.squareup.com/docs/basics/api101/pagination)
23
23
  # for more information.
24
24
  # @param [String] location_id Optional parameter: Limit results to the
25
- # location supplied. By default, results are returned for all locations
26
- # associated with the merchant.
25
+ # location supplied. By default, results are returned for the default (main)
26
+ # location associated with the merchant.
27
27
  # @param [Long] total Optional parameter: The exact amount in the
28
28
  # total_money for a `Payment`.
29
29
  # @param [String] last_4 Optional parameter: The last 4 digits of `Payment`
30
30
  # card.
31
31
  # @param [String] card_brand Optional parameter: The brand of `Payment`
32
32
  # card. For example, `VISA`
33
+ # @param [Integer] limit Optional parameter: Maximum number of results to be
34
+ # returned in a single page. It is possible to receive fewer results than
35
+ # the specified limit on a given page. If the supplied value is greater
36
+ # than 100, at most 100 results will be returned. Default: `100`
33
37
  # @return [ListPaymentsResponse Hash] response from the API call
34
38
  def list_payments(begin_time: nil,
35
39
  end_time: nil,
@@ -38,7 +42,8 @@ module Square
38
42
  location_id: nil,
39
43
  total: nil,
40
44
  last_4: nil,
41
- card_brand: nil)
45
+ card_brand: nil,
46
+ limit: nil)
42
47
  # Prepare query url.
43
48
  _query_builder = config.get_base_uri
44
49
  _query_builder << '/v2/payments'
@@ -51,7 +56,8 @@ module Square
51
56
  'location_id' => location_id,
52
57
  'total' => total,
53
58
  'last_4' => last_4,
54
- 'card_brand' => card_brand
59
+ 'card_brand' => card_brand,
60
+ 'limit' => limit
55
61
  )
56
62
  _query_url = APIHelper.clean_url _query_builder
57
63
 
@@ -82,9 +88,6 @@ module Square
82
88
  # For example, tip money, whether to autocomplete the payment, or a
83
89
  # reference ID
84
90
  # to correlate this payment with another system.
85
- # For more information about these
86
- # payment options, see [Take
87
- # Payments](https://developer.squareup.com/docs/payments-api/take-payments).
88
91
  # The `PAYMENTS_WRITE_ADDITIONAL_RECIPIENTS` OAuth permission is required
89
92
  # to enable application fees.
90
93
  # @param [CreatePaymentRequest] body Required parameter: An object
@@ -199,10 +202,7 @@ module Square
199
202
 
200
203
  # Cancels (voids) a payment. If you set `autocomplete` to false when
201
204
  # creating a payment,
202
- # you can cancel the payment using this endpoint. For more information, see
203
- # [Delayed
204
- # Payments](https://developer.squareup.com/docs/payments-api/take-payments#d
205
- # elayed-payments).
205
+ # you can cancel the payment using this endpoint.
206
206
  # @param [String] payment_id Required parameter: `payment_id` identifying
207
207
  # the payment to be canceled.
208
208
  # @return [CancelPaymentResponse Hash] response from the API call
@@ -240,18 +240,11 @@ module Square
240
240
  # created.
241
241
  # If you set autocomplete to false when creating a payment, you can complete
242
242
  # (capture)
243
- # the payment using this endpoint. For more information, see
244
- # [Delayed
245
- # Payments](https://developer.squareup.com/docs/payments-api/take-payments#d
246
- # elayed-payments).
243
+ # the payment using this endpoint.
247
244
  # @param [String] payment_id Required parameter: Unique ID identifying the
248
245
  # payment to be completed.
249
- # @param [Object] body Required parameter: An object containing the fields
250
- # to POST for the request. See the corresponding object definition for
251
- # field details.
252
246
  # @return [CompletePaymentResponse Hash] response from the API call
253
- def complete_payment(payment_id:,
254
- body:)
247
+ def complete_payment(payment_id:)
255
248
  # Prepare query url.
256
249
  _query_builder = config.get_base_uri
257
250
  _query_builder << '/v2/payments/{payment_id}/complete'
@@ -263,15 +256,13 @@ module Square
263
256
 
264
257
  # Prepare headers.
265
258
  _headers = {
266
- 'accept' => 'application/json',
267
- 'content-type' => 'application/json; charset=utf-8'
259
+ 'accept' => 'application/json'
268
260
  }
269
261
 
270
262
  # Prepare and execute HttpRequest.
271
263
  _request = config.http_client.post(
272
264
  _query_url,
273
- headers: _headers,
274
- parameters: body.to_json
265
+ headers: _headers
275
266
  )
276
267
  OAuth2.apply(config, _request)
277
268
  _response = execute_request(_request)
@@ -21,8 +21,9 @@ module Square
21
21
  # results for the original query. See
22
22
  # [Pagination](https://developer.squareup.com/docs/basics/api101/pagination)
23
23
  # for more information.
24
- # @param [String] location_id Optional parameter: ID of location associated
25
- # with payment.
24
+ # @param [String] location_id Optional parameter: Limit results to the
25
+ # location supplied. By default, results are returned for all locations
26
+ # associated with the merchant.
26
27
  # @param [String] status Optional parameter: If provided, only refunds with
27
28
  # the given status are returned. For a list of refund status values, see
28
29
  # [PaymentRefund](#type-paymentrefund). Default: If omitted refunds are
@@ -31,6 +32,10 @@ module Square
31
32
  # with the given source type are returned. - `CARD` - List refunds only for
32
33
  # payments where card was specified as payment source. Default: If omitted
33
34
  # refunds are returned regardless of source type.
35
+ # @param [Integer] limit Optional parameter: Maximum number of results to be
36
+ # returned in a single page. It is possible to receive fewer results than
37
+ # the specified limit on a given page. If the supplied value is greater
38
+ # than 100, at most 100 results will be returned. Default: `100`
34
39
  # @return [ListPaymentRefundsResponse Hash] response from the API call
35
40
  def list_payment_refunds(begin_time: nil,
36
41
  end_time: nil,
@@ -38,7 +43,8 @@ module Square
38
43
  cursor: nil,
39
44
  location_id: nil,
40
45
  status: nil,
41
- source_type: nil)
46
+ source_type: nil,
47
+ limit: nil)
42
48
  # Prepare query url.
43
49
  _query_builder = config.get_base_uri
44
50
  _query_builder << '/v2/refunds'
@@ -50,7 +56,8 @@ module Square
50
56
  'cursor' => cursor,
51
57
  'location_id' => location_id,
52
58
  'status' => status,
53
- 'source_type' => source_type
59
+ 'source_type' => source_type,
60
+ 'limit' => limit
54
61
  )
55
62
  _query_url = APIHelper.clean_url _query_builder
56
63
 
@@ -74,9 +81,7 @@ module Square
74
81
  end
75
82
 
76
83
  # Refunds a payment. You can refund the entire payment amount or a
77
- # portion of it. For more information, see
78
- # [Payments and Refunds
79
- # Overview](https://developer.squareup.com/docs/payments-api/overview).
84
+ # portion of it.
80
85
  # @param [RefundPaymentRequest] body Required parameter: An object
81
86
  # containing the fields to POST for the request. See the corresponding
82
87
  # object definition for field details.