Class: Raas::BillingAddressModel

Inherits:
BaseModel show all
Defined in:
lib/raas/models/billing_address_model.rb

Overview

Represents a Billing Address

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(first_name = nil, last_name = nil, address_line1 = nil, city = nil, state = nil, postal_code = nil, country = nil, email_address = nil, address_line2 = nil) ⇒ BillingAddressModel

Returns a new instance of BillingAddressModel.



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/raas/models/billing_address_model.rb', line 58

def initialize(first_name = nil,
               last_name = nil,
               address_line1 = nil,
               city = nil,
               state = nil,
               postal_code = nil,
               country = nil,
               email_address = nil,
               address_line2 = nil)
  @first_name = first_name
  @last_name = last_name
  @address_line1 = address_line1
  @city = city
  @state = state
  @postal_code = postal_code
  @country = country
  @email_address = email_address
  @address_line2 = address_line2
end

Instance Attribute Details

#address_line1String

The address

Returns:



17
18
19
# File 'lib/raas/models/billing_address_model.rb', line 17

def address_line1
  @address_line1
end

#address_line2String

An optional second address line

Returns:



41
42
43
# File 'lib/raas/models/billing_address_model.rb', line 41

def address_line2
  @address_line2
end

#cityString

The city

Returns:



21
22
23
# File 'lib/raas/models/billing_address_model.rb', line 21

def city
  @city
end

#countryString

The 2-letter country code

Returns:



33
34
35
# File 'lib/raas/models/billing_address_model.rb', line 33

def country
  @country
end

#email_addressString

The billing contact’s email address

Returns:



37
38
39
# File 'lib/raas/models/billing_address_model.rb', line 37

def email_address
  @email_address
end

#first_nameString

The first name

Returns:



9
10
11
# File 'lib/raas/models/billing_address_model.rb', line 9

def first_name
  @first_name
end

#last_nameString

The last name

Returns:



13
14
15
# File 'lib/raas/models/billing_address_model.rb', line 13

def last_name
  @last_name
end

#postal_codeString

The postal code

Returns:



29
30
31
# File 'lib/raas/models/billing_address_model.rb', line 29

def postal_code
  @postal_code
end

#stateString

The state/province

Returns:



25
26
27
# File 'lib/raas/models/billing_address_model.rb', line 25

def state
  @state
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/raas/models/billing_address_model.rb', line 79

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  first_name = hash['firstName']
  last_name = hash['lastName']
  address_line1 = hash['addressLine1']
  city = hash['city']
  state = hash['state']
  postal_code = hash['postalCode']
  country = hash['country']
  email_address = hash['emailAddress']
  address_line2 = hash['addressLine2']

  # Create object from extracted values.
  BillingAddressModel.new(first_name,
                          last_name,
                          address_line1,
                          city,
                          state,
                          postal_code,
                          country,
                          email_address,
                          address_line2)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['first_name'] = 'firstName'
  @_hash['last_name'] = 'lastName'
  @_hash['address_line1'] = 'addressLine1'
  @_hash['city'] = 'city'
  @_hash['state'] = 'state'
  @_hash['postal_code'] = 'postalCode'
  @_hash['country'] = 'country'
  @_hash['email_address'] = 'emailAddress'
  @_hash['address_line2'] = 'addressLine2'
  @_hash
end