square.rb 12.0.0.20210616 → 15.0.0.20211020
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +38 -21
- data/lib/square/api/base_api.rb +5 -9
- data/lib/square/api/catalog_api.rb +2 -2
- data/lib/square/api/customer_groups_api.rb +10 -2
- data/lib/square/api/customer_segments_api.rb +10 -2
- data/lib/square/api/customers_api.rb +11 -3
- data/lib/square/api/gift_cards_api.rb +3 -2
- data/lib/square/api/inventory_api.rb +244 -5
- data/lib/square/api/labor_api.rb +64 -62
- data/lib/square/api/loyalty_api.rb +15 -5
- data/lib/square/api/o_auth_api.rb +19 -12
- data/lib/square/api/orders_api.rb +37 -0
- data/lib/square/api/payments_api.rb +9 -3
- data/lib/square/api/transactions_api.rb +0 -188
- data/lib/square/api_helper.rb +19 -29
- data/lib/square/client.rb +6 -11
- data/lib/square/configuration.rb +19 -20
- data/lib/square/http/api_response.rb +1 -1
- data/lib/square/http/faraday_client.rb +21 -2
- data/lib/square/utilities/date_time_helper.rb +151 -0
- data/lib/square/utilities/file_wrapper.rb +1 -2
- data/lib/square.rb +48 -48
- metadata +12 -9
- data/lib/square/api/v1_employees_api.rb +0 -362
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25322287d3387bc053e23f58c5a3b74476789df2145f9648f46b330517aa7574
|
4
|
+
data.tar.gz: a5476f517732ce5df169b402fded9909cefa155e02c90d9af5996e4dc087a887
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d30c67ff2493a1dded81c4078d3549c0c195f092f9826735cd1f98bb6749153bd45d6614419f95f6d6fb32ed505459abc11ab0508b3fa51f0ad089f8a0cce51
|
7
|
+
data.tar.gz: 2b4a9e0bdb771a3658ec3a46b9838421c154ff1b280da9d27e589111dbb010c2d3c5672ae38d5b22e52ae26f864ae6d8cd76e53effc65e65fdefafcf0b949aa4
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -8,6 +8,10 @@
|
|
8
8
|
|
9
9
|
Use this gem to integrate Square payments into your app and grow your business with Square APIs including Catalog, Customers, Employees, Inventory, Labor, Locations, and Orders.
|
10
10
|
|
11
|
+
## Requirements
|
12
|
+
|
13
|
+
We support Ruby 2.5.x, 2.6.x, and 2.7.x.
|
14
|
+
|
11
15
|
## Installation
|
12
16
|
|
13
17
|
Install the gem from the command line:
|
@@ -33,6 +37,9 @@ gem 'square.rb'
|
|
33
37
|
* [Disputes]
|
34
38
|
* [Checkout]
|
35
39
|
* [Apple Pay]
|
40
|
+
* [Cards]
|
41
|
+
|
42
|
+
### Terminal
|
36
43
|
* [Terminal]
|
37
44
|
|
38
45
|
### Orders
|
@@ -56,6 +63,10 @@ gem 'square.rb'
|
|
56
63
|
### Loyalty
|
57
64
|
* [Loyalty]
|
58
65
|
|
66
|
+
### Gift Cards
|
67
|
+
* [Gift Cards]
|
68
|
+
* [Gift Card Activities]
|
69
|
+
|
59
70
|
### Bookings
|
60
71
|
* [Bookings]
|
61
72
|
|
@@ -63,12 +74,11 @@ gem 'square.rb'
|
|
63
74
|
* [Merchants]
|
64
75
|
* [Locations]
|
65
76
|
* [Devices]
|
77
|
+
* [Cash Drawers]
|
66
78
|
|
67
79
|
### Team
|
68
80
|
* [Team]
|
69
|
-
* [Employees]
|
70
81
|
* [Labor]
|
71
|
-
* [Cash Drawers]
|
72
82
|
|
73
83
|
### Financials
|
74
84
|
* [Bank Accounts]
|
@@ -82,6 +92,7 @@ gem 'square.rb'
|
|
82
92
|
* [OAuth]
|
83
93
|
|
84
94
|
### Deprecated APIs
|
95
|
+
* [Employees]
|
85
96
|
* [V1 Employees]
|
86
97
|
* [V1 Transactions]
|
87
98
|
* [V1 Items]
|
@@ -104,8 +115,8 @@ require 'square'
|
|
104
115
|
# for the Square account whose assets you want to manage.
|
105
116
|
|
106
117
|
client = Square::Client.new(
|
107
|
-
|
108
|
-
|
118
|
+
access_token: 'YOUR SANDBOX ACCESS TOKEN HERE',
|
119
|
+
environment: 'sandbox'
|
109
120
|
)
|
110
121
|
|
111
122
|
# Call list_locations method to get all locations in this Square account
|
@@ -113,10 +124,10 @@ result = client.locations.list_locations
|
|
113
124
|
|
114
125
|
# Call the #success? method to see if the call succeeded
|
115
126
|
if result.success?
|
116
|
-
|
127
|
+
# The #data Struct contains a list of locations
|
117
128
|
locations = result.data.locations
|
118
129
|
|
119
|
-
|
130
|
+
# Iterate over the list
|
120
131
|
locations.each do |location|
|
121
132
|
# Each location is represented as a Hash
|
122
133
|
location.each do |key, value|
|
@@ -165,6 +176,7 @@ This error was returned when an invalid token was used to call the API.
|
|
165
176
|
After you’ve tried out the Square APIs and tested your application using sandbox, you will want to switch to your production credentials so that you can manage real Square resources. Don't forget to switch your access token from sandbox to production for real data.
|
166
177
|
|
167
178
|
## SDK patterns
|
179
|
+
|
168
180
|
If you know a few patterns, you’ll be able to call any API in the SDK. Here are some important ones:
|
169
181
|
|
170
182
|
### Get an access token
|
@@ -185,30 +197,31 @@ To use the Square API, you import the Client class, instantiate a Client object,
|
|
185
197
|
|
186
198
|
- Instantiate a `Square::Client` object with the access token for the Square account whose resources you want to manage. To access sandbox resources, initialize the `Square::Client` with environment set to sandbox:
|
187
199
|
|
188
|
-
```ruby
|
189
|
-
client = Square::Client.new(
|
200
|
+
```ruby
|
201
|
+
client = Square::Client.new(
|
190
202
|
access_token: 'SANDBOX ACCESS TOKEN HERE',
|
191
203
|
environment: 'sandbox'
|
192
|
-
)
|
193
|
-
```
|
204
|
+
)
|
205
|
+
```
|
194
206
|
|
195
207
|
- To access production resources, set environment to production:
|
196
208
|
|
197
|
-
```ruby
|
198
|
-
client = Square::Client.new(
|
209
|
+
```ruby
|
210
|
+
client = Square::Client.new(
|
199
211
|
access_token: 'ACCESS TOKEN HERE',
|
200
212
|
environment: 'production'
|
201
|
-
)
|
202
|
-
```
|
213
|
+
)
|
214
|
+
```
|
203
215
|
|
204
216
|
- To set a custom environment provide a `custom_url`, and set environment to `custom`:
|
205
217
|
|
206
|
-
```ruby
|
207
|
-
client = Square::Client.new(
|
218
|
+
```ruby
|
219
|
+
client = Square::Client.new(
|
208
220
|
access_token:'ACCESS TOKEN HERE',
|
209
221
|
environment: 'custom',
|
210
222
|
custom_url: 'https://your.customdomain.com'
|
211
|
-
)
|
223
|
+
)
|
224
|
+
```
|
212
225
|
|
213
226
|
### Get an Instance of an API object and call its methods
|
214
227
|
|
@@ -216,9 +229,9 @@ Each API is implemented as a class. The Client object instantiates every API cla
|
|
216
229
|
|
217
230
|
- Work with an API by calling the methods on the API object. For example, you would call list_customers to get a list of all customers in the Square account:
|
218
231
|
|
219
|
-
```ruby
|
220
|
-
result = client.customers.list_customers
|
221
|
-
```
|
232
|
+
```ruby
|
233
|
+
result = client.customers.list_customers
|
234
|
+
```
|
222
235
|
|
223
236
|
See the SDK documentation for the list of methods for each API class.
|
224
237
|
|
@@ -239,6 +252,7 @@ result = client.customers.create_customer(request_body)
|
|
239
252
|
```
|
240
253
|
|
241
254
|
If your call succeeds, you’ll see a response that looks like this:
|
255
|
+
|
242
256
|
```
|
243
257
|
{'customer': {'created_at': '2019-06-28T21:23:05.126Z', 'creation_source': 'THIRD_PARTY', 'family_name': 'Earhardt', 'given_name': 'Amelia', 'id': 'CBASEDwl3El91nohQ2FLEk4aBfcgAQ', 'preferences': {'email_unsubscribed': False}, 'updated_at': '2019-06-28T21:23:05.126Z'}}
|
244
258
|
```
|
@@ -263,7 +277,7 @@ end
|
|
263
277
|
|
264
278
|
## Tests
|
265
279
|
|
266
|
-
First, clone the
|
280
|
+
First, clone the repo locally and `cd` into the directory.
|
267
281
|
|
268
282
|
```sh
|
269
283
|
git clone https://github.com/square/square-ruby-sdk.git
|
@@ -333,3 +347,6 @@ You can also use the Square API to create applications or services that work wit
|
|
333
347
|
[Transactions]: doc/api/transactions.md
|
334
348
|
[Sites]: doc/api/sites.md
|
335
349
|
[Snippets]: doc/api/snippets.md
|
350
|
+
[Cards]: doc/api/cards.md
|
351
|
+
[Gift Cards]: doc/api/gift-cards.md
|
352
|
+
[Gift Card Activities]: doc/api/gift-card-activities.md
|
data/lib/square/api/base_api.rb
CHANGED
@@ -8,34 +8,30 @@ module Square
|
|
8
8
|
@http_call_back = http_call_back
|
9
9
|
|
10
10
|
@global_headers = {
|
11
|
-
'user-agent' => 'Square-Ruby-SDK/
|
11
|
+
'user-agent' => 'Square-Ruby-SDK/15.0.0.20211020',
|
12
12
|
'Square-Version' => config.square_version
|
13
13
|
}
|
14
14
|
end
|
15
15
|
|
16
16
|
def validate_parameters(args)
|
17
17
|
args.each do |_name, value|
|
18
|
-
if value.nil?
|
19
|
-
raise ArgumentError, "Required parameter #{_name} cannot be nil."
|
20
|
-
end
|
18
|
+
raise ArgumentError, "Required parameter #{_name} cannot be nil." if value.nil?
|
21
19
|
end
|
22
20
|
end
|
23
21
|
|
24
22
|
def execute_request(request, binary: false)
|
25
|
-
@http_call_back
|
23
|
+
@http_call_back&.on_before_request(request)
|
26
24
|
|
27
25
|
APIHelper.clean_hash(request.headers)
|
28
26
|
request.headers.merge!(@global_headers)
|
29
|
-
unless config.additional_headers.nil?
|
30
|
-
request.headers.merge!(config.additional_headers)
|
31
|
-
end
|
27
|
+
request.headers.merge!(config.additional_headers) unless config.additional_headers.nil?
|
32
28
|
|
33
29
|
response = if binary
|
34
30
|
config.http_client.execute_as_binary(request)
|
35
31
|
else
|
36
32
|
config.http_client.execute_as_string(request)
|
37
33
|
end
|
38
|
-
@http_call_back
|
34
|
+
@http_call_back&.on_after_response(response)
|
39
35
|
|
40
36
|
response
|
41
37
|
end
|
@@ -435,7 +435,7 @@ module Square
|
|
435
435
|
# Searches for [CatalogObject]($m/CatalogObject) of any type by matching
|
436
436
|
# supported search attribute values,
|
437
437
|
# excluding custom attribute values on items or item variations, against one
|
438
|
-
# or more of the specified query
|
438
|
+
# or more of the specified query filters.
|
439
439
|
# This (`SearchCatalogObjects`) endpoint differs from the
|
440
440
|
# [SearchCatalogItems]($e/Catalog/SearchCatalogItems)
|
441
441
|
# endpoint in the following aspects:
|
@@ -485,7 +485,7 @@ module Square
|
|
485
485
|
# Searches for catalog items or item variations by matching supported search
|
486
486
|
# attribute values, including
|
487
487
|
# custom attribute values, against one or more of the specified query
|
488
|
-
#
|
488
|
+
# filters.
|
489
489
|
# This (`SearchCatalogItems`) endpoint differs from the
|
490
490
|
# [SearchCatalogObjects]($e/Catalog/SearchCatalogObjects)
|
491
491
|
# endpoint in the following aspects:
|
@@ -11,14 +11,22 @@ module Square
|
|
11
11
|
# set of results for your original query. For more information, see
|
12
12
|
# [Pagination](https://developer.squareup.com/docs/working-with-apis/paginat
|
13
13
|
# ion).
|
14
|
+
# @param [Integer] limit Optional parameter: The maximum number of results
|
15
|
+
# to return in a single page. This limit is advisory. The response might
|
16
|
+
# contain more or fewer results. The limit is ignored if it is less than 1
|
17
|
+
# or greater than 50. The default value is 50. For more information, see
|
18
|
+
# [Pagination](https://developer.squareup.com/docs/working-with-apis/paginat
|
19
|
+
# ion).
|
14
20
|
# @return [ListCustomerGroupsResponse Hash] response from the API call
|
15
|
-
def list_customer_groups(cursor: nil
|
21
|
+
def list_customer_groups(cursor: nil,
|
22
|
+
limit: nil)
|
16
23
|
# Prepare query url.
|
17
24
|
_query_builder = config.get_base_uri
|
18
25
|
_query_builder << '/v2/customers/groups'
|
19
26
|
_query_builder = APIHelper.append_url_with_query_parameters(
|
20
27
|
_query_builder,
|
21
|
-
'cursor' => cursor
|
28
|
+
'cursor' => cursor,
|
29
|
+
'limit' => limit
|
22
30
|
)
|
23
31
|
_query_url = APIHelper.clean_url _query_builder
|
24
32
|
|
@@ -11,14 +11,22 @@ module Square
|
|
11
11
|
# the next set of query results. For more information, see
|
12
12
|
# [Pagination](https://developer.squareup.com/docs/working-with-apis/paginat
|
13
13
|
# ion).
|
14
|
+
# @param [Integer] limit Optional parameter: The maximum number of results
|
15
|
+
# to return in a single page. This limit is advisory. The response might
|
16
|
+
# contain more or fewer results. The limit is ignored if it is less than 1
|
17
|
+
# or greater than 50. The default value is 50. For more information, see
|
18
|
+
# [Pagination](https://developer.squareup.com/docs/working-with-apis/paginat
|
19
|
+
# ion).
|
14
20
|
# @return [ListCustomerSegmentsResponse Hash] response from the API call
|
15
|
-
def list_customer_segments(cursor: nil
|
21
|
+
def list_customer_segments(cursor: nil,
|
22
|
+
limit: nil)
|
16
23
|
# Prepare query url.
|
17
24
|
_query_builder = config.get_base_uri
|
18
25
|
_query_builder << '/v2/customers/segments'
|
19
26
|
_query_builder = APIHelper.append_url_with_query_parameters(
|
20
27
|
_query_builder,
|
21
|
-
'cursor' => cursor
|
28
|
+
'cursor' => cursor,
|
29
|
+
'limit' => limit
|
22
30
|
)
|
23
31
|
_query_url = APIHelper.clean_url _query_builder
|
24
32
|
|
@@ -17,13 +17,20 @@ module Square
|
|
17
17
|
# set of results for your original query. For more information, see
|
18
18
|
# [Pagination](https://developer.squareup.com/docs/working-with-apis/paginat
|
19
19
|
# ion).
|
20
|
+
# @param [Integer] limit Optional parameter: The maximum number of results
|
21
|
+
# to return in a single page. This limit is advisory. The response might
|
22
|
+
# contain more or fewer results. The limit is ignored if it is less than 1
|
23
|
+
# or greater than 100. The default value is 100. For more information, see
|
24
|
+
# [Pagination](https://developer.squareup.com/docs/working-with-apis/paginat
|
25
|
+
# ion).
|
20
26
|
# @param [CustomerSortField] sort_field Optional parameter: Indicates how
|
21
|
-
# customers should be sorted.
|
27
|
+
# customers should be sorted. The default value is `DEFAULT`.
|
22
28
|
# @param [SortOrder] sort_order Optional parameter: Indicates whether
|
23
29
|
# customers should be sorted in ascending (`ASC`) or descending (`DESC`)
|
24
|
-
# order.
|
30
|
+
# order. The default value is `ASC`.
|
25
31
|
# @return [ListCustomersResponse Hash] response from the API call
|
26
32
|
def list_customers(cursor: nil,
|
33
|
+
limit: nil,
|
27
34
|
sort_field: nil,
|
28
35
|
sort_order: nil)
|
29
36
|
# Prepare query url.
|
@@ -32,6 +39,7 @@ module Square
|
|
32
39
|
_query_builder = APIHelper.append_url_with_query_parameters(
|
33
40
|
_query_builder,
|
34
41
|
'cursor' => cursor,
|
42
|
+
'limit' => limit,
|
35
43
|
'sort_field' => sort_field,
|
36
44
|
'sort_order' => sort_order
|
37
45
|
)
|
@@ -156,7 +164,7 @@ module Square
|
|
156
164
|
# @param [String] customer_id Required parameter: The ID of the customer to
|
157
165
|
# delete.
|
158
166
|
# @param [Long] version Optional parameter: The current version of the
|
159
|
-
# customer profile.
|
167
|
+
# customer profile. As a best practice, you should include this parameter
|
160
168
|
# to enable [optimistic
|
161
169
|
# concurrency](https://developer.squareup.com/docs/working-with-apis/optimis
|
162
170
|
# tic-concurrency) control. For more information, see [Delete a customer
|
@@ -65,8 +65,9 @@ module Square
|
|
65
65
|
)
|
66
66
|
end
|
67
67
|
|
68
|
-
# Creates a digital gift card
|
69
|
-
#
|
68
|
+
# Creates a digital gift card or registers a physical (plastic) gift card.
|
69
|
+
# You must activate the gift card before
|
70
|
+
# it can be used for payment. For more information, see
|
70
71
|
# [Selling gift
|
71
72
|
# cards](https://developer.squareup.com/docs/gift-cards/using-gift-cards-api
|
72
73
|
# #selling-square-gift-cards).
|
@@ -5,6 +5,46 @@ module Square
|
|
5
5
|
super(config, http_call_back: http_call_back)
|
6
6
|
end
|
7
7
|
|
8
|
+
# Deprecated version of
|
9
|
+
# [RetrieveInventoryAdjustment]($e/Inventory/RetrieveInventoryAdjustment)
|
10
|
+
# after the endpoint URL
|
11
|
+
# is updated to conform to the standard convention.
|
12
|
+
# @param [String] adjustment_id Required parameter: ID of the
|
13
|
+
# [InventoryAdjustment]($m/InventoryAdjustment) to retrieve.
|
14
|
+
# @return [RetrieveInventoryAdjustmentResponse Hash] response from the API call
|
15
|
+
def deprecated_retrieve_inventory_adjustment(adjustment_id:)
|
16
|
+
warn 'Endpoint deprecated_retrieve_inventory_adjustment in InventoryApi '\
|
17
|
+
'is deprecated'
|
18
|
+
# Prepare query url.
|
19
|
+
_query_builder = config.get_base_uri
|
20
|
+
_query_builder << '/v2/inventory/adjustment/{adjustment_id}'
|
21
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
22
|
+
_query_builder,
|
23
|
+
'adjustment_id' => { 'value' => adjustment_id, 'encode' => true }
|
24
|
+
)
|
25
|
+
_query_url = APIHelper.clean_url _query_builder
|
26
|
+
|
27
|
+
# Prepare headers.
|
28
|
+
_headers = {
|
29
|
+
'accept' => 'application/json'
|
30
|
+
}
|
31
|
+
|
32
|
+
# Prepare and execute HttpRequest.
|
33
|
+
_request = config.http_client.get(
|
34
|
+
_query_url,
|
35
|
+
headers: _headers
|
36
|
+
)
|
37
|
+
OAuth2.apply(config, _request)
|
38
|
+
_response = execute_request(_request)
|
39
|
+
|
40
|
+
# Return appropriate response type.
|
41
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
42
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
43
|
+
ApiResponse.new(
|
44
|
+
_response, data: decoded, errors: _errors
|
45
|
+
)
|
46
|
+
end
|
47
|
+
|
8
48
|
# Returns the [InventoryAdjustment]($m/InventoryAdjustment) object
|
9
49
|
# with the provided `adjustment_id`.
|
10
50
|
# @param [String] adjustment_id Required parameter: ID of the
|
@@ -13,7 +53,7 @@ module Square
|
|
13
53
|
def retrieve_inventory_adjustment(adjustment_id:)
|
14
54
|
# Prepare query url.
|
15
55
|
_query_builder = config.get_base_uri
|
16
|
-
_query_builder << '/v2/inventory/
|
56
|
+
_query_builder << '/v2/inventory/adjustments/{adjustment_id}'
|
17
57
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
18
58
|
_query_builder,
|
19
59
|
'adjustment_id' => { 'value' => adjustment_id, 'encode' => true }
|
@@ -41,6 +81,123 @@ module Square
|
|
41
81
|
)
|
42
82
|
end
|
43
83
|
|
84
|
+
# Deprecated version of
|
85
|
+
# [BatchChangeInventory]($e/Inventory/BatchChangeInventory) after the
|
86
|
+
# endpoint URL
|
87
|
+
# is updated to conform to the standard convention.
|
88
|
+
# @param [BatchChangeInventoryRequest] body Required parameter: An object
|
89
|
+
# containing the fields to POST for the request. See the corresponding
|
90
|
+
# object definition for field details.
|
91
|
+
# @return [BatchChangeInventoryResponse Hash] response from the API call
|
92
|
+
def deprecated_batch_change_inventory(body:)
|
93
|
+
warn 'Endpoint deprecated_batch_change_inventory in InventoryApi is depr'\
|
94
|
+
'ecated'
|
95
|
+
# Prepare query url.
|
96
|
+
_query_builder = config.get_base_uri
|
97
|
+
_query_builder << '/v2/inventory/batch-change'
|
98
|
+
_query_url = APIHelper.clean_url _query_builder
|
99
|
+
|
100
|
+
# Prepare headers.
|
101
|
+
_headers = {
|
102
|
+
'accept' => 'application/json',
|
103
|
+
'content-type' => 'application/json; charset=utf-8'
|
104
|
+
}
|
105
|
+
|
106
|
+
# Prepare and execute HttpRequest.
|
107
|
+
_request = config.http_client.post(
|
108
|
+
_query_url,
|
109
|
+
headers: _headers,
|
110
|
+
parameters: body.to_json
|
111
|
+
)
|
112
|
+
OAuth2.apply(config, _request)
|
113
|
+
_response = execute_request(_request)
|
114
|
+
|
115
|
+
# Return appropriate response type.
|
116
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
117
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
118
|
+
ApiResponse.new(
|
119
|
+
_response, data: decoded, errors: _errors
|
120
|
+
)
|
121
|
+
end
|
122
|
+
|
123
|
+
# Deprecated version of
|
124
|
+
# [BatchRetrieveInventoryChanges]($e/Inventory/BatchRetrieveInventoryChanges
|
125
|
+
# ) after the endpoint URL
|
126
|
+
# is updated to conform to the standard convention.
|
127
|
+
# @param [BatchRetrieveInventoryChangesRequest] body Required parameter: An
|
128
|
+
# object containing the fields to POST for the request. See the
|
129
|
+
# corresponding object definition for field details.
|
130
|
+
# @return [BatchRetrieveInventoryChangesResponse Hash] response from the API call
|
131
|
+
def deprecated_batch_retrieve_inventory_changes(body:)
|
132
|
+
warn 'Endpoint deprecated_batch_retrieve_inventory_changes in InventoryA'\
|
133
|
+
'pi is deprecated'
|
134
|
+
# Prepare query url.
|
135
|
+
_query_builder = config.get_base_uri
|
136
|
+
_query_builder << '/v2/inventory/batch-retrieve-changes'
|
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.post(
|
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(
|
158
|
+
_response, data: decoded, errors: _errors
|
159
|
+
)
|
160
|
+
end
|
161
|
+
|
162
|
+
# Deprecated version of
|
163
|
+
# [BatchRetrieveInventoryCounts]($e/Inventory/BatchRetrieveInventoryCounts)
|
164
|
+
# after the endpoint URL
|
165
|
+
# is updated to conform to the standard convention.
|
166
|
+
# @param [BatchRetrieveInventoryCountsRequest] body Required parameter: An
|
167
|
+
# object containing the fields to POST for the request. See the
|
168
|
+
# corresponding object definition for field details.
|
169
|
+
# @return [BatchRetrieveInventoryCountsResponse Hash] response from the API call
|
170
|
+
def deprecated_batch_retrieve_inventory_counts(body:)
|
171
|
+
warn 'Endpoint deprecated_batch_retrieve_inventory_counts in InventoryAp'\
|
172
|
+
'i is deprecated'
|
173
|
+
# Prepare query url.
|
174
|
+
_query_builder = config.get_base_uri
|
175
|
+
_query_builder << '/v2/inventory/batch-retrieve-counts'
|
176
|
+
_query_url = APIHelper.clean_url _query_builder
|
177
|
+
|
178
|
+
# Prepare headers.
|
179
|
+
_headers = {
|
180
|
+
'accept' => 'application/json',
|
181
|
+
'content-type' => 'application/json; charset=utf-8'
|
182
|
+
}
|
183
|
+
|
184
|
+
# Prepare and execute HttpRequest.
|
185
|
+
_request = config.http_client.post(
|
186
|
+
_query_url,
|
187
|
+
headers: _headers,
|
188
|
+
parameters: body.to_json
|
189
|
+
)
|
190
|
+
OAuth2.apply(config, _request)
|
191
|
+
_response = execute_request(_request)
|
192
|
+
|
193
|
+
# Return appropriate response type.
|
194
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
195
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
196
|
+
ApiResponse.new(
|
197
|
+
_response, data: decoded, errors: _errors
|
198
|
+
)
|
199
|
+
end
|
200
|
+
|
44
201
|
# Applies adjustments and counts to the provided item quantities.
|
45
202
|
# On success: returns the current calculated counts for all objects
|
46
203
|
# referenced in the request.
|
@@ -52,7 +209,7 @@ module Square
|
|
52
209
|
def batch_change_inventory(body:)
|
53
210
|
# Prepare query url.
|
54
211
|
_query_builder = config.get_base_uri
|
55
|
-
_query_builder << '/v2/inventory/batch-
|
212
|
+
_query_builder << '/v2/inventory/changes/batch-create'
|
56
213
|
_query_url = APIHelper.clean_url _query_builder
|
57
214
|
|
58
215
|
# Prepare headers.
|
@@ -91,7 +248,7 @@ module Square
|
|
91
248
|
def batch_retrieve_inventory_changes(body:)
|
92
249
|
# Prepare query url.
|
93
250
|
_query_builder = config.get_base_uri
|
94
|
-
_query_builder << '/v2/inventory/batch-retrieve
|
251
|
+
_query_builder << '/v2/inventory/changes/batch-retrieve'
|
95
252
|
_query_url = APIHelper.clean_url _query_builder
|
96
253
|
|
97
254
|
# Prepare headers.
|
@@ -134,7 +291,7 @@ module Square
|
|
134
291
|
def batch_retrieve_inventory_counts(body:)
|
135
292
|
# Prepare query url.
|
136
293
|
_query_builder = config.get_base_uri
|
137
|
-
_query_builder << '/v2/inventory/batch-retrieve
|
294
|
+
_query_builder << '/v2/inventory/counts/batch-retrieve'
|
138
295
|
_query_url = APIHelper.clean_url _query_builder
|
139
296
|
|
140
297
|
# Prepare headers.
|
@@ -160,6 +317,46 @@ module Square
|
|
160
317
|
)
|
161
318
|
end
|
162
319
|
|
320
|
+
# Deprecated version of
|
321
|
+
# [RetrieveInventoryPhysicalCount]($e/Inventory/RetrieveInventoryPhysicalCou
|
322
|
+
# nt) after the endpoint URL
|
323
|
+
# is updated to conform to the standard convention.
|
324
|
+
# @param [String] physical_count_id Required parameter: ID of the
|
325
|
+
# [InventoryPhysicalCount]($m/InventoryPhysicalCount) to retrieve.
|
326
|
+
# @return [RetrieveInventoryPhysicalCountResponse Hash] response from the API call
|
327
|
+
def deprecated_retrieve_inventory_physical_count(physical_count_id:)
|
328
|
+
warn 'Endpoint deprecated_retrieve_inventory_physical_count in Inventory'\
|
329
|
+
'Api is deprecated'
|
330
|
+
# Prepare query url.
|
331
|
+
_query_builder = config.get_base_uri
|
332
|
+
_query_builder << '/v2/inventory/physical-count/{physical_count_id}'
|
333
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
334
|
+
_query_builder,
|
335
|
+
'physical_count_id' => { 'value' => physical_count_id, 'encode' => true }
|
336
|
+
)
|
337
|
+
_query_url = APIHelper.clean_url _query_builder
|
338
|
+
|
339
|
+
# Prepare headers.
|
340
|
+
_headers = {
|
341
|
+
'accept' => 'application/json'
|
342
|
+
}
|
343
|
+
|
344
|
+
# Prepare and execute HttpRequest.
|
345
|
+
_request = config.http_client.get(
|
346
|
+
_query_url,
|
347
|
+
headers: _headers
|
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(
|
356
|
+
_response, data: decoded, errors: _errors
|
357
|
+
)
|
358
|
+
end
|
359
|
+
|
163
360
|
# Returns the [InventoryPhysicalCount]($m/InventoryPhysicalCount)
|
164
361
|
# object with the provided `physical_count_id`.
|
165
362
|
# @param [String] physical_count_id Required parameter: ID of the
|
@@ -168,7 +365,7 @@ module Square
|
|
168
365
|
def retrieve_inventory_physical_count(physical_count_id:)
|
169
366
|
# Prepare query url.
|
170
367
|
_query_builder = config.get_base_uri
|
171
|
-
_query_builder << '/v2/inventory/physical-
|
368
|
+
_query_builder << '/v2/inventory/physical-counts/{physical_count_id}'
|
172
369
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
173
370
|
_query_builder,
|
174
371
|
'physical_count_id' => { 'value' => physical_count_id, 'encode' => true }
|
@@ -196,6 +393,42 @@ module Square
|
|
196
393
|
)
|
197
394
|
end
|
198
395
|
|
396
|
+
# Returns the [InventoryTransfer]($m/InventoryTransfer) object
|
397
|
+
# with the provided `transfer_id`.
|
398
|
+
# @param [String] transfer_id Required parameter: ID of the
|
399
|
+
# [InventoryTransfer]($m/InventoryTransfer) to retrieve.
|
400
|
+
# @return [RetrieveInventoryTransferResponse Hash] response from the API call
|
401
|
+
def retrieve_inventory_transfer(transfer_id:)
|
402
|
+
# Prepare query url.
|
403
|
+
_query_builder = config.get_base_uri
|
404
|
+
_query_builder << '/v2/inventory/transfers/{transfer_id}'
|
405
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
406
|
+
_query_builder,
|
407
|
+
'transfer_id' => { 'value' => transfer_id, 'encode' => true }
|
408
|
+
)
|
409
|
+
_query_url = APIHelper.clean_url _query_builder
|
410
|
+
|
411
|
+
# Prepare headers.
|
412
|
+
_headers = {
|
413
|
+
'accept' => 'application/json'
|
414
|
+
}
|
415
|
+
|
416
|
+
# Prepare and execute HttpRequest.
|
417
|
+
_request = config.http_client.get(
|
418
|
+
_query_url,
|
419
|
+
headers: _headers
|
420
|
+
)
|
421
|
+
OAuth2.apply(config, _request)
|
422
|
+
_response = execute_request(_request)
|
423
|
+
|
424
|
+
# Return appropriate response type.
|
425
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
426
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
427
|
+
ApiResponse.new(
|
428
|
+
_response, data: decoded, errors: _errors
|
429
|
+
)
|
430
|
+
end
|
431
|
+
|
199
432
|
# Retrieves the current calculated stock count for a given
|
200
433
|
# [CatalogObject]($m/CatalogObject) at a given set of
|
201
434
|
# [Location]($m/Location)s. Responses are paginated and unsorted.
|
@@ -252,6 +485,11 @@ module Square
|
|
252
485
|
# Returns a set of physical counts and inventory adjustments for the
|
253
486
|
# provided [CatalogObject]($m/CatalogObject) at the requested
|
254
487
|
# [Location]($m/Location)s.
|
488
|
+
# You can achieve the same result by calling
|
489
|
+
# [BatchRetrieveInventoryChanges]($e/Inventory/BatchRetrieveInventoryChanges
|
490
|
+
# )
|
491
|
+
# and having the `catalog_object_ids` list contain a single element of the
|
492
|
+
# `CatalogObject` ID.
|
255
493
|
# Results are paginated and sorted in descending order according to their
|
256
494
|
# `occurred_at` timestamp (newest first).
|
257
495
|
# There are no limits on how far back the caller can page. This endpoint can
|
@@ -272,6 +510,7 @@ module Square
|
|
272
510
|
def retrieve_inventory_changes(catalog_object_id:,
|
273
511
|
location_ids: nil,
|
274
512
|
cursor: nil)
|
513
|
+
warn 'Endpoint retrieve_inventory_changes in InventoryApi is deprecated'
|
275
514
|
# Prepare query url.
|
276
515
|
_query_builder = config.get_base_uri
|
277
516
|
_query_builder << '/v2/inventory/{catalog_object_id}/changes'
|