Class: AdvancedBilling::OrganizationAddress

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/advanced_billing/models/organization_address.rb

Overview

OrganizationAddress Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(street: SKIP, line2: SKIP, city: SKIP, state: SKIP, zip: SKIP, country: SKIP, name: SKIP, phone: SKIP, additional_properties: {}) ⇒ OrganizationAddress

Returns a new instance of OrganizationAddress.



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/advanced_billing/models/organization_address.rb', line 86

def initialize(street: SKIP, line2: SKIP, city: SKIP, state: SKIP,
               zip: SKIP, country: SKIP, name: SKIP, phone: SKIP,
               additional_properties: {})
  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end

  @street = street unless street == SKIP
  @line2 = line2 unless line2 == SKIP
  @city = city unless city == SKIP
  @state = state unless state == SKIP
  @zip = zip unless zip == SKIP
  @country = country unless country == SKIP
  @name = name unless name == SKIP
  @phone = phone unless phone == SKIP
end

Instance Attribute Details

#cityString

TODO: Write general description for this method

Returns:

  • (String)


22
23
24
# File 'lib/advanced_billing/models/organization_address.rb', line 22

def city
  @city
end

#countryString

TODO: Write general description for this method

Returns:

  • (String)


34
35
36
# File 'lib/advanced_billing/models/organization_address.rb', line 34

def country
  @country
end

#line2String

TODO: Write general description for this method

Returns:

  • (String)


18
19
20
# File 'lib/advanced_billing/models/organization_address.rb', line 18

def line2
  @line2
end

#nameString

TODO: Write general description for this method

Returns:

  • (String)


38
39
40
# File 'lib/advanced_billing/models/organization_address.rb', line 38

def name
  @name
end

#phoneString

TODO: Write general description for this method

Returns:

  • (String)


42
43
44
# File 'lib/advanced_billing/models/organization_address.rb', line 42

def phone
  @phone
end

#stateString

TODO: Write general description for this method

Returns:

  • (String)


26
27
28
# File 'lib/advanced_billing/models/organization_address.rb', line 26

def state
  @state
end

#streetString

TODO: Write general description for this method

Returns:

  • (String)


14
15
16
# File 'lib/advanced_billing/models/organization_address.rb', line 14

def street
  @street
end

#zipString

TODO: Write general description for this method

Returns:

  • (String)


30
31
32
# File 'lib/advanced_billing/models/organization_address.rb', line 30

def zip
  @zip
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/advanced_billing/models/organization_address.rb', line 105

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  street = hash.key?('street') ? hash['street'] : SKIP
  line2 = hash.key?('line2') ? hash['line2'] : SKIP
  city = hash.key?('city') ? hash['city'] : SKIP
  state = hash.key?('state') ? hash['state'] : SKIP
  zip = hash.key?('zip') ? hash['zip'] : SKIP
  country = hash.key?('country') ? hash['country'] : SKIP
  name = hash.key?('name') ? hash['name'] : SKIP
  phone = hash.key?('phone') ? hash['phone'] : SKIP

  # Clean out expected properties from Hash.
  additional_properties = hash.reject { |k, _| names.value?(k) }

  # Create object from extracted values.
  OrganizationAddress.new(street: street,
                          line2: line2,
                          city: city,
                          state: state,
                          zip: zip,
                          country: country,
                          name: name,
                          phone: phone,
                          additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/advanced_billing/models/organization_address.rb', line 45

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['street'] = 'street'
  @_hash['line2'] = 'line2'
  @_hash['city'] = 'city'
  @_hash['state'] = 'state'
  @_hash['zip'] = 'zip'
  @_hash['country'] = 'country'
  @_hash['name'] = 'name'
  @_hash['phone'] = 'phone'
  @_hash
end

.nullablesObject

An array for nullable fields



73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/advanced_billing/models/organization_address.rb', line 73

def self.nullables
  %w[
    street
    line2
    city
    state
    zip
    country
    name
    phone
  ]
end

.optionalsObject

An array for optional fields



59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/advanced_billing/models/organization_address.rb', line 59

def self.optionals
  %w[
    street
    line2
    city
    state
    zip
    country
    name
    phone
  ]
end