Module: Pombo::Services

Defined in:
lib/pombo/services.rb

Overview

Contains delivery services

Class Method Summary collapse

Class Method Details

.all(service = nil) ⇒ Array<OpenStruct>

List all services supported Listing all the services of a group

Examples:

Pombo::Services.all
# => [
# =>    #<OpenStruct code="41106", max_weight=30, name="PAC", description="PAC (without contract)">,
# =>    ....
# => ]
Pombo::Services.all :pac
# => [
# =>    #<OpenStruct code="41106", max_weight=30, name="PAC", description="PAC (without contract)">,
# =>    ....
# => ]

Parameters:

  • service (Symbol) (defaults to: nil)

    group services, `:pac`, `sedex` or `e_sedex`

Returns:

  • (Array<OpenStruct>)

    with the data structure representing a service


26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/pombo/services.rb', line 26

def self.all(service = nil)
  case service
  when :pac
    all_pac.values
  when :sedex
    all_sedex.values
  when :e_sedex
    all_e_sedex.values
  else
    all_pac.values + all_sedex.values + all_e_sedex.values
  end
end

.find(code) ⇒ OpenStruct

Search for a service code

Examples:

Pombo::Services.find "41106"
# => #<OpenStruct code="41106", max_weight=30, name="PAC", description="PAC (without contract)">

Returns:

  • (OpenStruct)

    the data structure representing a service


44
45
46
# File 'lib/pombo/services.rb', line 44

def self.find(code)
  all_services.values_at(code).first
end