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



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

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. The returned distance is as the crow flies.

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:



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

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