Class: SpreeCmCommissioner::Integrations::VireakBuntham::Resources::BookingTransaction
- Inherits:
-
Base
- Object
- Base
- SpreeCmCommissioner::Integrations::VireakBuntham::Resources::BookingTransaction
- Defined in:
- app/services/spree_cm_commissioner/integrations/vireak_buntham/resources/booking_transaction.rb
Overview
Wraps POST /booking/checkTransaction response.
Response body shape:
{ "transactionId": "VTCK-...", "transactionDate": "2026-05-15",
"totalAmount": "17.000", "totalLuckyTicket": "0.000",
"status": 1, "ticket": [...] }
status: 1 = confirmed, 2 = used/traveled
Instance Attribute Summary collapse
-
#result ⇒ Object
Returns the value of attribute result.
-
#status ⇒ Object
Returns the value of attribute status.
-
#status_code ⇒ Object
Returns the value of attribute status_code.
-
#tickets ⇒ Object
Returns the value of attribute tickets.
-
#total_amount ⇒ Object
Returns the value of attribute total_amount.
-
#total_lucky_ticket ⇒ Object
Returns the value of attribute total_lucky_ticket.
-
#transaction_date ⇒ Object
Returns the value of attribute transaction_date.
-
#transaction_id ⇒ Object
Returns the value of attribute transaction_id.
Instance Method Summary collapse
- #confirmed? ⇒ Boolean
-
#initialize(data) ⇒ BookingTransaction
constructor
rubocop:disable Lint/MissingSuper.
- #success? ⇒ Boolean
- #to_h ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(data) ⇒ BookingTransaction
rubocop:disable Lint/MissingSuper
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/services/spree_cm_commissioner/integrations/vireak_buntham/resources/booking_transaction.rb', line 14 def initialize(data) # rubocop:disable Lint/MissingSuper header = data['header'] || {} @status_code = header['statusCode'].to_i @result = header['result'] @transaction_id = data['transactionId'] @transaction_date = data['transactionDate'] @total_amount = data['totalAmount'] @total_lucky_ticket = data['totalLuckyTicket'] @status = data['status'].to_i @tickets = Array(data['ticket']) end |
Instance Attribute Details
#result ⇒ Object
Returns the value of attribute result.
11 12 13 |
# File 'app/services/spree_cm_commissioner/integrations/vireak_buntham/resources/booking_transaction.rb', line 11 def result @result end |
#status ⇒ Object
Returns the value of attribute status.
11 12 13 |
# File 'app/services/spree_cm_commissioner/integrations/vireak_buntham/resources/booking_transaction.rb', line 11 def status @status end |
#status_code ⇒ Object
Returns the value of attribute status_code.
11 12 13 |
# File 'app/services/spree_cm_commissioner/integrations/vireak_buntham/resources/booking_transaction.rb', line 11 def status_code @status_code end |
#tickets ⇒ Object
Returns the value of attribute tickets.
11 12 13 |
# File 'app/services/spree_cm_commissioner/integrations/vireak_buntham/resources/booking_transaction.rb', line 11 def tickets @tickets end |
#total_amount ⇒ Object
Returns the value of attribute total_amount.
11 12 13 |
# File 'app/services/spree_cm_commissioner/integrations/vireak_buntham/resources/booking_transaction.rb', line 11 def total_amount @total_amount end |
#total_lucky_ticket ⇒ Object
Returns the value of attribute total_lucky_ticket.
11 12 13 |
# File 'app/services/spree_cm_commissioner/integrations/vireak_buntham/resources/booking_transaction.rb', line 11 def total_lucky_ticket @total_lucky_ticket end |
#transaction_date ⇒ Object
Returns the value of attribute transaction_date.
11 12 13 |
# File 'app/services/spree_cm_commissioner/integrations/vireak_buntham/resources/booking_transaction.rb', line 11 def transaction_date @transaction_date end |
#transaction_id ⇒ Object
Returns the value of attribute transaction_id.
11 12 13 |
# File 'app/services/spree_cm_commissioner/integrations/vireak_buntham/resources/booking_transaction.rb', line 11 def transaction_id @transaction_id end |
Instance Method Details
#confirmed? ⇒ Boolean
31 32 33 |
# File 'app/services/spree_cm_commissioner/integrations/vireak_buntham/resources/booking_transaction.rb', line 31 def confirmed? status == 1 end |
#success? ⇒ Boolean
27 28 29 |
# File 'app/services/spree_cm_commissioner/integrations/vireak_buntham/resources/booking_transaction.rb', line 27 def success? status_code == 200 && result == true end |
#to_h ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'app/services/spree_cm_commissioner/integrations/vireak_buntham/resources/booking_transaction.rb', line 35 def to_h { transaction_id: transaction_id, transaction_date: transaction_date, total_amount: total_amount, status: status, confirmed: confirmed?, tickets: tickets } end |