Class: DHL::Ecommerce::Account
- Includes:
- Operations::Find, Operations::List
- Defined in:
- lib/dhl/ecommerce/account.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
readonly
Returns the value of attribute address.
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Account
constructor
A new instance of Account.
- #locations ⇒ Object
Methods included from Operations::List
Methods included from Operations::Find
Constructor Details
#initialize(attributes = {}) ⇒ Account
Returns a new instance of Account.
9 10 11 12 13 14 15 16 |
# File 'lib/dhl/ecommerce/account.rb', line 9 def initialize(attributes = {}) super attributes unless attributes.empty? @id = attributes[:account].to_i if attributes[:account] @address = StandardAddress.new attributes end end |
Instance Attribute Details
#address ⇒ Object (readonly)
Returns the value of attribute address.
7 8 9 |
# File 'lib/dhl/ecommerce/account.rb', line 7 def address @address end |
#email ⇒ Object (readonly)
Returns the value of attribute email.
7 8 9 |
# File 'lib/dhl/ecommerce/account.rb', line 7 def email @email end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
7 8 9 |
# File 'lib/dhl/ecommerce/account.rb', line 7 def id @id end |
Instance Method Details
#locations ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/dhl/ecommerce/account.rb', line 18 def locations response = DHL::Ecommerce.request :get, "https://api.dhlglobalmail.com/v1/#{self.resource_name.downcase}s/#{id}/#{DHL::Ecommerce::Location.resource_name.downcase}s" response[self.resource_name]["#{DHL::Ecommerce::Location.resource_name}s"][DHL::Ecommerce::Location.resource_name] = [response[self.resource_name]["#{DHL::Ecommerce::Location.resource_name}s"][DHL::Ecommerce::Location.resource_name]] unless response[self.resource_name]["#{DHL::Ecommerce::Location.resource_name}s"][DHL::Ecommerce::Location.resource_name].is_a? Array response[self.resource_name]["#{DHL::Ecommerce::Location.resource_name}s"].map do |attributes| location = DHL::Ecommerce::Location.new attributes location.instance_variable_set :@account, self location end end |