Class: Afterpay::Consumer
- Inherits:
-
Object
- Object
- Afterpay::Consumer
- Defined in:
- lib/afterpay/consumer.rb
Instance Attribute Summary collapse
-
#email ⇒ Object
Returns the value of attribute email.
-
#first_name ⇒ Object
Returns the value of attribute first_name.
-
#last_name ⇒ Object
Returns the value of attribute last_name.
-
#phone ⇒ Object
Returns the value of attribute phone.
Class Method Summary collapse
-
.from_response(response) ⇒ Object
Builds Consumer from response.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Consumer
constructor
A new instance of Consumer.
- #to_hash ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Consumer
Returns a new instance of Consumer.
7 8 9 10 11 12 |
# File 'lib/afterpay/consumer.rb', line 7 def initialize(attributes = {}) @email = attributes[:email] @phone = attributes[:phone] || "" @first_name = attributes[:first_name] || "" @last_name = attributes[:last_name] || "" end |
Instance Attribute Details
#email ⇒ Object
Returns the value of attribute email.
5 6 7 |
# File 'lib/afterpay/consumer.rb', line 5 def email @email end |
#first_name ⇒ Object
Returns the value of attribute first_name.
5 6 7 |
# File 'lib/afterpay/consumer.rb', line 5 def first_name @first_name end |
#last_name ⇒ Object
Returns the value of attribute last_name.
5 6 7 |
# File 'lib/afterpay/consumer.rb', line 5 def last_name @last_name end |
#phone ⇒ Object
Returns the value of attribute phone.
5 6 7 |
# File 'lib/afterpay/consumer.rb', line 5 def phone @phone end |
Class Method Details
.from_response(response) ⇒ Object
Builds Consumer from response
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/afterpay/consumer.rb', line 24 def self.from_response(response) return nil if response.nil? new( email: response[:email], first_name: response[:givenNames], last_name: response[:surname], phone: response[:phoneNumber] ) end |
Instance Method Details
#to_hash ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/afterpay/consumer.rb', line 14 def to_hash { phoneNumber: phone, givenNames: first_name, surname: last_name, email: email } end |