Class: Trackplus::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/trackplus/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



5
6
7
8
9
# File 'lib/trackplus/client.rb', line 5

def initialize(options = {})
  @max_retries = options.fetch(:max_retries, 3)
  @api_key = options.fetch(:api_key) { configuration_error 'Missing api_key argument' }
  @transform_to = Transformation.new(options[:transform_to])
end

Instance Method Details

#couriersObject



16
17
18
# File 'lib/trackplus/client.rb', line 16

def couriers
  @transform_to.apply(nil, get_request('couriers')['data'])
end

#tracking(courier:, tracking_no:) ⇒ Object

returns a collection of your account members



12
13
14
# File 'lib/trackplus/client.rb', line 12

def tracking(courier:, tracking_no:)
  @transform_to.apply(nil, get_request("trackings/#{courier}/#{tracking_no}")['data'])
end