Class: Asdawqw::CompanyAddress

Inherits:
BaseModel show all
Defined in:
lib/asdawqw/models/company_address.rb

Overview

CompanyAddress Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(country = nil, state = nil, street_address = nil, city = nil, zip = nil) ⇒ CompanyAddress

Returns a new instance of CompanyAddress.



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/asdawqw/models/company_address.rb', line 40

def initialize(country = nil,
               state = nil,
               street_address = nil,
               city = nil,
               zip = nil)
  @country = country
  @state = state
  @street_address = street_address
  @city = city
  @zip = zip
end

Instance Attribute Details

#cityString

City of PM

Returns:



23
24
25
# File 'lib/asdawqw/models/company_address.rb', line 23

def city
  @city
end

#countryString

Country of PM. Require 2 letter ISO code

Returns:



11
12
13
# File 'lib/asdawqw/models/company_address.rb', line 11

def country
  @country
end

#stateString

State (Region) of PM. Required for US properties.

Returns:



15
16
17
# File 'lib/asdawqw/models/company_address.rb', line 15

def state
  @state
end

#street_addressString

Street address of PM.

Returns:



19
20
21
# File 'lib/asdawqw/models/company_address.rb', line 19

def street_address
  @street_address
end

#zipString

Zip code (postal code) of PM.

Returns:



27
28
29
# File 'lib/asdawqw/models/company_address.rb', line 27

def zip
  @zip
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/asdawqw/models/company_address.rb', line 53

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.

  country = hash['country']
  state = hash['state']
  street_address = hash['streetAddress']
  city = hash['city']
  zip = hash['zip']

  # Create object from extracted values.

  CompanyAddress.new(country,
                     state,
                     street_address,
                     city,
                     zip)
end

.namesObject

A mapping from model property names to API property names.



30
31
32
33
34
35
36
37
38
# File 'lib/asdawqw/models/company_address.rb', line 30

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['country'] = 'country'
  @_hash['state'] = 'state'
  @_hash['street_address'] = 'streetAddress'
  @_hash['city'] = 'city'
  @_hash['zip'] = 'zip'
  @_hash
end