square.rb 6.0.0.20200625 → 6.1.0.20200722

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f9b142bc997b6065afc532abf126925305076501dd2f92e27fa12a1e09b1dbcd
4
- data.tar.gz: 426acce9ecbcf54368c66d511b3a6b9eb0995ea0a2505fa811bcbcf2cf32683a
3
+ metadata.gz: 274c6809492acf86fd49adee12a1ccc2045d394dfff9612914de1bc010eeb1cb
4
+ data.tar.gz: 99e6be9ca77af585b64213a3e607ac36f935182bbf9dc8529546548f37d2023c
5
5
  SHA512:
6
- metadata.gz: bd46549961c8a0c9d469854e05cf5dbda210cb65c0d64d1997f3e894f10d043092dce537dc1cbd3610a43ff4249b10218ee06c85e4e9cf183452f990f67c9522
7
- data.tar.gz: 3f1df3f844188ea7dc76279dc20435729b6a05e676f71fe2ecfd59cc63e31c71e0ac0812cf63107d4d2bf54f2b7b1113d50998705a716decef46e5d0fdcc6b7a
6
+ metadata.gz: c13b32a0109ebd31d40394547775814ddb2aed9f50141b1cd36e3339d2c5e9b43d6f9cce2e0c3cc7775ad69034d3f0908c78c873d930f7d6cd7bfe4a20888e6c
7
+ data.tar.gz: eb897df878e5f4d861405c2580fb581ad28ce11e3d6ae467b193bc68822d88161238a111022c94d93d67c052c9321e90874550838723840de664313f02121003
data/README.md CHANGED
@@ -38,6 +38,9 @@ gem 'square.rb'
38
38
  ### Orders
39
39
  * [Orders]
40
40
 
41
+ ### Invoices
42
+ * [Invoices]
43
+
41
44
  ### Items
42
45
  * [Catalog]
43
46
  * [Inventory]
@@ -299,6 +302,7 @@ You can also use the Square API to create applications or services that work wit
299
302
  [Locations]: doc/locations.md
300
303
  [Merchants]: doc/merchants.md
301
304
  [Orders]: doc/orders.md
305
+ [Invoices]: doc/invoices.md
302
306
  [Apple Pay]: doc/apple-pay.md
303
307
  [Refunds]: doc/refunds.md
304
308
  [Reporting]: doc/reporting.md
@@ -46,6 +46,7 @@ require_relative 'square/api/devices_api.rb'
46
46
  require_relative 'square/api/disputes_api.rb'
47
47
  require_relative 'square/api/employees_api.rb'
48
48
  require_relative 'square/api/inventory_api.rb'
49
+ require_relative 'square/api/invoices_api.rb'
49
50
  require_relative 'square/api/labor_api.rb'
50
51
  require_relative 'square/api/locations_api.rb'
51
52
  require_relative 'square/api/reporting_api.rb'
@@ -8,8 +8,8 @@ module Square
8
8
  @http_call_back = http_call_back
9
9
 
10
10
  @global_headers = {
11
- 'user-agent' => 'Square-Ruby-SDK/6.0.0.20200625',
12
- 'Square-Version' => '2020-06-25'
11
+ 'user-agent' => 'Square-Ruby-SDK/6.1.0.20200722',
12
+ 'Square-Version' => config.square_version
13
13
  }
14
14
  end
15
15
 
@@ -131,14 +131,13 @@ module Square
131
131
  ApiResponse.new(_response, data: decoded, errors: _errors)
132
132
  end
133
133
 
134
- # Upload an image file to create a new [CatalogImage](#type-catalogimage)
135
- # for an existing
136
- # [CatalogObject](#type-catalogobject). Images can be uploaded and linked in
137
- # this request or created independently
138
- # (without an object assignment) and linked to a
139
- # [CatalogObject](#type-catalogobject) at a later time.
140
- # CreateCatalogImage accepts HTTP multipart/form-data requests with a JSON
141
- # part and an image file part in
134
+ # Uploads an image file to be represented by an
135
+ # [CatalogImage](#type-catalogimage) object linked to an existing
136
+ # [CatalogObject](#type-catalogobject) instance. A call to this endpoint can
137
+ # upload an image, link an image to
138
+ # a catalog object, or do both.
139
+ # This `CreateCatalogImage` endpoint accepts HTTP multipart/form-data
140
+ # requests with a JSON part and an image file part in
142
141
  # JPEG, PJPEG, PNG, or GIF format. The maximum file size is 15MB.
143
142
  # Additional information and an example cURL request can be found in the
144
143
  # [Create a Catalog Image
@@ -195,8 +194,8 @@ module Square
195
194
  ApiResponse.new(_response, data: decoded, errors: _errors)
196
195
  end
197
196
 
198
- # Returns information about the Square Catalog API, such as batch size
199
- # limits for `BatchUpsertCatalogObjects`.
197
+ # Retrieves information about the Square Catalog API, such as batch size
198
+ # limits that can be used by the `BatchUpsertCatalogObjects` endpoint.
200
199
  # @return [CatalogInfoResponse Hash] response from the API call
201
200
  def catalog_info
202
201
  # Prepare query url.
@@ -406,22 +405,23 @@ module Square
406
405
  ApiResponse.new(_response, data: decoded, errors: _errors)
407
406
  end
408
407
 
409
- # Queries the targeted catalog using a variety of query expressions.
410
- # Supported query expressions are of the following types:
411
- # - [CatalogQuerySortedAttribute](#type-catalogquerysortedattribute),
412
- # - [CatalogQueryExact](#type-catalogqueryexact),
413
- # - [CatalogQueryRange](#type-catalogqueryrange),
414
- # - [CatalogQueryText](#type-catalogquerytext),
415
- # - [CatalogQueryItemsForTax](#type-catalogqueryitemsfortax),
416
- # -
417
- # [CatalogQueryItemsForModifierList](#type-catalogqueryitemsformodifierlist)
418
- # ,
419
- # -
420
- # [CatalogQueryItemsForItemOptions](#type-catalogqueryitemsforitemoptions),
421
- # and
422
- # -
423
- # [CatalogQueryItemVariationsForItemOptionValues](#type-catalogqueryitemvari
424
- # ationsforitemoptionvalues).
408
+ # Searches for [CatalogObject](#type-CatalogObject) of any types against
409
+ # supported search attribute values,
410
+ # excluding custom attribute values on items or item variations, against one
411
+ # or more of the specified query expressions,
412
+ # This (`SearchCatalogObjects`) endpoint differs from the
413
+ # [SearchCatalogItems](#endpoint-Catalog-SearchCatalogItems)
414
+ # endpoint in the following aspects:
415
+ # - `SearchCatalogItems` can only search for items or item variations,
416
+ # whereas `SearchCatalogObjects` can search for any type of catalog objects.
417
+ # - `SearchCatalogItems` supports the custom attribute query filters to
418
+ # return items or item variations that contain custom attribute values,
419
+ # where `SearchCatalogObjects` does not.
420
+ # - `SearchCatalogItems` does not support the `include_deleted_objects`
421
+ # filter to search for deleted items or item variations, whereas
422
+ # `SearchCatalogObjects` does.
423
+ # - The both endpoints have different call conventions, including the query
424
+ # filter formats.
425
425
  # @param [SearchCatalogObjectsRequest] body Required parameter: An object
426
426
  # containing the fields to POST for the request. See the corresponding
427
427
  # object definition for field details.
@@ -453,6 +453,54 @@ module Square
453
453
  ApiResponse.new(_response, data: decoded, errors: _errors)
454
454
  end
455
455
 
456
+ # Searches for catalog items or item variations by matching supported search
457
+ # attribute values, including
458
+ # custom attribute values, against one or more of the specified query
459
+ # expressions,
460
+ # This (`SearchCatalogItems`) endpoint differs from the
461
+ # [SearchCatalogObjects](#endpoint-Catalog-SearchCatalogObjects)
462
+ # endpoint in the following aspects:
463
+ # - `SearchCatalogItems` can only search for items or item variations,
464
+ # whereas `SearchCatalogObjects` can search for any type of catalog objects.
465
+ # - `SearchCatalogItems` supports the custom attribute query filters to
466
+ # return items or item variations that contain custom attribute values,
467
+ # where `SearchCatalogObjects` does not.
468
+ # - `SearchCatalogItems` does not support the `include_deleted_objects`
469
+ # filter to search for deleted items or item variations, whereas
470
+ # `SearchCatalogObjects` does.
471
+ # - The both endpoints use different call conventions, including the query
472
+ # filter formats.
473
+ # @param [SearchCatalogItemsRequest] body Required parameter: An object
474
+ # containing the fields to POST for the request. See the corresponding
475
+ # object definition for field details.
476
+ # @return [SearchCatalogItemsResponse Hash] response from the API call
477
+ def search_catalog_items(body:)
478
+ # Prepare query url.
479
+ _query_builder = config.get_base_uri
480
+ _query_builder << '/v2/catalog/search-catalog-items'
481
+ _query_url = APIHelper.clean_url _query_builder
482
+
483
+ # Prepare headers.
484
+ _headers = {
485
+ 'accept' => 'application/json',
486
+ 'content-type' => 'application/json; charset=utf-8'
487
+ }
488
+
489
+ # Prepare and execute HttpRequest.
490
+ _request = config.http_client.post(
491
+ _query_url,
492
+ headers: _headers,
493
+ parameters: body.to_json
494
+ )
495
+ OAuth2.apply(config, _request)
496
+ _response = execute_request(_request)
497
+
498
+ # Return appropriate response type.
499
+ decoded = APIHelper.json_deserialize(_response.raw_body)
500
+ _errors = APIHelper.map_response(decoded, ['errors'])
501
+ ApiResponse.new(_response, data: decoded, errors: _errors)
502
+ end
503
+
456
504
  # Updates the [CatalogModifierList](#type-catalogmodifierlist) objects
457
505
  # that apply to the targeted [CatalogItem](#type-catalogitem) without having
458
506
  # to perform an upsert on the entire item.
@@ -253,8 +253,8 @@ module Square
253
253
  # @param [String] cursor Optional parameter: A pagination cursor returned by
254
254
  # a previous call to this endpoint. Provide this to retrieve the next set of
255
255
  # results for the original query. See the
256
- # [Pagination](https://developer.squareup.com/docs/docs/working-with-apis/pa
257
- # gination) guide for more information.
256
+ # [Pagination](https://developer.squareup.com/docs/working-with-apis/paginat
257
+ # ion) guide for more information.
258
258
  # @return [RetrieveInventoryChangesResponse Hash] response from the API call
259
259
  def retrieve_inventory_changes(catalog_object_id:,
260
260
  location_ids: nil,
@@ -0,0 +1,358 @@
1
+ module Square
2
+ # InvoicesApi
3
+ class InvoicesApi < BaseApi
4
+ def initialize(config, http_call_back: nil)
5
+ super(config, http_call_back: http_call_back)
6
+ end
7
+
8
+ # Returns a list of invoices for a given location. The response
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.
11
+ # For more information about retrieving invoices, see [Retrieve
12
+ # invoices](https://developer.squareup.com/docs/docs/invoices-api/overview#r
13
+ # etrieve-invoices).
14
+ # @param [String] location_id Required parameter: The ID of the location for
15
+ # which to list invoices.
16
+ # @param [String] cursor Optional parameter: A pagination cursor returned by
17
+ # a previous call to this endpoint. Provide this cursor to retrieve the
18
+ # next set of results for your original query. For more information, see
19
+ # [Pagination](https://developer.squareup.com/docs/docs/working-with-apis/pa
20
+ # gination).
21
+ # @param [Integer] limit Optional parameter: The maximum number of invoices
22
+ # to return (200 is the maximum `limit`). If not provided, the server uses
23
+ # a default limit of 100 invoices.
24
+ # @return [ListInvoicesResponse Hash] response from the API call
25
+ def list_invoices(location_id:,
26
+ cursor: nil,
27
+ limit: nil)
28
+ # Prepare query url.
29
+ _query_builder = config.get_base_uri
30
+ _query_builder << '/v2/invoices'
31
+ _query_builder = APIHelper.append_url_with_query_parameters(
32
+ _query_builder,
33
+ 'location_id' => location_id,
34
+ 'cursor' => cursor,
35
+ 'limit' => limit
36
+ )
37
+ _query_url = APIHelper.clean_url _query_builder
38
+
39
+ # Prepare headers.
40
+ _headers = {
41
+ 'accept' => 'application/json'
42
+ }
43
+
44
+ # Prepare and execute HttpRequest.
45
+ _request = config.http_client.get(
46
+ _query_url,
47
+ headers: _headers
48
+ )
49
+ OAuth2.apply(config, _request)
50
+ _response = execute_request(_request)
51
+
52
+ # Return appropriate response type.
53
+ decoded = APIHelper.json_deserialize(_response.raw_body)
54
+ _errors = APIHelper.map_response(decoded, ['errors'])
55
+ ApiResponse.new(_response, data: decoded, errors: _errors)
56
+ end
57
+
58
+ # Creates a draft [invoice](#type-invoice)
59
+ # for an order created using the Orders API.
60
+ # A draft invoice remains in your account and no action is taken.
61
+ # You must publish the invoice before Square can process it (send it to the
62
+ # 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
+ # @param [CreateInvoiceRequest] body Required parameter: An object
66
+ # containing the fields to POST for the request. See the corresponding
67
+ # object definition for field details.
68
+ # @return [CreateInvoiceResponse Hash] response from the API call
69
+ def create_invoice(body:)
70
+ # Prepare query url.
71
+ _query_builder = config.get_base_uri
72
+ _query_builder << '/v2/invoices'
73
+ _query_url = APIHelper.clean_url _query_builder
74
+
75
+ # Prepare headers.
76
+ _headers = {
77
+ 'accept' => 'application/json',
78
+ 'content-type' => 'application/json; charset=utf-8'
79
+ }
80
+
81
+ # Prepare and execute HttpRequest.
82
+ _request = config.http_client.post(
83
+ _query_url,
84
+ headers: _headers,
85
+ parameters: body.to_json
86
+ )
87
+ OAuth2.apply(config, _request)
88
+ _response = execute_request(_request)
89
+
90
+ # Return appropriate response type.
91
+ decoded = APIHelper.json_deserialize(_response.raw_body)
92
+ _errors = APIHelper.map_response(decoded, ['errors'])
93
+ ApiResponse.new(_response, data: decoded, errors: _errors)
94
+ end
95
+
96
+ # Searches for invoices from a location specified in
97
+ # the filter. You can optionally specify customers in the filter for whom to
98
+ # retrieve invoices. In the current implementation, you can only specify one
99
+ # location and
100
+ # optionally one customer.
101
+ # The response is paginated. If truncated, the response includes a `cursor`
102
+ # that you use in a subsequent request to fetch the next set of invoices.
103
+ # For more information about retrieving invoices, see [Retrieve
104
+ # invoices](https://developer.squareup.com/docs/docs/invoices-api/overview#r
105
+ # etrieve-invoices).
106
+ # @param [SearchInvoicesRequest] body Required parameter: An object
107
+ # containing the fields to POST for the request. See the corresponding
108
+ # object definition for field details.
109
+ # @return [SearchInvoicesResponse Hash] response from the API call
110
+ def search_invoices(body:)
111
+ # Prepare query url.
112
+ _query_builder = config.get_base_uri
113
+ _query_builder << '/v2/invoices/search'
114
+ _query_url = APIHelper.clean_url _query_builder
115
+
116
+ # Prepare headers.
117
+ _headers = {
118
+ 'accept' => 'application/json',
119
+ 'content-type' => 'application/json; charset=utf-8'
120
+ }
121
+
122
+ # Prepare and execute HttpRequest.
123
+ _request = config.http_client.post(
124
+ _query_url,
125
+ headers: _headers,
126
+ parameters: body.to_json
127
+ )
128
+ OAuth2.apply(config, _request)
129
+ _response = execute_request(_request)
130
+
131
+ # Return appropriate response type.
132
+ decoded = APIHelper.json_deserialize(_response.raw_body)
133
+ _errors = APIHelper.map_response(decoded, ['errors'])
134
+ ApiResponse.new(_response, data: decoded, errors: _errors)
135
+ end
136
+
137
+ # Deletes the specified invoice. When an invoice is deleted, the
138
+ # associated Order status changes to CANCELED. You can only delete a draft
139
+ # invoice (you cannot delete an invoice scheduled for publication, or a
140
+ # published invoice).
141
+ # @param [String] invoice_id Required parameter: The ID of the invoice to
142
+ # delete.
143
+ # @param [Integer] version Optional parameter: The version of the
144
+ # [invoice](#type-invoice) to delete. If you do not know the version, you
145
+ # can call [GetInvoice](#endpoint-Invoices-GetInvoice) or
146
+ # [ListInvoices](#endpoint-Invoices-ListInvoices).
147
+ # @return [DeleteInvoiceResponse Hash] response from the API call
148
+ def delete_invoice(invoice_id:,
149
+ version: nil)
150
+ # Prepare query url.
151
+ _query_builder = config.get_base_uri
152
+ _query_builder << '/v2/invoices/{invoice_id}'
153
+ _query_builder = APIHelper.append_url_with_template_parameters(
154
+ _query_builder,
155
+ 'invoice_id' => invoice_id
156
+ )
157
+ _query_builder = APIHelper.append_url_with_query_parameters(
158
+ _query_builder,
159
+ 'version' => version
160
+ )
161
+ _query_url = APIHelper.clean_url _query_builder
162
+
163
+ # Prepare headers.
164
+ _headers = {
165
+ 'accept' => 'application/json'
166
+ }
167
+
168
+ # Prepare and execute HttpRequest.
169
+ _request = config.http_client.delete(
170
+ _query_url,
171
+ headers: _headers
172
+ )
173
+ OAuth2.apply(config, _request)
174
+ _response = execute_request(_request)
175
+
176
+ # Return appropriate response type.
177
+ decoded = APIHelper.json_deserialize(_response.raw_body)
178
+ _errors = APIHelper.map_response(decoded, ['errors'])
179
+ ApiResponse.new(_response, data: decoded, errors: _errors)
180
+ end
181
+
182
+ # Retrieves an invoice by invoice ID.
183
+ # @param [String] invoice_id Required parameter: The id of the invoice to
184
+ # retrieve.
185
+ # @return [GetInvoiceResponse Hash] response from the API call
186
+ def get_invoice(invoice_id:)
187
+ # Prepare query url.
188
+ _query_builder = config.get_base_uri
189
+ _query_builder << '/v2/invoices/{invoice_id}'
190
+ _query_builder = APIHelper.append_url_with_template_parameters(
191
+ _query_builder,
192
+ 'invoice_id' => invoice_id
193
+ )
194
+ _query_url = APIHelper.clean_url _query_builder
195
+
196
+ # Prepare headers.
197
+ _headers = {
198
+ 'accept' => 'application/json'
199
+ }
200
+
201
+ # Prepare and execute HttpRequest.
202
+ _request = config.http_client.get(
203
+ _query_url,
204
+ headers: _headers
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
+
215
+ # Updates an invoice by modifying field values, clearing field values, or
216
+ # both
217
+ # as specified in the request.
218
+ # There are no restrictions to updating an invoice in a draft state.
219
+ # However, there are guidelines for updating a published invoice.
220
+ # For more information, see [Update an
221
+ # invoice](https://developer.squareup.com/docs/docs/invoices-api/overview#up
222
+ # date-an-invoice).
223
+ # @param [String] invoice_id Required parameter: The id of the invoice to
224
+ # update.
225
+ # @param [UpdateInvoiceRequest] body Required parameter: An object
226
+ # containing the fields to POST for the request. See the corresponding
227
+ # object definition for field details.
228
+ # @return [UpdateInvoiceResponse Hash] response from the API call
229
+ def update_invoice(invoice_id:,
230
+ body:)
231
+ # Prepare query url.
232
+ _query_builder = config.get_base_uri
233
+ _query_builder << '/v2/invoices/{invoice_id}'
234
+ _query_builder = APIHelper.append_url_with_template_parameters(
235
+ _query_builder,
236
+ 'invoice_id' => invoice_id
237
+ )
238
+ _query_url = APIHelper.clean_url _query_builder
239
+
240
+ # Prepare headers.
241
+ _headers = {
242
+ 'accept' => 'application/json',
243
+ 'content-type' => 'application/json; charset=utf-8'
244
+ }
245
+
246
+ # Prepare and execute HttpRequest.
247
+ _request = config.http_client.put(
248
+ _query_url,
249
+ headers: _headers,
250
+ parameters: body.to_json
251
+ )
252
+ OAuth2.apply(config, _request)
253
+ _response = execute_request(_request)
254
+
255
+ # Return appropriate response type.
256
+ decoded = APIHelper.json_deserialize(_response.raw_body)
257
+ _errors = APIHelper.map_response(decoded, ['errors'])
258
+ ApiResponse.new(_response, data: decoded, errors: _errors)
259
+ end
260
+
261
+ # Cancels an invoice. The seller cannot collect payments for
262
+ # the canceled invoice.
263
+ # You cannot cancel an invoice in a terminal state: `PAID`, `REFUNDED`,
264
+ # `CANCELED`, or `FAILED`.
265
+ # @param [String] invoice_id Required parameter: The ID of the
266
+ # [invoice](#type-invoice) to cancel.
267
+ # @param [CancelInvoiceRequest] body Required parameter: An object
268
+ # containing the fields to POST for the request. See the corresponding
269
+ # object definition for field details.
270
+ # @return [CancelInvoiceResponse Hash] response from the API call
271
+ def cancel_invoice(invoice_id:,
272
+ body:)
273
+ # Prepare query url.
274
+ _query_builder = config.get_base_uri
275
+ _query_builder << '/v2/invoices/{invoice_id}/cancel'
276
+ _query_builder = APIHelper.append_url_with_template_parameters(
277
+ _query_builder,
278
+ 'invoice_id' => invoice_id
279
+ )
280
+ _query_url = APIHelper.clean_url _query_builder
281
+
282
+ # Prepare headers.
283
+ _headers = {
284
+ 'accept' => 'application/json',
285
+ 'content-type' => 'application/json; charset=utf-8'
286
+ }
287
+
288
+ # Prepare and execute HttpRequest.
289
+ _request = config.http_client.post(
290
+ _query_url,
291
+ headers: _headers,
292
+ parameters: body.to_json
293
+ )
294
+ OAuth2.apply(config, _request)
295
+ _response = execute_request(_request)
296
+
297
+ # Return appropriate response type.
298
+ decoded = APIHelper.json_deserialize(_response.raw_body)
299
+ _errors = APIHelper.map_response(decoded, ['errors'])
300
+ ApiResponse.new(_response, data: decoded, errors: _errors)
301
+ end
302
+
303
+ # Publishes the specified draft invoice.
304
+ # After an invoice is published, Square
305
+ # follows up based on the invoice configuration. For example, Square
306
+ # sends the invoice to the customer's email address, charges the customer's
307
+ # card on file, or does
308
+ # nothing. Square also makes the invoice available on a Square-hosted
309
+ # invoice page.
310
+ # The invoice `status` also changes from `DRAFT` to a status
311
+ # based on the invoice configuration. For example, the status changes to
312
+ # `UNPAID` if
313
+ # Square emails the invoice or `PARTIALLY_PAID` if Square charge a card on
314
+ # file for a portion of the
315
+ # invoice amount).
316
+ # For more information, see
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
+ # publish.
322
+ # @param [PublishInvoiceRequest] body Required parameter: An object
323
+ # containing the fields to POST for the request. See the corresponding
324
+ # object definition for field details.
325
+ # @return [PublishInvoiceResponse Hash] response from the API call
326
+ def publish_invoice(invoice_id:,
327
+ body:)
328
+ # Prepare query url.
329
+ _query_builder = config.get_base_uri
330
+ _query_builder << '/v2/invoices/{invoice_id}/publish'
331
+ _query_builder = APIHelper.append_url_with_template_parameters(
332
+ _query_builder,
333
+ 'invoice_id' => invoice_id
334
+ )
335
+ _query_url = APIHelper.clean_url _query_builder
336
+
337
+ # Prepare headers.
338
+ _headers = {
339
+ 'accept' => 'application/json',
340
+ 'content-type' => 'application/json; charset=utf-8'
341
+ }
342
+
343
+ # Prepare and execute HttpRequest.
344
+ _request = config.http_client.post(
345
+ _query_url,
346
+ headers: _headers,
347
+ parameters: body.to_json
348
+ )
349
+ OAuth2.apply(config, _request)
350
+ _response = execute_request(_request)
351
+
352
+ # Return appropriate response type.
353
+ decoded = APIHelper.json_deserialize(_response.raw_body)
354
+ _errors = APIHelper.map_response(decoded, ['errors'])
355
+ ApiResponse.new(_response, data: decoded, errors: _errors)
356
+ end
357
+ end
358
+ end
@@ -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.
@@ -4,11 +4,11 @@ module Square
4
4
  attr_reader :config
5
5
 
6
6
  def sdk_version
7
- '6.0.0.20200625'
7
+ '6.1.0.20200722'
8
8
  end
9
9
 
10
10
  def square_version
11
- '2020-06-25'
11
+ config.square_version
12
12
  end
13
13
 
14
14
  # Access to mobile_authorization controller.
@@ -113,6 +113,12 @@ module Square
113
113
  @inventory ||= InventoryApi.new config
114
114
  end
115
115
 
116
+ # Access to invoices controller.
117
+ # @return [InvoicesApi] Returns the controller instance.
118
+ def invoices
119
+ @invoices ||= InvoicesApi.new config
120
+ end
121
+
116
122
  # Access to labor controller.
117
123
  # @return [LaborApi] Returns the controller instance.
118
124
  def labor
@@ -187,13 +193,14 @@ module Square
187
193
 
188
194
  def initialize(timeout: 60, max_retries: 0, retry_interval: 1,
189
195
  backoff_factor: 1, environment: 'production',
190
- access_token: 'TODO: Replace', additional_headers: {},
191
- config: nil)
196
+ square_version: '2020-07-22', access_token: 'TODO: Replace',
197
+ additional_headers: {}, config: nil)
192
198
  @config = if config.nil?
193
199
  Configuration.new(timeout: timeout, max_retries: max_retries,
194
200
  retry_interval: retry_interval,
195
201
  backoff_factor: backoff_factor,
196
202
  environment: environment,
203
+ square_version: square_version,
197
204
  access_token: access_token,
198
205
  additional_headers: additional_headers)
199
206
  else
@@ -9,6 +9,7 @@ module Square
9
9
  attr_reader :retry_interval
10
10
  attr_reader :backoff_factor
11
11
  attr_reader :environment
12
+ attr_reader :square_version
12
13
  attr_reader :access_token
13
14
 
14
15
  def additional_headers
@@ -21,7 +22,8 @@ module Square
21
22
 
22
23
  def initialize(timeout: 60, max_retries: 0, retry_interval: 1,
23
24
  backoff_factor: 1, environment: 'production',
24
- access_token: 'TODO: Replace', additional_headers: {})
25
+ square_version: '2020-07-22', access_token: 'TODO: Replace',
26
+ additional_headers: {})
25
27
  # The value to use for connection timeout
26
28
  @timeout = timeout
27
29
 
@@ -38,6 +40,9 @@ module Square
38
40
  # Current API environment
39
41
  @environment = String(environment)
40
42
 
43
+ # Square Connect API versions
44
+ @square_version = square_version
45
+
41
46
  # OAuth 2.0 Access Token
42
47
  @access_token = access_token
43
48
 
@@ -49,20 +54,23 @@ module Square
49
54
  end
50
55
 
51
56
  def clone_with(timeout: nil, max_retries: nil, retry_interval: nil,
52
- backoff_factor: nil, environment: nil, access_token: nil,
53
- additional_headers: nil)
57
+ backoff_factor: nil, environment: nil, square_version: nil,
58
+ access_token: nil, additional_headers: nil)
54
59
  timeout ||= self.timeout
55
60
  max_retries ||= self.max_retries
56
61
  retry_interval ||= self.retry_interval
57
62
  backoff_factor ||= self.backoff_factor
58
63
  environment ||= self.environment
64
+ square_version ||= self.square_version
59
65
  access_token ||= self.access_token
60
66
  additional_headers ||= self.additional_headers
61
67
 
62
68
  Configuration.new(timeout: timeout, max_retries: max_retries,
63
69
  retry_interval: retry_interval,
64
70
  backoff_factor: backoff_factor,
65
- environment: environment, access_token: access_token,
71
+ environment: environment,
72
+ square_version: square_version,
73
+ access_token: access_token,
66
74
  additional_headers: additional_headers)
67
75
  end
68
76
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: square.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.0.20200625
4
+ version: 6.1.0.20200722
5
5
  platform: ruby
6
6
  authors:
7
7
  - Square Developer Platform
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-25 00:00:00.000000000 Z
11
+ date: 2020-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logging
@@ -131,6 +131,7 @@ files:
131
131
  - lib/square/api/disputes_api.rb
132
132
  - lib/square/api/employees_api.rb
133
133
  - lib/square/api/inventory_api.rb
134
+ - lib/square/api/invoices_api.rb
134
135
  - lib/square/api/labor_api.rb
135
136
  - lib/square/api/locations_api.rb
136
137
  - lib/square/api/loyalty_api.rb