Class: ShippingConnector::Dao

Inherits:
Carrier
  • Object
show all
Defined in:
lib/shipping_connector/carrier/dao.rb

Instance Method Summary collapse

Methods inherited from Carrier

#require!

Constructor Details

#initialize(customer_id, password) ⇒ Dao

Initializes a new carrier object for DAO

Parameters:

  • customer_id (Integer)

    login details for the API user

  • password (String)

    login details for the API user


12
13
14
15
# File 'lib/shipping_connector/carrier/dao.rb', line 12

def initialize(options = {})
  require! options, :customer_id, :password
  super
end

Instance Method Details

#service_points(scope, zip_code, address, limit = 10) ⇒ Array<ServicePoint> #service_points(id) ⇒ ServicePoint

Returns a list of service points or a single service point

Overloads:

  • #service_points(scope, zip_code, address, limit = 10) ⇒ Array<ServicePoint>

    Returns the nearest service points ordered by distance.

    Parameters:

    • scope (Symbol)

      the scope: `:list` for listing nearest service points

    • zip_code (Integer, String)

      zip code for address to search from

    • address (String)

      street address to search from

    • limit (Integer) (defaults to: 10)

      amount of service points to be returned

    Returns:

    • (Array<ServicePoint>)

      the nearest service points ordered by distance

  • #service_points(id) ⇒ ServicePoint

    Returns the service point for the given `id`.

    Parameters:

    • id (Integer)

      the `id` of the service_point to be returned

    Returns:


27
28
29
30
31
32
33
34
35
36
37
# File 'lib/shipping_connector/carrier/dao.rb', line 27

def service_points(*arguments)
  scope   = arguments.slice!(0)
  options = arguments.slice!(0) || {}

  case scope
  when :list
    list_service_points(options)
  else
    find_service_point(scope)
  end
end