Class: OpenapiClient::ShipmentsApi

Inherits:
Object
  • Object
show all
Defined in:
lib/openapi_client/api/shipments_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ ShipmentsApi

Returns a new instance of ShipmentsApi.



19
20
21
# File 'lib/openapi_client/api/shipments_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/openapi_client/api/shipments_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#cancel_shipments(shipment_id, opts = {}) ⇒ String

Cancel a Shipment Mark a shipment cancelled, if it is no longer needed or being used by your organized. Any label associated with the shipment needs to be voided first An example use case would be if a batch label creation job is going to run at a set time and only queries ‘pending` shipments. Marking a shipment as cancelled would remove it from this process

Parameters:

  • shipment_id (String)

    Shipment ID

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (String)


27
28
29
30
# File 'lib/openapi_client/api/shipments_api.rb', line 27

def cancel_shipments(shipment_id, opts = {})
  data, _status_code, _headers = cancel_shipments_with_http_info(shipment_id, opts)
  data
end

#cancel_shipments_with_http_info(shipment_id, opts = {}) ⇒ Array<(String, Integer, Hash)>

Cancel a Shipment Mark a shipment cancelled, if it is no longer needed or being used by your organized. Any label associated with the shipment needs to be voided first An example use case would be if a batch label creation job is going to run at a set time and only queries &#x60;pending&#x60; shipments. Marking a shipment as cancelled would remove it from this process

Parameters:

  • shipment_id (String)

    Shipment ID

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(String, Integer, Hash)>)

    String data, response status code and response headers



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/openapi_client/api/shipments_api.rb', line 37

def cancel_shipments_with_http_info(shipment_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ShipmentsApi.cancel_shipments ...'
  end
  # verify the required parameter 'shipment_id' is set
  if @api_client.config.client_side_validation && shipment_id.nil?
    fail ArgumentError, "Missing the required parameter 'shipment_id' when calling ShipmentsApi.cancel_shipments"
  end
  if @api_client.config.client_side_validation && shipment_id.to_s.length > 25
    fail ArgumentError, 'invalid value for "shipment_id" when calling ShipmentsApi.cancel_shipments, the character length must be smaller than or equal to 25.'
  end

  if @api_client.config.client_side_validation && shipment_id.to_s.length < 1
    fail ArgumentError, 'invalid value for "shipment_id" when calling ShipmentsApi.cancel_shipments, the character length must be great than or equal to 1.'
  end

  pattern = Regexp.new(/^se(-[a-z0-9]+)+$/)
  if @api_client.config.client_side_validation && shipment_id !~ pattern
    fail ArgumentError, "invalid value for 'shipment_id' when calling ShipmentsApi.cancel_shipments, must conform to the pattern #{pattern}."
  end

  # resource path
  local_var_path = '/v1/shipments/{shipment_id}/cancel'.sub('{' + 'shipment_id' + '}', CGI.escape(shipment_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['text/plain', 'application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:body] 

  # return_type
  return_type = opts[:return_type] || 'String' 

  # auth_names
  auth_names = opts[:auth_names] || ['api_key']

  new_options = opts.merge(
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ShipmentsApi#cancel_shipments\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#create_shipments(create_shipments_request_body, opts = {}) ⇒ CreateShipmentsResponseBody

Create Shipments Create one or multiple shipments.

Parameters:

Returns:



102
103
104
105
# File 'lib/openapi_client/api/shipments_api.rb', line 102

def create_shipments(create_shipments_request_body, opts = {})
  data, _status_code, _headers = create_shipments_with_http_info(create_shipments_request_body, opts)
  data
end

#create_shipments_with_http_info(create_shipments_request_body, opts = {}) ⇒ Array<(CreateShipmentsResponseBody, Integer, Hash)>

Create Shipments Create one or multiple shipments.

Parameters:

Returns:

  • (Array<(CreateShipmentsResponseBody, Integer, Hash)>)

    CreateShipmentsResponseBody data, response status code and response headers



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/openapi_client/api/shipments_api.rb', line 112

def create_shipments_with_http_info(create_shipments_request_body, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ShipmentsApi.create_shipments ...'
  end
  # verify the required parameter 'create_shipments_request_body' is set
  if @api_client.config.client_side_validation && create_shipments_request_body.nil?
    fail ArgumentError, "Missing the required parameter 'create_shipments_request_body' when calling ShipmentsApi.create_shipments"
  end
  # resource path
  local_var_path = '/v1/shipments'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:body] || @api_client.object_to_http_body(create_shipments_request_body) 

  # return_type
  return_type = opts[:return_type] || 'CreateShipmentsResponseBody' 

  # auth_names
  auth_names = opts[:auth_names] || ['api_key']

  new_options = opts.merge(
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ShipmentsApi#create_shipments\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_shipment_by_external_id(external_shipment_id, opts = {}) ⇒ GetShipmentByExternalIdResponseBody

Get Shipment By External ID Query Shipments created using your own custom ID convention using this endpint

Parameters:

  • external_shipment_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



166
167
168
169
# File 'lib/openapi_client/api/shipments_api.rb', line 166

def get_shipment_by_external_id(external_shipment_id, opts = {})
  data, _status_code, _headers = get_shipment_by_external_id_with_http_info(external_shipment_id, opts)
  data
end

#get_shipment_by_external_id_with_http_info(external_shipment_id, opts = {}) ⇒ Array<(GetShipmentByExternalIdResponseBody, Integer, Hash)>

Get Shipment By External ID Query Shipments created using your own custom ID convention using this endpint

Parameters:

  • external_shipment_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
# File 'lib/openapi_client/api/shipments_api.rb', line 176

def get_shipment_by_external_id_with_http_info(external_shipment_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ShipmentsApi.get_shipment_by_external_id ...'
  end
  # verify the required parameter 'external_shipment_id' is set
  if @api_client.config.client_side_validation && external_shipment_id.nil?
    fail ArgumentError, "Missing the required parameter 'external_shipment_id' when calling ShipmentsApi.get_shipment_by_external_id"
  end
  # resource path
  local_var_path = '/v1/shipments/external_shipment_id/{external_shipment_id}'.sub('{' + 'external_shipment_id' + '}', CGI.escape(external_shipment_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:body] 

  # return_type
  return_type = opts[:return_type] || 'GetShipmentByExternalIdResponseBody' 

  # auth_names
  auth_names = opts[:auth_names] || ['api_key']

  new_options = opts.merge(
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ShipmentsApi#get_shipment_by_external_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_shipment_by_id(shipment_id, opts = {}) ⇒ GetShipmentByIdResponseBody

Get Shipment By ID Get an individual shipment based on its ID

Parameters:

  • shipment_id (String)

    Shipment ID

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



228
229
230
231
# File 'lib/openapi_client/api/shipments_api.rb', line 228

def get_shipment_by_id(shipment_id, opts = {})
  data, _status_code, _headers = get_shipment_by_id_with_http_info(shipment_id, opts)
  data
end

#get_shipment_by_id_with_http_info(shipment_id, opts = {}) ⇒ Array<(GetShipmentByIdResponseBody, Integer, Hash)>

Get Shipment By ID Get an individual shipment based on its ID

Parameters:

  • shipment_id (String)

    Shipment ID

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(GetShipmentByIdResponseBody, Integer, Hash)>)

    GetShipmentByIdResponseBody data, response status code and response headers



238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
# File 'lib/openapi_client/api/shipments_api.rb', line 238

def get_shipment_by_id_with_http_info(shipment_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ShipmentsApi.get_shipment_by_id ...'
  end
  # verify the required parameter 'shipment_id' is set
  if @api_client.config.client_side_validation && shipment_id.nil?
    fail ArgumentError, "Missing the required parameter 'shipment_id' when calling ShipmentsApi.get_shipment_by_id"
  end
  if @api_client.config.client_side_validation && shipment_id.to_s.length > 25
    fail ArgumentError, 'invalid value for "shipment_id" when calling ShipmentsApi.get_shipment_by_id, the character length must be smaller than or equal to 25.'
  end

  if @api_client.config.client_side_validation && shipment_id.to_s.length < 1
    fail ArgumentError, 'invalid value for "shipment_id" when calling ShipmentsApi.get_shipment_by_id, the character length must be great than or equal to 1.'
  end

  pattern = Regexp.new(/^se(-[a-z0-9]+)+$/)
  if @api_client.config.client_side_validation && shipment_id !~ pattern
    fail ArgumentError, "invalid value for 'shipment_id' when calling ShipmentsApi.get_shipment_by_id, must conform to the pattern #{pattern}."
  end

  # resource path
  local_var_path = '/v1/shipments/{shipment_id}'.sub('{' + 'shipment_id' + '}', CGI.escape(shipment_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:body] 

  # return_type
  return_type = opts[:return_type] || 'GetShipmentByIdResponseBody' 

  # auth_names
  auth_names = opts[:auth_names] || ['api_key']

  new_options = opts.merge(
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ShipmentsApi#get_shipment_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_shipment_errors(shipment_id, opts = {}) ⇒ ListShipmentErrorsResponseBody

Get Shipment Errors If there are no errors associated with this shipment then the API will return a 404 Not Found response to indicate that no errors are associated with the request

Parameters:

  • shipment_id (String)

    Shipment ID

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :page (Integer)

    Return a specific page of results. Defaults to the first page. If set to a number that&#39;s greater than the number of pages of results, an empty page is returned. (default to 1)

  • :pagesize (Integer)

Returns:



305
306
307
308
# File 'lib/openapi_client/api/shipments_api.rb', line 305

def list_shipment_errors(shipment_id, opts = {})
  data, _status_code, _headers = list_shipment_errors_with_http_info(shipment_id, opts)
  data
end

#list_shipment_errors_with_http_info(shipment_id, opts = {}) ⇒ Array<(ListShipmentErrorsResponseBody, Integer, Hash)>

Get Shipment Errors If there are no errors associated with this shipment then the API will return a 404 Not Found response to indicate that no errors are associated with the request

Parameters:

  • shipment_id (String)

    Shipment ID

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :page (Integer)

    Return a specific page of results. Defaults to the first page. If set to a number that&#39;s greater than the number of pages of results, an empty page is returned.

  • :pagesize (Integer)

Returns:



317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
# File 'lib/openapi_client/api/shipments_api.rb', line 317

def list_shipment_errors_with_http_info(shipment_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ShipmentsApi.list_shipment_errors ...'
  end
  # verify the required parameter 'shipment_id' is set
  if @api_client.config.client_side_validation && shipment_id.nil?
    fail ArgumentError, "Missing the required parameter 'shipment_id' when calling ShipmentsApi.list_shipment_errors"
  end
  if @api_client.config.client_side_validation && shipment_id.to_s.length > 25
    fail ArgumentError, 'invalid value for "shipment_id" when calling ShipmentsApi.list_shipment_errors, the character length must be smaller than or equal to 25.'
  end

  if @api_client.config.client_side_validation && shipment_id.to_s.length < 1
    fail ArgumentError, 'invalid value for "shipment_id" when calling ShipmentsApi.list_shipment_errors, the character length must be great than or equal to 1.'
  end

  pattern = Regexp.new(/^se(-[a-z0-9]+)+$/)
  if @api_client.config.client_side_validation && shipment_id !~ pattern
    fail ArgumentError, "invalid value for 'shipment_id' when calling ShipmentsApi.list_shipment_errors, must conform to the pattern #{pattern}."
  end

  if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] < 1
    fail ArgumentError, 'invalid value for "opts[:"page"]" when calling ShipmentsApi.list_shipment_errors, must be greater than or equal to 1.'
  end

  if @api_client.config.client_side_validation && !opts[:'pagesize'].nil? && opts[:'pagesize'] < 1
    fail ArgumentError, 'invalid value for "opts[:"pagesize"]" when calling ShipmentsApi.list_shipment_errors, must be greater than or equal to 1.'
  end

  # resource path
  local_var_path = '/v1/shipments/{shipment_id}/errors'.sub('{' + 'shipment_id' + '}', CGI.escape(shipment_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
  query_params[:'pagesize'] = opts[:'pagesize'] if !opts[:'pagesize'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:body] 

  # return_type
  return_type = opts[:return_type] || 'ListShipmentErrorsResponseBody' 

  # auth_names
  auth_names = opts[:auth_names] || ['api_key']

  new_options = opts.merge(
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ShipmentsApi#list_shipment_errors\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_shipment_rates(shipment_id, opts = {}) ⇒ ListShipmentRatesResponseBody

Get Shipment Rates Get Rates for the shipment information associated with the shipment ID

Parameters:

  • shipment_id (String)

    Shipment ID

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :created_at_start (DateTime)

    Used to create a filter for when a resource was created (ex. A shipment that was created after a certain time)

Returns:



393
394
395
396
# File 'lib/openapi_client/api/shipments_api.rb', line 393

def list_shipment_rates(shipment_id, opts = {})
  data, _status_code, _headers = list_shipment_rates_with_http_info(shipment_id, opts)
  data
end

#list_shipment_rates_with_http_info(shipment_id, opts = {}) ⇒ Array<(ListShipmentRatesResponseBody, Integer, Hash)>

Get Shipment Rates Get Rates for the shipment information associated with the shipment ID

Parameters:

  • shipment_id (String)

    Shipment ID

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :created_at_start (DateTime)

    Used to create a filter for when a resource was created (ex. A shipment that was created after a certain time)

Returns:



404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
# File 'lib/openapi_client/api/shipments_api.rb', line 404

def list_shipment_rates_with_http_info(shipment_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ShipmentsApi.list_shipment_rates ...'
  end
  # verify the required parameter 'shipment_id' is set
  if @api_client.config.client_side_validation && shipment_id.nil?
    fail ArgumentError, "Missing the required parameter 'shipment_id' when calling ShipmentsApi.list_shipment_rates"
  end
  if @api_client.config.client_side_validation && shipment_id.to_s.length > 25
    fail ArgumentError, 'invalid value for "shipment_id" when calling ShipmentsApi.list_shipment_rates, the character length must be smaller than or equal to 25.'
  end

  if @api_client.config.client_side_validation && shipment_id.to_s.length < 1
    fail ArgumentError, 'invalid value for "shipment_id" when calling ShipmentsApi.list_shipment_rates, the character length must be great than or equal to 1.'
  end

  pattern = Regexp.new(/^se(-[a-z0-9]+)+$/)
  if @api_client.config.client_side_validation && shipment_id !~ pattern
    fail ArgumentError, "invalid value for 'shipment_id' when calling ShipmentsApi.list_shipment_rates, must conform to the pattern #{pattern}."
  end

  # resource path
  local_var_path = '/v1/shipments/{shipment_id}/rates'.sub('{' + 'shipment_id' + '}', CGI.escape(shipment_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'created_at_start'] = opts[:'created_at_start'] if !opts[:'created_at_start'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:body] 

  # return_type
  return_type = opts[:return_type] || 'ListShipmentRatesResponseBody' 

  # auth_names
  auth_names = opts[:auth_names] || ['api_key']

  new_options = opts.merge(
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ShipmentsApi#list_shipment_rates\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_shipments(opts = {}) ⇒ ListShipmentsResponseBody

List Shipments Get list of Shipments

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :shipment_status (ShipmentStatus)
  • :batch_id (String)

    Batch ID

  • :tag (String)

    Search for shipments based on the custom tag added to the shipment object

  • :created_at_start (DateTime)

    Used to create a filter for when a resource was created (ex. A shipment that was created after a certain time)

  • :created_at_end (DateTime)

    Used to create a filter for when a resource was created, (ex. A shipment that was created before a certain time)

  • :modified_at_start (DateTime)

    Used to create a filter for when a resource was modified (ex. A shipment that was modified after a certain time)

  • :modified_at_end (DateTime)

    Used to create a filter for when a resource was modified (ex. A shipment that was modified before a certain time)

  • :page (Integer)

    Return a specific page of results. Defaults to the first page. If set to a number that&#39;s greater than the number of pages of results, an empty page is returned. (default to 1)

  • :page_size (Integer)

    The number of results to return per response. (default to 25)

  • :sales_order_id (String)

    Sales Order ID

  • :sort_dir (SortDir)

    Controls the sort order of the query.

  • :sort_by (ShipmentsSortBy)

Returns:



481
482
483
484
# File 'lib/openapi_client/api/shipments_api.rb', line 481

def list_shipments(opts = {})
  data, _status_code, _headers = list_shipments_with_http_info(opts)
  data
end

#list_shipments_with_http_info(opts = {}) ⇒ Array<(ListShipmentsResponseBody, Integer, Hash)>

List Shipments Get list of Shipments

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :shipment_status (ShipmentStatus)
  • :batch_id (String)

    Batch ID

  • :tag (String)

    Search for shipments based on the custom tag added to the shipment object

  • :created_at_start (DateTime)

    Used to create a filter for when a resource was created (ex. A shipment that was created after a certain time)

  • :created_at_end (DateTime)

    Used to create a filter for when a resource was created, (ex. A shipment that was created before a certain time)

  • :modified_at_start (DateTime)

    Used to create a filter for when a resource was modified (ex. A shipment that was modified after a certain time)

  • :modified_at_end (DateTime)

    Used to create a filter for when a resource was modified (ex. A shipment that was modified before a certain time)

  • :page (Integer)

    Return a specific page of results. Defaults to the first page. If set to a number that&#39;s greater than the number of pages of results, an empty page is returned.

  • :page_size (Integer)

    The number of results to return per response.

  • :sales_order_id (String)

    Sales Order ID

  • :sort_dir (SortDir)

    Controls the sort order of the query.

  • :sort_by (ShipmentsSortBy)

Returns:

  • (Array<(ListShipmentsResponseBody, Integer, Hash)>)

    ListShipmentsResponseBody data, response status code and response headers



502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
# File 'lib/openapi_client/api/shipments_api.rb', line 502

def list_shipments_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ShipmentsApi.list_shipments ...'
  end
  if @api_client.config.client_side_validation && !opts[:'batch_id'].nil? && opts[:'batch_id'].to_s.length > 25
    fail ArgumentError, 'invalid value for "opts[:"batch_id"]" when calling ShipmentsApi.list_shipments, the character length must be smaller than or equal to 25.'
  end

  if @api_client.config.client_side_validation && !opts[:'batch_id'].nil? && opts[:'batch_id'].to_s.length < 1
    fail ArgumentError, 'invalid value for "opts[:"batch_id"]" when calling ShipmentsApi.list_shipments, the character length must be great than or equal to 1.'
  end

  pattern = Regexp.new(/^se(-[a-z0-9]+)+$/)
  if @api_client.config.client_side_validation && !opts[:'batch_id'].nil? && opts[:'batch_id'] !~ pattern
    fail ArgumentError, "invalid value for 'opts[:\"batch_id\"]' when calling ShipmentsApi.list_shipments, must conform to the pattern #{pattern}."
  end

  if @api_client.config.client_side_validation && !opts[:'tag'].nil? && opts[:'tag'].to_s.length < 1
    fail ArgumentError, 'invalid value for "opts[:"tag"]" when calling ShipmentsApi.list_shipments, the character length must be great than or equal to 1.'
  end

  if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] < 1
    fail ArgumentError, 'invalid value for "opts[:"page"]" when calling ShipmentsApi.list_shipments, must be greater than or equal to 1.'
  end

  if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] < 1
    fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling ShipmentsApi.list_shipments, must be greater than or equal to 1.'
  end

  # resource path
  local_var_path = '/v1/shipments'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'shipment_status'] = opts[:'shipment_status'] if !opts[:'shipment_status'].nil?
  query_params[:'batch_id'] = opts[:'batch_id'] if !opts[:'batch_id'].nil?
  query_params[:'tag'] = opts[:'tag'] if !opts[:'tag'].nil?
  query_params[:'created_at_start'] = opts[:'created_at_start'] if !opts[:'created_at_start'].nil?
  query_params[:'created_at_end'] = opts[:'created_at_end'] if !opts[:'created_at_end'].nil?
  query_params[:'modified_at_start'] = opts[:'modified_at_start'] if !opts[:'modified_at_start'].nil?
  query_params[:'modified_at_end'] = opts[:'modified_at_end'] if !opts[:'modified_at_end'].nil?
  query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
  query_params[:'page_size'] = opts[:'page_size'] if !opts[:'page_size'].nil?
  query_params[:'sales_order_id'] = opts[:'sales_order_id'] if !opts[:'sales_order_id'].nil?
  query_params[:'sort_dir'] = opts[:'sort_dir'] if !opts[:'sort_dir'].nil?
  query_params[:'sort_by'] = opts[:'sort_by'] if !opts[:'sort_by'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:body] 

  # return_type
  return_type = opts[:return_type] || 'ListShipmentsResponseBody' 

  # auth_names
  auth_names = opts[:auth_names] || ['api_key']

  new_options = opts.merge(
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ShipmentsApi#list_shipments\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#parse_shipment(parse_shipment_request_body, opts = {}) ⇒ ParseShipmentResponseBody

Parse shipping info The shipment-recognition API makes it easy for you to extract shipping data from unstructured text, including people’s names, addresses, package weights and dimensions, insurance and delivery requirements, and more. Data often enters your system as unstructured text (for example: emails, SMS messages, support tickets, or other documents). ShipEngine’s shipment-recognition API helps you extract meaningful, structured data from this unstructured text. The parsed shipment data is returned in the same structure that’s used for other ShipEngine APIs, so you can easily use the parsed data to create a shipping label. > Note: Shipment recognition is currently supported for the United States, Canada, Australia, New Zealand, the United Kingdom, and Ireland.

Parameters:

  • parse_shipment_request_body (ParseShipmentRequestBody)

    The only required field is &#x60;text&#x60;, which is the text to be parsed. You can optionally also provide a &#x60;shipment&#x60; containing any already-known values. For example, you probably already know the &#x60;ship_from&#x60; address, and you may also already know what carrier and service you want to use.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



587
588
589
590
# File 'lib/openapi_client/api/shipments_api.rb', line 587

def parse_shipment(parse_shipment_request_body, opts = {})
  data, _status_code, _headers = parse_shipment_with_http_info(parse_shipment_request_body, opts)
  data
end

#parse_shipment_with_http_info(parse_shipment_request_body, opts = {}) ⇒ Array<(ParseShipmentResponseBody, Integer, Hash)>

Parse shipping info The shipment-recognition API makes it easy for you to extract shipping data from unstructured text, including people&#39;s names, addresses, package weights and dimensions, insurance and delivery requirements, and more. Data often enters your system as unstructured text (for example: emails, SMS messages, support tickets, or other documents). ShipEngine&#39;s shipment-recognition API helps you extract meaningful, structured data from this unstructured text. The parsed shipment data is returned in the same structure that&#39;s used for other ShipEngine APIs, so you can easily use the parsed data to create a shipping label. &gt; Note: Shipment recognition is currently supported for the United States, Canada, Australia, New Zealand, the United Kingdom, and Ireland.

Parameters:

  • parse_shipment_request_body (ParseShipmentRequestBody)

    The only required field is &#x60;text&#x60;, which is the text to be parsed. You can optionally also provide a &#x60;shipment&#x60; containing any already-known values. For example, you probably already know the &#x60;ship_from&#x60; address, and you may also already know what carrier and service you want to use.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(ParseShipmentResponseBody, Integer, Hash)>)

    ParseShipmentResponseBody data, response status code and response headers



597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
# File 'lib/openapi_client/api/shipments_api.rb', line 597

def parse_shipment_with_http_info(parse_shipment_request_body, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ShipmentsApi.parse_shipment ...'
  end
  # verify the required parameter 'parse_shipment_request_body' is set
  if @api_client.config.client_side_validation && parse_shipment_request_body.nil?
    fail ArgumentError, "Missing the required parameter 'parse_shipment_request_body' when calling ShipmentsApi.parse_shipment"
  end
  # resource path
  local_var_path = '/v1/shipments/recognize'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:body] || @api_client.object_to_http_body(parse_shipment_request_body) 

  # return_type
  return_type = opts[:return_type] || 'ParseShipmentResponseBody' 

  # auth_names
  auth_names = opts[:auth_names] || ['api_key']

  new_options = opts.merge(
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ShipmentsApi#parse_shipment\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#tag_shipment(shipment_id, tag_name, opts = {}) ⇒ TagShipmentResponseBody

Add Tag to Shipment Add a tag to the shipment object

Parameters:

  • shipment_id (String)

    Shipment ID

  • tag_name (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



652
653
654
655
# File 'lib/openapi_client/api/shipments_api.rb', line 652

def tag_shipment(shipment_id, tag_name, opts = {})
  data, _status_code, _headers = tag_shipment_with_http_info(shipment_id, tag_name, opts)
  data
end

#tag_shipment_with_http_info(shipment_id, tag_name, opts = {}) ⇒ Array<(TagShipmentResponseBody, Integer, Hash)>

Add Tag to Shipment Add a tag to the shipment object

Parameters:

  • shipment_id (String)

    Shipment ID

  • tag_name (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(TagShipmentResponseBody, Integer, Hash)>)

    TagShipmentResponseBody data, response status code and response headers



663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
# File 'lib/openapi_client/api/shipments_api.rb', line 663

def tag_shipment_with_http_info(shipment_id, tag_name, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ShipmentsApi.tag_shipment ...'
  end
  # verify the required parameter 'shipment_id' is set
  if @api_client.config.client_side_validation && shipment_id.nil?
    fail ArgumentError, "Missing the required parameter 'shipment_id' when calling ShipmentsApi.tag_shipment"
  end
  if @api_client.config.client_side_validation && shipment_id.to_s.length > 25
    fail ArgumentError, 'invalid value for "shipment_id" when calling ShipmentsApi.tag_shipment, the character length must be smaller than or equal to 25.'
  end

  if @api_client.config.client_side_validation && shipment_id.to_s.length < 1
    fail ArgumentError, 'invalid value for "shipment_id" when calling ShipmentsApi.tag_shipment, the character length must be great than or equal to 1.'
  end

  pattern = Regexp.new(/^se(-[a-z0-9]+)+$/)
  if @api_client.config.client_side_validation && shipment_id !~ pattern
    fail ArgumentError, "invalid value for 'shipment_id' when calling ShipmentsApi.tag_shipment, must conform to the pattern #{pattern}."
  end

  # verify the required parameter 'tag_name' is set
  if @api_client.config.client_side_validation && tag_name.nil?
    fail ArgumentError, "Missing the required parameter 'tag_name' when calling ShipmentsApi.tag_shipment"
  end
  if @api_client.config.client_side_validation && tag_name.to_s.length < 1
    fail ArgumentError, 'invalid value for "tag_name" when calling ShipmentsApi.tag_shipment, the character length must be great than or equal to 1.'
  end

  # resource path
  local_var_path = '/v1/shipments/{shipment_id}/tags/{tag_name}'.sub('{' + 'shipment_id' + '}', CGI.escape(shipment_id.to_s)).sub('{' + 'tag_name' + '}', CGI.escape(tag_name.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:body] 

  # return_type
  return_type = opts[:return_type] || 'TagShipmentResponseBody' 

  # auth_names
  auth_names = opts[:auth_names] || ['api_key']

  new_options = opts.merge(
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ShipmentsApi#tag_shipment\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#untag_shipment(shipment_id, tag_name, opts = {}) ⇒ String

Remove Tag from Shipment Remove an existing tag from the Shipment object

Parameters:

  • shipment_id (String)

    Shipment ID

  • tag_name (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (String)


737
738
739
740
# File 'lib/openapi_client/api/shipments_api.rb', line 737

def untag_shipment(shipment_id, tag_name, opts = {})
  data, _status_code, _headers = untag_shipment_with_http_info(shipment_id, tag_name, opts)
  data
end

#untag_shipment_with_http_info(shipment_id, tag_name, opts = {}) ⇒ Array<(String, Integer, Hash)>

Remove Tag from Shipment Remove an existing tag from the Shipment object

Parameters:

  • shipment_id (String)

    Shipment ID

  • tag_name (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(String, Integer, Hash)>)

    String data, response status code and response headers



748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
# File 'lib/openapi_client/api/shipments_api.rb', line 748

def untag_shipment_with_http_info(shipment_id, tag_name, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ShipmentsApi.untag_shipment ...'
  end
  # verify the required parameter 'shipment_id' is set
  if @api_client.config.client_side_validation && shipment_id.nil?
    fail ArgumentError, "Missing the required parameter 'shipment_id' when calling ShipmentsApi.untag_shipment"
  end
  if @api_client.config.client_side_validation && shipment_id.to_s.length > 25
    fail ArgumentError, 'invalid value for "shipment_id" when calling ShipmentsApi.untag_shipment, the character length must be smaller than or equal to 25.'
  end

  if @api_client.config.client_side_validation && shipment_id.to_s.length < 1
    fail ArgumentError, 'invalid value for "shipment_id" when calling ShipmentsApi.untag_shipment, the character length must be great than or equal to 1.'
  end

  pattern = Regexp.new(/^se(-[a-z0-9]+)+$/)
  if @api_client.config.client_side_validation && shipment_id !~ pattern
    fail ArgumentError, "invalid value for 'shipment_id' when calling ShipmentsApi.untag_shipment, must conform to the pattern #{pattern}."
  end

  # verify the required parameter 'tag_name' is set
  if @api_client.config.client_side_validation && tag_name.nil?
    fail ArgumentError, "Missing the required parameter 'tag_name' when calling ShipmentsApi.untag_shipment"
  end
  if @api_client.config.client_side_validation && tag_name.to_s.length < 1
    fail ArgumentError, 'invalid value for "tag_name" when calling ShipmentsApi.untag_shipment, the character length must be great than or equal to 1.'
  end

  # resource path
  local_var_path = '/v1/shipments/{shipment_id}/tags/{tag_name}'.sub('{' + 'shipment_id' + '}', CGI.escape(shipment_id.to_s)).sub('{' + 'tag_name' + '}', CGI.escape(tag_name.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['text/plain', 'application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:body] 

  # return_type
  return_type = opts[:return_type] || 'String' 

  # auth_names
  auth_names = opts[:auth_names] || ['api_key']

  new_options = opts.merge(
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ShipmentsApi#untag_shipment\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#update_shipment(shipment_id, update_shipment_request_body, opts = {}) ⇒ UpdateShipmentResponseBody

Update Shipment By ID Update a shipment object based on its ID

Parameters:

  • shipment_id (String)

    Shipment ID

  • update_shipment_request_body (UpdateShipmentRequestBody)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



822
823
824
825
# File 'lib/openapi_client/api/shipments_api.rb', line 822

def update_shipment(shipment_id, update_shipment_request_body, opts = {})
  data, _status_code, _headers = update_shipment_with_http_info(shipment_id, update_shipment_request_body, opts)
  data
end

#update_shipment_with_http_info(shipment_id, update_shipment_request_body, opts = {}) ⇒ Array<(UpdateShipmentResponseBody, Integer, Hash)>

Update Shipment By ID Update a shipment object based on its ID

Parameters:

  • shipment_id (String)

    Shipment ID

  • update_shipment_request_body (UpdateShipmentRequestBody)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(UpdateShipmentResponseBody, Integer, Hash)>)

    UpdateShipmentResponseBody data, response status code and response headers



833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
# File 'lib/openapi_client/api/shipments_api.rb', line 833

def update_shipment_with_http_info(shipment_id, update_shipment_request_body, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ShipmentsApi.update_shipment ...'
  end
  # verify the required parameter 'shipment_id' is set
  if @api_client.config.client_side_validation && shipment_id.nil?
    fail ArgumentError, "Missing the required parameter 'shipment_id' when calling ShipmentsApi.update_shipment"
  end
  if @api_client.config.client_side_validation && shipment_id.to_s.length > 25
    fail ArgumentError, 'invalid value for "shipment_id" when calling ShipmentsApi.update_shipment, the character length must be smaller than or equal to 25.'
  end

  if @api_client.config.client_side_validation && shipment_id.to_s.length < 1
    fail ArgumentError, 'invalid value for "shipment_id" when calling ShipmentsApi.update_shipment, the character length must be great than or equal to 1.'
  end

  pattern = Regexp.new(/^se(-[a-z0-9]+)+$/)
  if @api_client.config.client_side_validation && shipment_id !~ pattern
    fail ArgumentError, "invalid value for 'shipment_id' when calling ShipmentsApi.update_shipment, must conform to the pattern #{pattern}."
  end

  # verify the required parameter 'update_shipment_request_body' is set
  if @api_client.config.client_side_validation && update_shipment_request_body.nil?
    fail ArgumentError, "Missing the required parameter 'update_shipment_request_body' when calling ShipmentsApi.update_shipment"
  end
  # resource path
  local_var_path = '/v1/shipments/{shipment_id}'.sub('{' + 'shipment_id' + '}', CGI.escape(shipment_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:body] || @api_client.object_to_http_body(update_shipment_request_body) 

  # return_type
  return_type = opts[:return_type] || 'UpdateShipmentResponseBody' 

  # auth_names
  auth_names = opts[:auth_names] || ['api_key']

  new_options = opts.merge(
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ShipmentsApi#update_shipment\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end