Class: Cargowise::Endpoint

Inherits:
Object
  • Object
show all
Defined in:
lib/cargowise/endpoint.rb

Overview

Stores the details for connecting to a single logistics company.

Generally created using the register() method on the Order and Shipment classes.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Endpoint

create a new endpoint. All 4 options are compulsory.

Raises:

  • (ArgumentError)


17
18
19
20
21
22
23
24
25
# File 'lib/cargowise/endpoint.rb', line 17

def initialize(opts = {})
  raise ArgumentError, "option :uri must be provided"      if opts[:uri].nil?
  raise ArgumentError, "option :code must be provided"     if opts[:code].nil?
  raise ArgumentError, "option :user must be provided"     if opts[:user].nil?
  raise ArgumentError, "option :password must be provided" if opts[:password].nil?

  @uri = opts[:uri]
  @code, @user, @password = opts[:code], opts[:user], opts[:password]
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



13
14
15
# File 'lib/cargowise/endpoint.rb', line 13

def code
  @code
end

#passwordObject (readonly)

Returns the value of attribute password.



13
14
15
# File 'lib/cargowise/endpoint.rb', line 13

def password
  @password
end

#uriObject (readonly)

Returns the value of attribute uri.



12
13
14
# File 'lib/cargowise/endpoint.rb', line 12

def uri
  @uri
end

#userObject (readonly)

Returns the value of attribute user.



13
14
15
# File 'lib/cargowise/endpoint.rb', line 13

def user
  @user
end