Class: EwayRapid::InternalModels::Customer

Inherits:
Object
  • Object
show all
Defined in:
lib/eway_rapid/models/internal_models.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#card_detailsObject

Returns the value of attribute card_details.



55
56
57
# File 'lib/eway_rapid/models/internal_models.rb', line 55

def card_details
  @card_details
end

#card_expiry_monthObject

Returns the value of attribute card_expiry_month.



52
53
54
# File 'lib/eway_rapid/models/internal_models.rb', line 52

def card_expiry_month
  @card_expiry_month
end

#card_expiry_yearObject

Returns the value of attribute card_expiry_year.



53
54
55
# File 'lib/eway_rapid/models/internal_models.rb', line 53

def card_expiry_year
  @card_expiry_year
end

#card_issue_numberObject

Returns the value of attribute card_issue_number.



50
51
52
# File 'lib/eway_rapid/models/internal_models.rb', line 50

def card_issue_number
  @card_issue_number
end

#card_nameObject

Returns the value of attribute card_name.



51
52
53
# File 'lib/eway_rapid/models/internal_models.rb', line 51

def card_name
  @card_name
end

#card_numberObject

Returns the value of attribute card_number.



47
48
49
# File 'lib/eway_rapid/models/internal_models.rb', line 47

def card_number
  @card_number
end

#card_start_monthObject

Returns the value of attribute card_start_month.



48
49
50
# File 'lib/eway_rapid/models/internal_models.rb', line 48

def card_start_month
  @card_start_month
end

#card_start_yearObject

Returns the value of attribute card_start_year.



49
50
51
# File 'lib/eway_rapid/models/internal_models.rb', line 49

def card_start_year
  @card_start_year
end

#cityObject

Returns the value of attribute city.



37
38
39
# File 'lib/eway_rapid/models/internal_models.rb', line 37

def city
  @city
end

#commentsObject

Returns the value of attribute comments.



44
45
46
# File 'lib/eway_rapid/models/internal_models.rb', line 44

def comments
  @comments
end

#company_nameObject

Returns the value of attribute company_name.



33
34
35
# File 'lib/eway_rapid/models/internal_models.rb', line 33

def company_name
  @company_name
end

#countryObject

Returns the value of attribute country.



40
41
42
# File 'lib/eway_rapid/models/internal_models.rb', line 40

def country
  @country
end

#customer_device_ipObject

Returns the value of attribute customer_device_ip.



56
57
58
# File 'lib/eway_rapid/models/internal_models.rb', line 56

def customer_device_ip
  @customer_device_ip
end

#emailObject

Returns the value of attribute email.



41
42
43
# File 'lib/eway_rapid/models/internal_models.rb', line 41

def email
  @email
end

#faxObject

Returns the value of attribute fax.



45
46
47
# File 'lib/eway_rapid/models/internal_models.rb', line 45

def fax
  @fax
end

#first_nameObject

Returns the value of attribute first_name.



31
32
33
# File 'lib/eway_rapid/models/internal_models.rb', line 31

def first_name
  @first_name
end

#is_activeObject

Returns the value of attribute is_active.



54
55
56
# File 'lib/eway_rapid/models/internal_models.rb', line 54

def is_active
  @is_active
end

#job_descriptionObject

Returns the value of attribute job_description.



34
35
36
# File 'lib/eway_rapid/models/internal_models.rb', line 34

def job_description
  @job_description
end

#last_nameObject

Returns the value of attribute last_name.



32
33
34
# File 'lib/eway_rapid/models/internal_models.rb', line 32

def last_name
  @last_name
end

#mobileObject

Returns the value of attribute mobile.



43
44
45
# File 'lib/eway_rapid/models/internal_models.rb', line 43

def mobile
  @mobile
end

#phoneObject

Returns the value of attribute phone.



42
43
44
# File 'lib/eway_rapid/models/internal_models.rb', line 42

def phone
  @phone
end

#postal_codeObject

Returns the value of attribute postal_code.



39
40
41
# File 'lib/eway_rapid/models/internal_models.rb', line 39

def postal_code
  @postal_code
end

#referenceObject

Returns the value of attribute reference.



29
30
31
# File 'lib/eway_rapid/models/internal_models.rb', line 29

def reference
  @reference
end

#stateObject

Returns the value of attribute state.



38
39
40
# File 'lib/eway_rapid/models/internal_models.rb', line 38

def state
  @state
end

#street1Object

Returns the value of attribute street1.



35
36
37
# File 'lib/eway_rapid/models/internal_models.rb', line 35

def street1
  @street1
end

#street2Object

Returns the value of attribute street2.



36
37
38
# File 'lib/eway_rapid/models/internal_models.rb', line 36

def street2
  @street2
end

#titleObject

Returns the value of attribute title.



30
31
32
# File 'lib/eway_rapid/models/internal_models.rb', line 30

def title
  @title
end

#token_customer_idObject

Returns the value of attribute token_customer_id.



28
29
30
# File 'lib/eway_rapid/models/internal_models.rb', line 28

def token_customer_id
  @token_customer_id
end

#urlObject

Returns the value of attribute url.



46
47
48
# File 'lib/eway_rapid/models/internal_models.rb', line 46

def url
  @url
end

Class Method Details

.from_array(array) ⇒ Object



134
135
136
137
138
139
140
141
142
143
# File 'lib/eway_rapid/models/internal_models.rb', line 134

def self.from_array(array)
  options = []
  if array
    array.each {|option_hash|
      obj = Customer.from_hash(option_hash)
      options.push(obj)
    }
  end
  options
end

.from_hash(hash) ⇒ Object



100
101
102
103
104
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
132
# File 'lib/eway_rapid/models/internal_models.rb', line 100

def self.from_hash(hash)
  customer = Customer.new
  customer.token_customer_id = hash[Constants::TOKEN_CUSTOMER_ID]
  customer.reference = hash[Constants::REFERENCE]
  customer.title = hash[Constants::TITLE]
  customer.first_name = hash[Constants::FIRST_NAME]
  customer.last_name = hash[Constants::LAST_NAME]
  customer.company_name = hash[Constants::COMPANY_NAME]
  customer.job_description = hash[Constants::JOB_DESCRIPTION]
  customer.street1 = hash[Constants::STREET1]
  customer.street2 = hash[Constants::STREET2]
  customer.city = hash[Constants::CITY]
  customer.state = hash[Constants::STATE]
  customer.postal_code = hash[Constants::POSTAL_CODE]
  customer.country = hash[Constants::COUNTRY]
  customer.email = hash[Constants::EMAIL]
  customer.phone = hash[Constants::PHONE]
  customer.mobile = hash[Constants::MOBILE]
  customer.comments = hash[Constants::COMMENTS]
  customer.fax = hash[Constants::FAX]
  customer.url = hash[Constants::URL]
  customer.card_number = hash[Constants::CARD_NUMBER]
  customer.card_start_month = hash[Constants::CARD_START_MONTH]
  customer.card_start_year = hash[Constants::CARD_START_YEAR]
  customer.card_issue_number = hash[Constants::CARD_ISSUE_NUMBER]
  customer.card_name = hash[Constants::CARD_NAME]
  customer.card_expiry_month = hash[Constants::CARD_EXPIRY_MONTH]
  customer.card_expiry_year = hash[Constants::CARD_EXPIRY_YEAR]
  customer.is_active = hash[Constants::IS_ACTIVE]
  customer.card_details = Models::CardDetails.from_hash(hash[Constants::CARD_DETAILS])
  customer.customer_device_ip = hash[Constants::CUSTOMER_DEVICE_IP]
  customer
end

.from_json(json) ⇒ Object



95
96
97
98
# File 'lib/eway_rapid/models/internal_models.rb', line 95

def self.from_json(json)
  hash = JSON.parse(json)
  from_hash(hash)
end

.to_hash(customer) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/eway_rapid/models/internal_models.rb', line 58

def self.to_hash(customer)
  hash = {}
  if customer
    hash[Constants::TOKEN_CUSTOMER_ID] = customer.token_customer_id if customer.token_customer_id
    hash[Constants::REFERENCE] = customer.reference if customer.reference
    hash[Constants::TITLE] = customer.title if customer.title
    hash[Constants::FIRST_NAME] = customer.first_name if customer.first_name
    hash[Constants::LAST_NAME] = customer.last_name if customer.last_name
    hash[Constants::COMPANY_NAME] = customer.company_name if customer.company_name
    hash[Constants::JOB_DESCRIPTION] = customer.job_description if customer.job_description
    hash[Constants::STREET1] = customer.street1 if customer.street1
    hash[Constants::STREET2] = customer.street2 if customer.street2
    hash[Constants::CITY] = customer.city if customer.city
    hash[Constants::STATE] = customer.state if customer.state
    hash[Constants::POSTAL_CODE] = customer.postal_code if customer.postal_code
    hash[Constants::COUNTRY] = customer.country if customer.country
    hash[Constants::EMAIL] = customer.email if customer.email
    hash[Constants::PHONE] = customer.phone if customer.phone
    hash[Constants::MOBILE] = customer.mobile if customer.mobile
    hash[Constants::COMMENTS] = customer.comments if customer.comments
    hash[Constants::FAX] = customer.fax if customer.fax
    hash[Constants::URL] = customer.url if customer.url
    hash[Constants::CARD_DETAILS] = Models::CardDetails.to_hash(customer.card_details) if Models::CardDetails.to_hash(customer.card_details)
    hash[Constants::IS_ACTIVE] = customer.is_active if customer.is_active

    hash[Constants::CARD_NUMBER] = customer.card_number if customer.card_number
    hash[Constants::CARD_START_MONTH] = customer.card_start_month if customer.card_start_month
    hash[Constants::CARD_START_YEAR] = customer.card_start_year if customer.card_start_year
    hash[Constants::CARD_ISSUE_NUMBER] = customer.card_issue_number if customer.card_issue_number
    hash[Constants::CARD_NAME] = customer.card_name if customer.card_name
    hash[Constants::CARD_EXPIRY_MONTH] = customer.card_expiry_month if customer.card_expiry_month
    hash[Constants::CARD_EXPIRY_YEAR] = customer.card_expiry_year if customer.card_expiry_year
    hash[Constants::CUSTOMER_DEVICE_IP] = customer.customer_device_ip if customer.customer_device_ip
  end
  hash
end