Class: AftershipAPI::CourierApi

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ CourierApi

Returns a new instance of CourierApi.



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

def api_client
  @api_client
end

Instance Method Details

#detect_courier(body:, opts: {}) ⇒ Model::DetectCourierResponse

Parameters:

Returns:



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
104
105
106
# File 'lib/aftership-tracking-sdk/api/courier.rb', line 67

def detect_courier(body:, opts: {})
  opts[:body] = body
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CourierApi.detect_courier ...'
  end


  # resource path
  local_var_path = "/tracking/2025-07/couriers/detect"
  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 = 'DetectCourierResponseData'

  new_options = opts.merge(
    :operation => :"CourierApi.detect_courier",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :return_type => return_type
  )

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

  resp = Model::DetectCourierResponse.new
  resp.data = data
  resp.response_header = headers
  resp
end

#get_couriers(opts: {}) ⇒ Model::GetCouriersResponse

get_couriers Return a list of couriers.

Parameters:

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

    the optional parameters

Options Hash (opts:):

  • :active (Boolean)

    get user activated couriers

  • :slug (String)

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

Returns:



19
20
21
22
23
24
25
26
27
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
# File 'lib/aftership-tracking-sdk/api/courier.rb', line 19

def get_couriers(opts: {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CourierApi.get_couriers ...'
  end


  # resource path
  local_var_path = "/tracking/2025-07/couriers"
  method = :'GET'

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

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

  # return_type
  return_type = 'GetCouriersResponseData'

  new_options = opts.merge(
    :operation => :"CourierApi.get_couriers",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :return_type => return_type
  )

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

  resp = Model::GetCouriersResponse.new
  resp.data = data
  resp.response_header = headers
  resp
end