Module: Deliveries::Courier

Instance Method Summary collapse

Instance Method Details

#config(key, default: nil) ⇒ Mixed

Get configuration value by key.

Parameters:

  • key (String, Symbol[])

    Dot notation string or array of symbols.

  • default (Mixed) (defaults to: nil)

Returns:

  • (Mixed)


22
23
24
25
26
27
# File 'lib/deliveries/courier.rb', line 22

def config(key, default: nil)
  raise 'Courier not configured' unless configured?

  key = key.split('.').map(&:to_sym) if key.is_a? String
  @config.dig(*key) || default
end

#configure {|@config| ... } ⇒ Object

Yields:



7
8
9
10
# File 'lib/deliveries/courier.rb', line 7

def configure
  @config ||= ancestors.first::Config.new
  yield @config
end

#configured?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/deliveries/courier.rb', line 12

def configured?
  @config.present?
end

#create_pickup(sender:, receiver:, parcels:, reference_code:, pickup_date: nil, remarks: nil, language: nil) ⇒ Object

Raises:

  • (NotImplementedError)


49
50
51
# File 'lib/deliveries/courier.rb', line 49

def create_pickup(sender:, receiver:, parcels:, reference_code:, pickup_date: nil, remarks: nil, language: nil)
  raise NotImplementedError
end

#create_shipment(sender:, receiver:, collection_point:, parcels:, reference_code:, shipment_date: nil, remarks: nil, language: nil) ⇒ Object

Raises:

  • (NotImplementedError)


45
46
47
# File 'lib/deliveries/courier.rb', line 45

def create_shipment(sender:, receiver:, collection_point:, parcels:, reference_code:, shipment_date: nil, remarks: nil, language: nil)
  raise NotImplementedError
end

#get_collection_point(global_point_id:) ⇒ Object

Raises:

  • (NotImplementedError)


37
38
39
# File 'lib/deliveries/courier.rb', line 37

def get_collection_point(global_point_id:)
  raise NotImplementedError
end

#get_collection_points(country:, postcode:) ⇒ Object

Raises:

  • (NotImplementedError)


41
42
43
# File 'lib/deliveries/courier.rb', line 41

def get_collection_points(country:, postcode:)
  raise NotImplementedError
end

#get_label(tracking_code:, language: nil) ⇒ Object

Raises:

  • (NotImplementedError)


53
54
55
# File 'lib/deliveries/courier.rb', line 53

def get_label(tracking_code:, language: nil)
  raise NotImplementedError
end

#get_labels(tracking_codes:, language: nil) ⇒ Object

Raises:

  • (NotImplementedError)


57
58
59
# File 'lib/deliveries/courier.rb', line 57

def get_labels(tracking_codes:, language: nil)
  raise NotImplementedError
end

#live?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/deliveries/courier.rb', line 33

def live?
  Deliveries.live?
end

#pickup_info(tracking_code:, language: nil) ⇒ Object

Raises:

  • (NotImplementedError)


65
66
67
# File 'lib/deliveries/courier.rb', line 65

def pickup_info(tracking_code:, language: nil)
  raise NotImplementedError
end

#shipment_info(tracking_code:, language: nil) ⇒ Object

Raises:

  • (NotImplementedError)


61
62
63
# File 'lib/deliveries/courier.rb', line 61

def shipment_info(tracking_code:, language: nil)
  raise NotImplementedError
end

#test?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/deliveries/courier.rb', line 29

def test?
  Deliveries.test?
end