Class: SpreeCmCommissioner::Integrations::Larryta::Resources::Passenger
- Inherits:
-
Base
- Object
- Base
- SpreeCmCommissioner::Integrations::Larryta::Resources::Passenger
- Defined in:
- app/services/spree_cm_commissioner/integrations/larryta/resources/passenger.rb
Overview
Represents a passenger record from Larryta API
Instance Attribute Summary collapse
-
#customer_code ⇒ Object
Returns the value of attribute customer_code.
-
#customer_id ⇒ Object
Returns the value of attribute customer_id.
-
#msg ⇒ Object
Returns the value of attribute msg.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
-
#error_message ⇒ Object
Returns the error message if failed.
-
#failed? ⇒ Boolean
Returns true if passenger creation failed.
-
#id ⇒ Object
Returns the passenger ID.
-
#initialize(data) ⇒ Passenger
constructor
rubocop:disable Lint/MissingSuper.
-
#success? ⇒ Boolean
Returns true if the passenger was created successfully.
-
#to_h ⇒ Object
Returns a hash representation.
Methods inherited from Base
Constructor Details
#initialize(data) ⇒ Passenger
rubocop:disable Lint/MissingSuper
6 7 8 9 10 11 |
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/passenger.rb', line 6 def initialize(data) # rubocop:disable Lint/MissingSuper @customer_id = data['customer_id'] @customer_code = data['customer_code'] @status = data['status'] @msg = data['msg'] end |
Instance Attribute Details
#customer_code ⇒ Object
Returns the value of attribute customer_code.
4 5 6 |
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/passenger.rb', line 4 def customer_code @customer_code end |
#customer_id ⇒ Object
Returns the value of attribute customer_id.
4 5 6 |
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/passenger.rb', line 4 def customer_id @customer_id end |
#msg ⇒ Object
Returns the value of attribute msg.
4 5 6 |
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/passenger.rb', line 4 def msg @msg end |
#status ⇒ Object
Returns the value of attribute status.
4 5 6 |
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/passenger.rb', line 4 def status @status end |
Instance Method Details
#error_message ⇒ Object
Returns the error message if failed
29 30 31 32 33 |
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/passenger.rb', line 29 def return msg if failed? nil end |
#failed? ⇒ Boolean
Returns true if passenger creation failed
24 25 26 |
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/passenger.rb', line 24 def failed? !success? end |
#id ⇒ Object
Returns the passenger ID
14 15 16 |
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/passenger.rb', line 14 def id customer_id end |
#success? ⇒ Boolean
Returns true if the passenger was created successfully
19 20 21 |
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/passenger.rb', line 19 def success? status == true && customer_id.present? end |
#to_h ⇒ Object
Returns a hash representation
36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/passenger.rb', line 36 def to_h { id: id, customer_code: customer_code, success: success?, failed: failed?, error_message: , status: status, message: msg } end |