Class: SecureTrading::Objects::Customer

Inherits:
DataObject
  • Object
show all
Defined in:
lib/secure_trading/objects/customer.rb

Defined Under Namespace

Classes: Address

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from DataObject

#initialize, #to_xml

Constructor Details

This class inherits a constructor from SecureTrading::DataObject

Instance Attribute Details

#addressObject

Returns the value of attribute address.



5
6
7
# File 'lib/secure_trading/objects/customer.rb', line 5

def address
  @address
end

#companyObject

Returns the value of attribute company.



5
6
7
# File 'lib/secure_trading/objects/customer.rb', line 5

def company
  @company
end

#email_addressObject

Returns the value of attribute email_address.



5
6
7
# File 'lib/secure_trading/objects/customer.rb', line 5

def email_address
  @email_address
end

#first_nameObject

Returns the value of attribute first_name.



5
6
7
# File 'lib/secure_trading/objects/customer.rb', line 5

def first_name
  @first_name
end

#last_nameObject

Returns the value of attribute last_name.



5
6
7
# File 'lib/secure_trading/objects/customer.rb', line 5

def last_name
  @last_name
end

#phone_numberObject

Returns the value of attribute phone_number.



5
6
7
# File 'lib/secure_trading/objects/customer.rb', line 5

def phone_number
  @phone_number
end

#titleObject

Returns the value of attribute title.



5
6
7
# File 'lib/secure_trading/objects/customer.rb', line 5

def title
  @title
end

Instance Method Details

#sanitize(value) ⇒ Object



23
24
25
# File 'lib/secure_trading/objects/customer.rb', line 23

def sanitize(value)
  Iconv.iconv('ascii//translit//IGNORE', 'utf-8//IGNORE', value).join
end

#to_hashObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/secure_trading/objects/customer.rb', line 7

def to_hash
  {
    'Postal' => {
                  'Name' => { 'NamePrefix' => sanitize(self.title), 'FirstName' => sanitize(self.first_name), 'LastName' => sanitize(self.last_name) },
                  'Company' => sanitize(self.company),
                  'Street' => sanitize(self.address.street),
                  'City' => sanitize(self.address.city),
                  'StateProv' => sanitize(self.address.state),
                  'PostalCode' => sanitize(self.address.postal_code),
                  'CountryCode' => sanitize(self.address.country)
                },
    'Telecom' => {'Phone' => sanitize(self.phone_number)},
    'Online' => {'Email' => sanitize(self.email_address)}
  }
end