Class: Square::InventoryApi

Inherits:
BaseApi
  • Object
show all
Defined in:
lib/square/api/inventory_api.rb

Overview

InventoryApi

Instance Attribute Summary

Attributes inherited from BaseApi

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseApi

#initialize, #new_api_call_builder, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters

Constructor Details

This class inherits a constructor from Square::BaseApi

Instance Method Details

#batch_change_inventory(body:) ⇒ BatchChangeInventoryResponse Hash

Applies adjustments and counts to the provided item quantities. On success: returns the current calculated counts for all objects referenced in the request. On failure: returns a list of related errors. containing the fields to POST for the request. See the corresponding object definition for field details.

Parameters:

  • body (BatchChangeInventoryRequest)

    Required parameter: An object

Returns:

  • (BatchChangeInventoryResponse Hash)

    response from the API call



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/square/api/inventory_api.rb', line 139

def batch_change_inventory(body:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v2/inventory/changes/batch-create',
                                 'default')
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end

#batch_retrieve_inventory_changes(body:) ⇒ BatchRetrieveInventoryChangesResponse Hash

Returns historical physical counts and adjustments based on the provided filter criteria. Results are paginated and sorted in ascending order according their ‘occurred_at` timestamp (oldest first). BatchRetrieveInventoryChanges is a catch-all query endpoint for queries that cannot be handled by other, simpler endpoints. object containing the fields to POST for the request. See the corresponding object definition for field details.

Parameters:

  • body (BatchRetrieveInventoryChangesRequest)

    Required parameter: An

Returns:

  • (BatchRetrieveInventoryChangesResponse Hash)

    response from the API call



166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/square/api/inventory_api.rb', line 166

def batch_retrieve_inventory_changes(body:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v2/inventory/changes/batch-retrieve',
                                 'default')
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end

#batch_retrieve_inventory_counts(body:) ⇒ BatchRetrieveInventoryCountsResponse Hash

Returns current counts for the provided [CatalogObject]($m/CatalogObject)s at the requested [Location]($m/Location)s. Results are paginated and sorted in descending order according to their ‘calculated_at` timestamp (newest first). When `updated_after` is specified, only counts that have changed since that time (based on the server timestamp for the most recent change) are returned. This allows clients to perform a “sync” operation, for example in response to receiving a Webhook notification. object containing the fields to POST for the request. See the corresponding object definition for field details.

Parameters:

  • body (BatchRetrieveInventoryCountsRequest)

    Required parameter: An

Returns:

  • (BatchRetrieveInventoryCountsResponse Hash)

    response from the API call



197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# File 'lib/square/api/inventory_api.rb', line 197

def batch_retrieve_inventory_counts(body:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v2/inventory/counts/batch-retrieve',
                                 'default')
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end

#deprecated_batch_change_inventory(body:) ⇒ BatchChangeInventoryResponse Hash

Deprecated version of [BatchChangeInventory](api-endpoint:Inventory-BatchChangeInventory) after the endpoint URL is updated to conform to the standard convention. containing the fields to POST for the request. See the corresponding object definition for field details.

Parameters:

  • body (BatchChangeInventoryRequest)

    Required parameter: An object

Returns:

  • (BatchChangeInventoryResponse Hash)

    response from the API call



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/square/api/inventory_api.rb', line 58

def deprecated_batch_change_inventory(body:)
  warn 'Endpoint deprecated_batch_change_inventory in InventoryApi is depr'\
       'ecated'
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v2/inventory/batch-change',
                                 'default')
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end

#deprecated_batch_retrieve_inventory_changes(body:) ⇒ BatchRetrieveInventoryChangesResponse Hash

Deprecated version of [BatchRetrieveInventoryChanges](api-endpoint:Inventory-BatchRetrieveInvent oryChanges) after the endpoint URL is updated to conform to the standard convention. object containing the fields to POST for the request. See the corresponding object definition for field details.

Parameters:

  • body (BatchRetrieveInventoryChangesRequest)

    Required parameter: An

Returns:

  • (BatchRetrieveInventoryChangesResponse Hash)

    response from the API call



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/square/api/inventory_api.rb', line 85

def deprecated_batch_retrieve_inventory_changes(body:)
  warn 'Endpoint deprecated_batch_retrieve_inventory_changes in InventoryA'\
       'pi is deprecated'
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v2/inventory/batch-retrieve-changes',
                                 'default')
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end

#deprecated_batch_retrieve_inventory_counts(body:) ⇒ BatchRetrieveInventoryCountsResponse Hash

Deprecated version of [BatchRetrieveInventoryCounts](api-endpoint:Inventory-BatchRetrieveInvento ryCounts) after the endpoint URL is updated to conform to the standard convention. object containing the fields to POST for the request. See the corresponding object definition for field details.

Parameters:

  • body (BatchRetrieveInventoryCountsRequest)

    Required parameter: An

Returns:

  • (BatchRetrieveInventoryCountsResponse Hash)

    response from the API call



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/square/api/inventory_api.rb', line 112

def deprecated_batch_retrieve_inventory_counts(body:)
  warn 'Endpoint deprecated_batch_retrieve_inventory_counts in InventoryAp'\
       'i is deprecated'
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v2/inventory/batch-retrieve-counts',
                                 'default')
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end

#deprecated_retrieve_inventory_adjustment(adjustment_id:) ⇒ RetrieveInventoryAdjustmentResponse Hash

Deprecated version of [RetrieveInventoryAdjustment](api-endpoint:Inventory-RetrieveInventoryAdju stment) after the endpoint URL is updated to conform to the standard convention. [InventoryAdjustment](entity:InventoryAdjustment) to retrieve.

Parameters:

  • adjustment_id (String)

    Required parameter: ID of the

Returns:

  • (RetrieveInventoryAdjustmentResponse Hash)

    response from the API call



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/square/api/inventory_api.rb', line 11

def deprecated_retrieve_inventory_adjustment(adjustment_id:)
  warn 'Endpoint deprecated_retrieve_inventory_adjustment in InventoryApi '\
       'is deprecated'
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/inventory/adjustment/{adjustment_id}',
                                 'default')
               .template_param(new_parameter(adjustment_id, key: 'adjustment_id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end

#deprecated_retrieve_inventory_physical_count(physical_count_id:) ⇒ RetrieveInventoryPhysicalCountResponse Hash

Deprecated version of [RetrieveInventoryPhysicalCount](api-endpoint:Inventory-RetrieveInventoryP hysicalCount) after the endpoint URL is updated to conform to the standard convention. [InventoryPhysicalCount](entity:InventoryPhysicalCount) to retrieve.

Parameters:

  • physical_count_id (String)

    Required parameter: ID of the

Returns:

  • (RetrieveInventoryPhysicalCountResponse Hash)

    response from the API call



221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# File 'lib/square/api/inventory_api.rb', line 221

def deprecated_retrieve_inventory_physical_count(physical_count_id:)
  warn 'Endpoint deprecated_retrieve_inventory_physical_count in Inventory'\
       'Api is deprecated'
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/inventory/physical-count/{physical_count_id}',
                                 'default')
               .template_param(new_parameter(physical_count_id, key: 'physical_count_id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end

#retrieve_inventory_adjustment(adjustment_id:) ⇒ RetrieveInventoryAdjustmentResponse Hash

Returns the [InventoryAdjustment]($m/InventoryAdjustment) object with the provided ‘adjustment_id`. [InventoryAdjustment](entity:InventoryAdjustment) to retrieve.

Parameters:

  • adjustment_id (String)

    Required parameter: ID of the

Returns:

  • (RetrieveInventoryAdjustmentResponse Hash)

    response from the API call



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/square/api/inventory_api.rb', line 34

def retrieve_inventory_adjustment(adjustment_id:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/inventory/adjustments/{adjustment_id}',
                                 'default')
               .template_param(new_parameter(adjustment_id, key: 'adjustment_id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end

#retrieve_inventory_changes(catalog_object_id:, location_ids: nil, cursor: nil) ⇒ RetrieveInventoryChangesResponse Hash

Returns a set of physical counts and inventory adjustments for the provided [CatalogObject](entity:CatalogObject) at the requested [Location](entity:Location)s. You can achieve the same result by calling [BatchRetrieveInventoryChanges](api-endpoint:Inventory-BatchRetrieveInvent oryChanges) and having the ‘catalog_object_ids` list contain a single element of the `CatalogObject` ID. Results are paginated and sorted in descending order according to their `occurred_at` timestamp (newest first). There are no limits on how far back the caller can page. This endpoint can be used to display recent changes for a specific item. For more sophisticated queries, use a batch endpoint. [CatalogObject](entity:CatalogObject) to retrieve. [Location](entity:Location) IDs to look up as a comma-separated list. An empty list queries all locations. a previous call to this endpoint. Provide this to retrieve the next set of results for the original query. See the [Pagination](developer.squareup.com/docs/working-with-apis/paginat ion) guide for more information.

Parameters:

  • catalog_object_id (String)

    Required parameter: ID of the

  • location_ids (String) (defaults to: nil)

    Optional parameter: The

  • cursor (String) (defaults to: nil)

    Optional parameter: A pagination cursor returned by

Returns:

  • (RetrieveInventoryChangesResponse Hash)

    response from the API call



341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
# File 'lib/square/api/inventory_api.rb', line 341

def retrieve_inventory_changes(catalog_object_id:,
                               location_ids: nil,
                               cursor: nil)
  warn 'Endpoint retrieve_inventory_changes in InventoryApi is deprecated'
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/inventory/{catalog_object_id}/changes',
                                 'default')
               .template_param(new_parameter(catalog_object_id, key: 'catalog_object_id')
                                .should_encode(true))
               .query_param(new_parameter(location_ids, key: 'location_ids'))
               .query_param(new_parameter(cursor, key: 'cursor'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end

#retrieve_inventory_count(catalog_object_id:, location_ids: nil, cursor: nil) ⇒ RetrieveInventoryCountResponse Hash

Retrieves the current calculated stock count for a given [CatalogObject]($m/CatalogObject) at a given set of [Location]($m/Location)s. Responses are paginated and unsorted. For more sophisticated queries, use a batch endpoint. [CatalogObject](entity:CatalogObject) to retrieve. [Location](entity:Location) IDs to look up as a comma-separated list. An empty list queries all locations. a previous call to this endpoint. Provide this to retrieve the next set of results for the original query. See the [Pagination](developer.squareup.com/docs/working-with-apis/paginat ion) guide for more information.

Parameters:

  • catalog_object_id (String)

    Required parameter: ID of the

  • location_ids (String) (defaults to: nil)

    Optional parameter: The

  • cursor (String) (defaults to: nil)

    Optional parameter: A pagination cursor returned by

Returns:

  • (RetrieveInventoryCountResponse Hash)

    response from the API call



296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
# File 'lib/square/api/inventory_api.rb', line 296

def retrieve_inventory_count(catalog_object_id:,
                             location_ids: nil,
                             cursor: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/inventory/{catalog_object_id}',
                                 'default')
               .template_param(new_parameter(catalog_object_id, key: 'catalog_object_id')
                                .should_encode(true))
               .query_param(new_parameter(location_ids, key: 'location_ids'))
               .query_param(new_parameter(cursor, key: 'cursor'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end

#retrieve_inventory_physical_count(physical_count_id:) ⇒ RetrieveInventoryPhysicalCountResponse Hash

Returns the [InventoryPhysicalCount]($m/InventoryPhysicalCount) object with the provided ‘physical_count_id`. [InventoryPhysicalCount](entity:InventoryPhysicalCount) to retrieve.

Parameters:

  • physical_count_id (String)

    Required parameter: ID of the

Returns:

  • (RetrieveInventoryPhysicalCountResponse Hash)

    response from the API call



244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
# File 'lib/square/api/inventory_api.rb', line 244

def retrieve_inventory_physical_count(physical_count_id:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/inventory/physical-counts/{physical_count_id}',
                                 'default')
               .template_param(new_parameter(physical_count_id, key: 'physical_count_id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end

#retrieve_inventory_transfer(transfer_id:) ⇒ RetrieveInventoryTransferResponse Hash

Returns the [InventoryTransfer]($m/InventoryTransfer) object with the provided ‘transfer_id`. [InventoryTransfer](entity:InventoryTransfer) to retrieve.

Parameters:

  • transfer_id (String)

    Required parameter: ID of the

Returns:

  • (RetrieveInventoryTransferResponse Hash)

    response from the API call



265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
# File 'lib/square/api/inventory_api.rb', line 265

def retrieve_inventory_transfer(transfer_id:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/inventory/transfers/{transfer_id}',
                                 'default')
               .template_param(new_parameter(transfer_id, key: 'transfer_id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end