Class: AftershipAPI::TrackingApi

Inherits:
Object
  • Object
show all
Defined in:
lib/aftership-tracking-sdk/api/tracking.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ TrackingApi

Returns a new instance of TrackingApi.



9
10
11
# File 'lib/aftership-tracking-sdk/api/tracking.rb', line 9

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

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



7
8
9
# File 'lib/aftership-tracking-sdk/api/tracking.rb', line 7

def api_client
  @api_client
end

Instance Method Details

#create_tracking(body:, opts: {}) ⇒ Model::CreateTrackingResponse

Parameters:

Returns:



19
20
21
22
23
24
25
26
# File 'lib/aftership-tracking-sdk/api/tracking.rb', line 19

def create_tracking(body:,opts: {})
  if "" != ""
    body = {:'' => body}
  end
  opts[:body] = body
  data, _status_code, _headers = create_tracking_with_http_info(opts: opts)
  data
end

#create_tracking_with_http_info(opts: {}) ⇒ Object



28
29
30
31
32
33
34
35
36
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
# File 'lib/aftership-tracking-sdk/api/tracking.rb', line 28

def create_tracking_with_http_info(opts: {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TrackingApi.create_tracking ...'
  end



  # resource path
  local_var_path = "/tracking/2024-10/trackings" 
  method = :'POST'

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

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

  # return_type
  return_type = 'CreateTrackingResponse'
  
  new_options = opts.merge(
    :operation => :"TrackingApi.create_tracking",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :return_type => return_type,
    :response_legacy_tag => "",
    :is_paging => false
  )

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

#delete_tracking_by_id(id:, opts: {}) ⇒ Model::DeleteTrackingByIdResponse

delete_tracking_by_id Delete a tracking.

Parameters:

  • id (String)

    tracking ID

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

    the optional parameters

Returns:



72
73
74
75
# File 'lib/aftership-tracking-sdk/api/tracking.rb', line 72

def delete_tracking_by_id(id:, opts: {})
  data, _status_code, _headers = delete_tracking_by_id_with_http_info(id:id, opts: opts)
  data
end

#delete_tracking_by_id_with_http_info(id:, opts: {}) ⇒ Object



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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/aftership-tracking-sdk/api/tracking.rb', line 77

def delete_tracking_by_id_with_http_info(id:, opts: {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TrackingApi.delete_tracking_by_id ...'
  end

  if id.nil? or id.to_s == ''
    raise InvalidParamError.new "id cannot be nil or empty"
  end


  # resource path
  local_var_path = "/tracking/2024-10/trackings/#{id}" 
  method = :'DELETE'

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

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

  # return_type
  return_type = 'DeleteTrackingByIdResponse'
  
  new_options = opts.merge(
    :operation => :"TrackingApi.delete_tracking_by_id",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :return_type => return_type,
    :response_legacy_tag => "",
    :is_paging => false
  )

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

#get_tracking_by_id(id:, opts: {}) ⇒ Model::GetTrackingByIdResponse

get_tracking_by_id Get tracking results of a single tracking.

Parameters:

  • id (String)

    tracking ID

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

    the optional parameters

Options Hash (opts:):

  • :fields (String)

    List of fields to include in the response. Use comma for multiple values. Fields to include: ‘tracking_postal_code`, `tracking_ship_date`, `tracking_account_number`, `tracking_key`, `tracking_origin_country`, `tracking_destination_country`, `tracking_state`, `title`, `order_id`, `tag`, `checkpoints`

  • :lang (String)

    Translate checkpoint messages from the carrier’s provided language to the target language. Supported target languages include:</br>&nbsp;&nbsp;&nbsp;&nbsp;- English (en)</br>&nbsp;&nbsp;&nbsp;&nbsp;- French (fr)</br>&nbsp;&nbsp;&nbsp;&nbsp;- French Canadian (fr-CA)</br>&nbsp;&nbsp;&nbsp;&nbsp;- Arabic (ar)</br>&nbsp;&nbsp;&nbsp;&nbsp;- Bulgarian (bg)</br>&nbsp;&nbsp;&nbsp;&nbsp;- Catalan (ca)</br>&nbsp;&nbsp;&nbsp;&nbsp;- Croatian (hr)</br>&nbsp;&nbsp;&nbsp;&nbsp;- Czech (cs)</br>&nbsp;&nbsp;&nbsp;&nbsp;- Danish (da)</br>&nbsp;&nbsp;&nbsp;&nbsp;- Dutch (nl)</br>&nbsp;&nbsp;&nbsp;&nbsp;- Estonian (et)</br>&nbsp;&nbsp;&nbsp;&nbsp;- Filipino (tl)</br>&nbsp;&nbsp;&nbsp;&nbsp;- Finnish (fi)</br>&nbsp;&nbsp;&nbsp;&nbsp;- German (de)</br>&nbsp;&nbsp;&nbsp;&nbsp;- Greek (el)</br>&nbsp;&nbsp;&nbsp;&nbsp;- Hebrew (he)</br>&nbsp;&nbsp;&nbsp;&nbsp;- Hindi (hi)</br>&nbsp;&nbsp;&nbsp;&nbsp;- Hungarian (hu)</br>&nbsp;&nbsp;&nbsp;&nbsp;- Indonesian (id)</br>&nbsp;&nbsp;&nbsp;&nbsp;- Italian (it)</br>&nbsp;&nbsp;&nbsp;&nbsp;- Japanese (ja)</br>&nbsp;&nbsp;&nbsp;&nbsp;- Korean (ko)</br>&nbsp;&nbsp;&nbsp;&nbsp;- Latvian (lv)</br>&nbsp;&nbsp;&nbsp;&nbsp;- Lithuanian (lt)</br>&nbsp;&nbsp;&nbsp;&nbsp;- Malay (ms)</br>&nbsp;&nbsp;&nbsp;&nbsp;- Polish (pl)</br>&nbsp;&nbsp;&nbsp;&nbsp;- Portuguese (pt)</br>&nbsp;&nbsp;&nbsp;&nbsp;- Romanian (ro)</br>&nbsp;&nbsp;&nbsp;&nbsp;- Russian (ru)</br>&nbsp;&nbsp;&nbsp;&nbsp;- Serbian (sr)</br>&nbsp;&nbsp;&nbsp;&nbsp;- Slovak (sk)</br>&nbsp;&nbsp;&nbsp;&nbsp;- Slovenian (sl)</br>&nbsp;&nbsp;&nbsp;&nbsp;- Spanish (es)</br>&nbsp;&nbsp;&nbsp;&nbsp;- Swedish (sv)</br>&nbsp;&nbsp;&nbsp;&nbsp;- Thai (th)</br>&nbsp;&nbsp;&nbsp;&nbsp;- Turkish (tr)</br>&nbsp;&nbsp;&nbsp;&nbsp;- Ukrainian (uk)</br>&nbsp;&nbsp;&nbsp;&nbsp;- Vietnamese (vi)</br>&nbsp;&nbsp;&nbsp;&nbsp;- Simplified Chinese (zh-Hans)</br>&nbsp;&nbsp;&nbsp;&nbsp;- Traditional Chinese (zh-Hant)</br>&nbsp;&nbsp;&nbsp;&nbsp;- Norwegian (nb)</br>

Returns:



126
127
128
129
# File 'lib/aftership-tracking-sdk/api/tracking.rb', line 126

def get_tracking_by_id(id:, opts: {})
  data, _status_code, _headers = get_tracking_by_id_with_http_info(id:id, opts: opts)
  data
end

#get_tracking_by_id_with_http_info(id:, opts: {}) ⇒ Object



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
168
169
170
171
172
173
# File 'lib/aftership-tracking-sdk/api/tracking.rb', line 131

def get_tracking_by_id_with_http_info(id:, opts: {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TrackingApi.get_tracking_by_id ...'
  end

  if id.nil? or id.to_s == ''
    raise InvalidParamError.new "id cannot be nil or empty"
  end


  # resource path
  local_var_path = "/tracking/2024-10/trackings/#{id}" 
  method = :'GET'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'fields'] = opts[:'fields'] if !opts[:'fields'].nil?
  query_params[:'lang'] = opts[:'lang'] if !opts[:'lang'].nil?
  # header parameters
  header_params = opts[:header_params] || {}

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

  # return_type
  return_type = 'GetTrackingByIdResponse'
  
  new_options = opts.merge(
    :operation => :"TrackingApi.get_tracking_by_id",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :return_type => return_type,
    :response_legacy_tag => "",
    :is_paging => false
  )

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

#get_trackings(opts: {}) ⇒ Model::GetTrackingsResponse

get_trackings Get tracking results of multiple trackings.<div style=“visibility:hidden; height: 0”></div>

Parameters:

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

    the optional parameters

Options Hash (opts:):

  • :cursor (String)

    A string representing the cursor value for the current page of results.

  • :limit (Integer)

    Number of trackings each page contain. (Default: 100, Max: 200)

  • :keyword (String)

    Search the content of the tracking record fields: ‘tracking_number`, `title`, `order_id`, `customer_name`, `custom_fields`, `emails`, `smses`

  • :tracking_numbers (String)

    Tracking number of shipments. Use comma to separate multiple values (Example: RA123456789US,LE123456789US). Supports up to 50 tracking numbers.

  • :slug (String)

    Unique courier code Use comma for multiple values. (Example: dhl,ups,usps)

  • :transit_time (Integer)

    Total delivery time in days.- When the shipment is delivered: Transit time = Delivered date - Picked up date- When the shipment is not delivered: Transit time = Current date - Picked up dateValue as ‘null` for the shipment without pickup date.

  • :origin (String)

    Origin country/region of trackings. Use ISO Alpha-3 (three letters). Use comma for multiple values. (Example: USA,HKG)

  • :destination (String)

    Destination country/region of trackings. Use ISO Alpha-3 (three letters). Use comma for multiple values. (Example: USA,HKG)

  • :tag (String)

    Current status of tracking. Values include ‘Pending`, `InfoReceived`, `InTransit`, `OutForDelivery`, `AttemptFail`, `Delivered`, `AvailableForPickup`, `Exception`, `Expired` (See tag definition)

  • :created_at_min (String)

    Start date and time of trackings created. AfterShip only stores data of 120 days.(Defaults: 30 days ago, Example: 2013-03-15T16:41:56+08:00)

  • :created_at_max (String)

    End date and time of trackings created.(Defaults: now, Example: 2013-04-15T16:41:56+08:00)

  • :updated_at_min (String)

    Start date and time of trackings updated. (Example: 2013-04-15T16:41:56+08:00)

  • :updated_at_max (String)

    End date and time of trackings updated. (Example: 2013-04-15T16:41:56+08:00)

  • :fields (String)

    List of fields to include in the response. Use comma for multiple values. Available options: ‘title`, `order_id`, `tag`, `checkpoints`. Example: `title,order_id`

  • :return_to_sender (String)

    Select return to sender, the value should be ‘true` or `false`, with optional comma separated.

  • :courier_destination_country_iso3 (String)

    Destination country/region of trackings returned by courier. Use ISO Alpha-3 (three letters). Use comma for multiple values. (Example: USA,HKG)

  • :shipment_tags (String)

    Tags you added to your shipments to help categorize and filter them easily. Use a comma to separate multiple values (Example: a,b)

  • :order_id (String)

    A globally-unique identifier for the order. Use comma for multiple values.(Example: 6845a095a27a4caeb27487806f058add,4845a095a27a4caeb27487806f058abc)

Returns:



197
198
199
200
# File 'lib/aftership-tracking-sdk/api/tracking.rb', line 197

def get_trackings(opts: {})
  data, _status_code, _headers = get_trackings_with_http_info(opts: opts)
  data
end

#get_trackings_with_http_info(opts: {}) ⇒ Object



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
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
# File 'lib/aftership-tracking-sdk/api/tracking.rb', line 202

def get_trackings_with_http_info(opts: {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TrackingApi.get_trackings ...'
  end



  # resource path
  local_var_path = "/tracking/2024-10/trackings" 
  method = :'GET'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'cursor'] = opts[:'cursor'] if !opts[:'cursor'].nil?
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'keyword'] = opts[:'keyword'] if !opts[:'keyword'].nil?
  query_params[:'tracking_numbers'] = opts[:'tracking_numbers'] if !opts[:'tracking_numbers'].nil?
  query_params[:'slug'] = opts[:'slug'] if !opts[:'slug'].nil?
  query_params[:'transit_time'] = opts[:'transit_time'] if !opts[:'transit_time'].nil?
  query_params[:'origin'] = opts[:'origin'] if !opts[:'origin'].nil?
  query_params[:'destination'] = opts[:'destination'] if !opts[:'destination'].nil?
  query_params[:'tag'] = opts[:'tag'] if !opts[:'tag'].nil?
  query_params[:'created_at_min'] = opts[:'created_at_min'] if !opts[:'created_at_min'].nil?
  query_params[:'created_at_max'] = opts[:'created_at_max'] if !opts[:'created_at_max'].nil?
  query_params[:'updated_at_min'] = opts[:'updated_at_min'] if !opts[:'updated_at_min'].nil?
  query_params[:'updated_at_max'] = opts[:'updated_at_max'] if !opts[:'updated_at_max'].nil?
  query_params[:'fields'] = opts[:'fields'] if !opts[:'fields'].nil?
  query_params[:'return_to_sender'] = opts[:'return_to_sender'] if !opts[:'return_to_sender'].nil?
  query_params[:'courier_destination_country_iso3'] = opts[:'courier_destination_country_iso3'] if !opts[:'courier_destination_country_iso3'].nil?
  query_params[:'shipment_tags'] = opts[:'shipment_tags'] if !opts[:'shipment_tags'].nil?
  query_params[:'order_id'] = opts[:'order_id'] if !opts[:'order_id'].nil?
  # header parameters
  header_params = opts[:header_params] || {}

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

  # return_type
  return_type = 'GetTrackingsResponse'
  
  new_options = opts.merge(
    :operation => :"TrackingApi.get_trackings",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :return_type => return_type,
    :response_legacy_tag => "",
    :is_paging => false
  )

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

#mark_tracking_completed_by_id(id:, body:, opts: {}) ⇒ Model::MarkTrackingCompletedByIdResponse

Parameters:

Returns:



266
267
268
269
270
271
272
273
# File 'lib/aftership-tracking-sdk/api/tracking.rb', line 266

def mark_tracking_completed_by_id(id:, body:,opts: {})
  if "" != ""
    body = {:'' => body}
  end
  opts[:body] = body
  data, _status_code, _headers = mark_tracking_completed_by_id_with_http_info(id:id, opts: opts)
  data
end

#mark_tracking_completed_by_id_with_http_info(id:, opts: {}) ⇒ Object



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
305
306
307
308
309
310
311
312
313
314
315
# File 'lib/aftership-tracking-sdk/api/tracking.rb', line 275

def mark_tracking_completed_by_id_with_http_info(id:, opts: {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TrackingApi.mark_tracking_completed_by_id ...'
  end

  if id.nil? or id.to_s == ''
    raise InvalidParamError.new "id cannot be nil or empty"
  end


  # resource path
  local_var_path = "/tracking/2024-10/trackings/#{id}/mark-as-completed" 
  method = :'POST'

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

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

  # return_type
  return_type = 'MarkTrackingCompletedByIdResponse'
  
  new_options = opts.merge(
    :operation => :"TrackingApi.mark_tracking_completed_by_id",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :return_type => return_type,
    :response_legacy_tag => "",
    :is_paging => false
  )

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

#retrack_tracking_by_id(id:, opts: {}) ⇒ Model::RetrackTrackingByIdResponse

retrack_tracking_by_id Retrack an expired tracking. Max 3 times per tracking.

Parameters:

  • id (String)

    tracking id

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

    the optional parameters

Returns:



322
323
324
325
# File 'lib/aftership-tracking-sdk/api/tracking.rb', line 322

def retrack_tracking_by_id(id:, opts: {})
  data, _status_code, _headers = retrack_tracking_by_id_with_http_info(id:id, opts: opts)
  data
end

#retrack_tracking_by_id_with_http_info(id:, opts: {}) ⇒ Object



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
# File 'lib/aftership-tracking-sdk/api/tracking.rb', line 327

def retrack_tracking_by_id_with_http_info(id:, opts: {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TrackingApi.retrack_tracking_by_id ...'
  end

  if id.nil? or id.to_s == ''
    raise InvalidParamError.new "id cannot be nil or empty"
  end


  # resource path
  local_var_path = "/tracking/2024-10/trackings/#{id}/retrack" 
  method = :'POST'

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

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

  # return_type
  return_type = 'RetrackTrackingByIdResponse'
  
  new_options = opts.merge(
    :operation => :"TrackingApi.retrack_tracking_by_id",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :return_type => return_type,
    :response_legacy_tag => "",
    :is_paging => false
  )

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

#update_tracking_by_id(id:, body:, opts: {}) ⇒ Model::UpdateTrackingByIdResponse

Parameters:

Returns:



376
377
378
379
380
381
382
383
# File 'lib/aftership-tracking-sdk/api/tracking.rb', line 376

def update_tracking_by_id(id:, body:,opts: {})
  if "" != ""
    body = {:'' => body}
  end
  opts[:body] = body
  data, _status_code, _headers = update_tracking_by_id_with_http_info(id:id, opts: opts)
  data
end

#update_tracking_by_id_with_http_info(id:, opts: {}) ⇒ Object



385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
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
# File 'lib/aftership-tracking-sdk/api/tracking.rb', line 385

def update_tracking_by_id_with_http_info(id:, opts: {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TrackingApi.update_tracking_by_id ...'
  end

  if id.nil? or id.to_s == ''
    raise InvalidParamError.new "id cannot be nil or empty"
  end


  # resource path
  local_var_path = "/tracking/2024-10/trackings/#{id}" 
  method = :'PUT'

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

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

  # return_type
  return_type = 'UpdateTrackingByIdResponse'
  
  new_options = opts.merge(
    :operation => :"TrackingApi.update_tracking_by_id",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :return_type => return_type,
    :response_legacy_tag => "",
    :is_paging => false
  )

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