Class: OpenapiClient::BatchesApi

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ BatchesApi

Returns a new instance of BatchesApi.



19
20
21
# File 'lib/openapi_client/api/batches_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/batches_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#add_to_batch(batch_id, add_to_batch_request_body, opts = {}) ⇒ String

Add to a Batch Add a Shipment or Rate to a Batch

Parameters:

  • batch_id (String)

    Batch ID

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

    the optional parameters

Returns:

  • (String)


28
29
30
31
# File 'lib/openapi_client/api/batches_api.rb', line 28

def add_to_batch(batch_id, add_to_batch_request_body, opts = {})
  data, _status_code, _headers = add_to_batch_with_http_info(batch_id, add_to_batch_request_body, opts)
  data
end

#add_to_batch_with_http_info(batch_id, add_to_batch_request_body, opts = {}) ⇒ Array<(String, Integer, Hash)>

Add to a Batch Add a Shipment or Rate to a Batch

Parameters:

  • batch_id (String)

    Batch ID

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

    the optional parameters

Returns:

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

    String data, response status code and response headers



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
96
97
98
99
100
101
102
103
# File 'lib/openapi_client/api/batches_api.rb', line 39

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

  if @api_client.config.client_side_validation && batch_id.to_s.length < 1
    fail ArgumentError, 'invalid value for "batch_id" when calling BatchesApi.add_to_batch, 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 && batch_id !~ pattern
    fail ArgumentError, "invalid value for 'batch_id' when calling BatchesApi.add_to_batch, must conform to the pattern #{pattern}."
  end

  # verify the required parameter 'add_to_batch_request_body' is set
  if @api_client.config.client_side_validation && add_to_batch_request_body.nil?
    fail ArgumentError, "Missing the required parameter 'add_to_batch_request_body' when calling BatchesApi.add_to_batch"
  end
  # resource path
  local_var_path = '/v1/batches/{batch_id}/add'.sub('{' + 'batch_id' + '}', CGI.escape(batch_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'])
  # 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(add_to_batch_request_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(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: BatchesApi#add_to_batch\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#create_batch(create_batch_request_body, opts = {}) ⇒ CreateBatchResponseBody

Create A Batch Create a Batch

Parameters:

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

    the optional parameters

Returns:



110
111
112
113
# File 'lib/openapi_client/api/batches_api.rb', line 110

def create_batch(create_batch_request_body, opts = {})
  data, _status_code, _headers = create_batch_with_http_info(create_batch_request_body, opts)
  data
end

#create_batch_with_http_info(create_batch_request_body, opts = {}) ⇒ Array<(CreateBatchResponseBody, Integer, Hash)>

Create A Batch Create a Batch

Parameters:

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

    the optional parameters

Returns:

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

    CreateBatchResponseBody data, response status code and response headers



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
160
161
162
163
164
165
166
167
# File 'lib/openapi_client/api/batches_api.rb', line 120

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

  # 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_batch_request_body) 

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

  # 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: BatchesApi#create_batch\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#delete_batch(batch_id, opts = {}) ⇒ String

Delete Batch By Id Delete Batch By Id

Parameters:

  • batch_id (String)

    Batch ID

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

    the optional parameters

Returns:

  • (String)


174
175
176
177
# File 'lib/openapi_client/api/batches_api.rb', line 174

def delete_batch(batch_id, opts = {})
  data, _status_code, _headers = delete_batch_with_http_info(batch_id, opts)
  data
end

#delete_batch_with_http_info(batch_id, opts = {}) ⇒ Array<(String, Integer, Hash)>

Delete Batch By Id Delete Batch By Id

Parameters:

  • batch_id (String)

    Batch ID

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

    the optional parameters

Returns:

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

    String data, response status code and response headers



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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
# File 'lib/openapi_client/api/batches_api.rb', line 184

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

  if @api_client.config.client_side_validation && batch_id.to_s.length < 1
    fail ArgumentError, 'invalid value for "batch_id" when calling BatchesApi.delete_batch, 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 && batch_id !~ pattern
    fail ArgumentError, "invalid value for 'batch_id' when calling BatchesApi.delete_batch, must conform to the pattern #{pattern}."
  end

  # resource path
  local_var_path = '/v1/batches/{batch_id}'.sub('{' + 'batch_id' + '}', CGI.escape(batch_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(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: BatchesApi#delete_batch\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_batch_by_external_id(external_batch_id, opts = {}) ⇒ GetBatchByExternalIdResponseBody

Get Batch By External ID Get Batch By External ID

Parameters:

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

    the optional parameters

Returns:



249
250
251
252
# File 'lib/openapi_client/api/batches_api.rb', line 249

def get_batch_by_external_id(external_batch_id, opts = {})
  data, _status_code, _headers = get_batch_by_external_id_with_http_info(external_batch_id, opts)
  data
end

#get_batch_by_external_id_with_http_info(external_batch_id, opts = {}) ⇒ Array<(GetBatchByExternalIdResponseBody, Integer, Hash)>

Get Batch By External ID Get Batch By External ID

Parameters:

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

    the optional parameters

Returns:



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
297
298
299
300
301
302
303
304
# File 'lib/openapi_client/api/batches_api.rb', line 259

def get_batch_by_external_id_with_http_info(external_batch_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: BatchesApi.get_batch_by_external_id ...'
  end
  # verify the required parameter 'external_batch_id' is set
  if @api_client.config.client_side_validation && external_batch_id.nil?
    fail ArgumentError, "Missing the required parameter 'external_batch_id' when calling BatchesApi.get_batch_by_external_id"
  end
  # resource path
  local_var_path = '/v1/batches/external_batch_id/{external_batch_id}'.sub('{' + 'external_batch_id' + '}', CGI.escape(external_batch_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] || 'GetBatchByExternalIdResponseBody' 

  # 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: BatchesApi#get_batch_by_external_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_batch_by_id(batch_id, opts = {}) ⇒ GetBatchByIdResponseBody

Get Batch By ID Get Batch By ID

Parameters:

  • batch_id (String)

    Batch ID

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

    the optional parameters

Returns:



311
312
313
314
# File 'lib/openapi_client/api/batches_api.rb', line 311

def get_batch_by_id(batch_id, opts = {})
  data, _status_code, _headers = get_batch_by_id_with_http_info(batch_id, opts)
  data
end

#get_batch_by_id_with_http_info(batch_id, opts = {}) ⇒ Array<(GetBatchByIdResponseBody, Integer, Hash)>

Get Batch By ID Get Batch By ID

Parameters:

  • batch_id (String)

    Batch ID

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

    the optional parameters

Returns:

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

    GetBatchByIdResponseBody data, response status code and response headers



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
# File 'lib/openapi_client/api/batches_api.rb', line 321

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

  if @api_client.config.client_side_validation && batch_id.to_s.length < 1
    fail ArgumentError, 'invalid value for "batch_id" when calling BatchesApi.get_batch_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 && batch_id !~ pattern
    fail ArgumentError, "invalid value for 'batch_id' when calling BatchesApi.get_batch_by_id, must conform to the pattern #{pattern}."
  end

  # resource path
  local_var_path = '/v1/batches/{batch_id}'.sub('{' + 'batch_id' + '}', CGI.escape(batch_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] || 'GetBatchByIdResponseBody' 

  # 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: BatchesApi#get_batch_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_batch_errors(batch_id, opts = {}) ⇒ ListBatchErrorsResponseBody

Get Batch Errors Error handling in batches are handled differently than in a single synchronous request. You must retrieve the status of your batch by [getting a batch](www.shipengine.com/docs/reference/get-batch-by-id/) and getting an overview of the statuses or you can list errors directly here below to get detailed information about the errors.

Parameters:

  • batch_id (String)

    Batch 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:



388
389
390
391
# File 'lib/openapi_client/api/batches_api.rb', line 388

def list_batch_errors(batch_id, opts = {})
  data, _status_code, _headers = list_batch_errors_with_http_info(batch_id, opts)
  data
end

#list_batch_errors_with_http_info(batch_id, opts = {}) ⇒ Array<(ListBatchErrorsResponseBody, Integer, Hash)>

Get Batch Errors Error handling in batches are handled differently than in a single synchronous request. You must retrieve the status of your batch by [getting a batch](www.shipengine.com/docs/reference/get-batch-by-id/) and getting an overview of the statuses or you can list errors directly here below to get detailed information about the errors.

Parameters:

  • batch_id (String)

    Batch 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:

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

    ListBatchErrorsResponseBody data, response status code and response headers



400
401
402
403
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
464
465
466
467
468
# File 'lib/openapi_client/api/batches_api.rb', line 400

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

  if @api_client.config.client_side_validation && batch_id.to_s.length < 1
    fail ArgumentError, 'invalid value for "batch_id" when calling BatchesApi.list_batch_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 && batch_id !~ pattern
    fail ArgumentError, "invalid value for 'batch_id' when calling BatchesApi.list_batch_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 BatchesApi.list_batch_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 BatchesApi.list_batch_errors, must be greater than or equal to 1.'
  end

  # resource path
  local_var_path = '/v1/batches/{batch_id}/errors'.sub('{' + 'batch_id' + '}', CGI.escape(batch_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] || 'ListBatchErrorsResponseBody' 

  # 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: BatchesApi#list_batch_errors\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_batches(opts = {}) ⇒ ListBatchesResponseBody

List Batches List Batches associated with your Shipengine account

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :status (BatchStatus)
  • :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)

  • :sort_dir (SortDir)

    Controls the sort order of the query.

  • :sort_by (BatchesSortBy)

Returns:



479
480
481
482
# File 'lib/openapi_client/api/batches_api.rb', line 479

def list_batches(opts = {})
  data, _status_code, _headers = list_batches_with_http_info(opts)
  data
end

#list_batches_with_http_info(opts = {}) ⇒ Array<(ListBatchesResponseBody, Integer, Hash)>

List Batches List Batches associated with your Shipengine account

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :status (BatchStatus)
  • :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.

  • :sort_dir (SortDir)

    Controls the sort order of the query.

  • :sort_by (BatchesSortBy)

Returns:

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

    ListBatchesResponseBody data, response status code and response headers



493
494
495
496
497
498
499
500
501
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
# File 'lib/openapi_client/api/batches_api.rb', line 493

def list_batches_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: BatchesApi.list_batches ...'
  end
  if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] < 1
    fail ArgumentError, 'invalid value for "opts[:"page"]" when calling BatchesApi.list_batches, 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 BatchesApi.list_batches, must be greater than or equal to 1.'
  end

  # resource path
  local_var_path = '/v1/batches'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'status'] = opts[:'status'] if !opts[:'status'].nil?
  query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
  query_params[:'page_size'] = opts[:'page_size'] if !opts[:'page_size'].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] || 'ListBatchesResponseBody' 

  # 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: BatchesApi#list_batches\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#process_batch(batch_id, process_batch_request_body, opts = {}) ⇒ String

Process Batch ID Labels Process Batch ID Labels

Parameters:

  • batch_id (String)

    Batch ID

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

    the optional parameters

Returns:

  • (String)


555
556
557
558
# File 'lib/openapi_client/api/batches_api.rb', line 555

def process_batch(batch_id, process_batch_request_body, opts = {})
  data, _status_code, _headers = process_batch_with_http_info(batch_id, process_batch_request_body, opts)
  data
end

#process_batch_with_http_info(batch_id, process_batch_request_body, opts = {}) ⇒ Array<(String, Integer, Hash)>

Process Batch ID Labels Process Batch ID Labels

Parameters:

  • batch_id (String)

    Batch ID

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

    the optional parameters

Returns:

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

    String data, response status code and response headers



566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
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
# File 'lib/openapi_client/api/batches_api.rb', line 566

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

  if @api_client.config.client_side_validation && batch_id.to_s.length < 1
    fail ArgumentError, 'invalid value for "batch_id" when calling BatchesApi.process_batch, 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 && batch_id !~ pattern
    fail ArgumentError, "invalid value for 'batch_id' when calling BatchesApi.process_batch, must conform to the pattern #{pattern}."
  end

  # verify the required parameter 'process_batch_request_body' is set
  if @api_client.config.client_side_validation && process_batch_request_body.nil?
    fail ArgumentError, "Missing the required parameter 'process_batch_request_body' when calling BatchesApi.process_batch"
  end
  # resource path
  local_var_path = '/v1/batches/{batch_id}/process/labels'.sub('{' + 'batch_id' + '}', CGI.escape(batch_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'])
  # 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(process_batch_request_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(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: BatchesApi#process_batch\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#remove_from_batch(batch_id, remove_from_batch_request_body, opts = {}) ⇒ String

Remove From Batch Remove a shipment or rate from a batch

Parameters:

  • batch_id (String)

    Batch ID

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

    the optional parameters

Returns:

  • (String)


638
639
640
641
# File 'lib/openapi_client/api/batches_api.rb', line 638

def remove_from_batch(batch_id, remove_from_batch_request_body, opts = {})
  data, _status_code, _headers = remove_from_batch_with_http_info(batch_id, remove_from_batch_request_body, opts)
  data
end

#remove_from_batch_with_http_info(batch_id, remove_from_batch_request_body, opts = {}) ⇒ Array<(String, Integer, Hash)>

Remove From Batch Remove a shipment or rate from a batch

Parameters:

  • batch_id (String)

    Batch ID

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

    the optional parameters

Returns:

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

    String data, response status code and response headers



649
650
651
652
653
654
655
656
657
658
659
660
661
662
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
# File 'lib/openapi_client/api/batches_api.rb', line 649

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

  if @api_client.config.client_side_validation && batch_id.to_s.length < 1
    fail ArgumentError, 'invalid value for "batch_id" when calling BatchesApi.remove_from_batch, 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 && batch_id !~ pattern
    fail ArgumentError, "invalid value for 'batch_id' when calling BatchesApi.remove_from_batch, must conform to the pattern #{pattern}."
  end

  # verify the required parameter 'remove_from_batch_request_body' is set
  if @api_client.config.client_side_validation && remove_from_batch_request_body.nil?
    fail ArgumentError, "Missing the required parameter 'remove_from_batch_request_body' when calling BatchesApi.remove_from_batch"
  end
  # resource path
  local_var_path = '/v1/batches/{batch_id}/remove'.sub('{' + 'batch_id' + '}', CGI.escape(batch_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'])
  # 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(remove_from_batch_request_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(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: BatchesApi#remove_from_batch\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#update_batch(batch_id, opts = {}) ⇒ String

Update Batch By Id Update Batch By Id

Parameters:

  • batch_id (String)

    Batch ID

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

    the optional parameters

Returns:

  • (String)


720
721
722
723
# File 'lib/openapi_client/api/batches_api.rb', line 720

def update_batch(batch_id, opts = {})
  data, _status_code, _headers = update_batch_with_http_info(batch_id, opts)
  data
end

#update_batch_with_http_info(batch_id, opts = {}) ⇒ Array<(String, Integer, Hash)>

Update Batch By Id Update Batch By Id

Parameters:

  • batch_id (String)

    Batch ID

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

    the optional parameters

Returns:

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

    String data, response status code and response headers



730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
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
# File 'lib/openapi_client/api/batches_api.rb', line 730

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

  if @api_client.config.client_side_validation && batch_id.to_s.length < 1
    fail ArgumentError, 'invalid value for "batch_id" when calling BatchesApi.update_batch, 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 && batch_id !~ pattern
    fail ArgumentError, "invalid value for 'batch_id' when calling BatchesApi.update_batch, must conform to the pattern #{pattern}."
  end

  # resource path
  local_var_path = '/v1/batches/{batch_id}'.sub('{' + 'batch_id' + '}', CGI.escape(batch_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: BatchesApi#update_batch\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end