Class: SpreeCmCommissioner::Integrations::Larryta::Resources::BookingTransaction

Inherits:
Base
  • Object
show all
Defined in:
app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb

Overview

Represents a booking transaction from Larryta’s check_transaction API Contains comprehensive booking information including customer, pricing, and route details

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

from_api_response

Constructor Details

#initialize(data) ⇒ BookingTransaction

rubocop:disable Lint/MissingSuper,Metrics/AbcSize,Metrics/MethodLength



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 37

def initialize(data) # rubocop:disable Lint/MissingSuper,Metrics/AbcSize,Metrics/MethodLength
  @session_token = data['session_token']
  @booking_code = data['booking_code']
  @unit_price = data['unit_price']
  @payment_type = data['payment_type']
  @customer_id = data['customer_id']
  @payment_id = data['payment_id']
  @direction_id = data['direction_id']
  @booking_date = data['booking_date']
  @departure_date = data['departure_date']
  @pay_date = data['pay_date']
  @remark = data['remark']
  @change_num = data['change_num']
  @seat_nums = data['seat_nums']
  @total_seat = data['total_seat']
  @total_amount = data['total_amount']
  @total_discount = data['total_discount']
  @total_commission = data['total_commission']
  @total_bonus = data['total_bonus']
  @total_net_price = data['total_net_price']
  @total_fee_charge = data['total_fee_charge']
  @reseller_by = data['reseller_by']
  @release_by = data['release_by']
  @status = data['status']
  @msg = data['msg']

  # Customer info
  customer = data['customer'] || {}
  @customer_full_name = customer['full_name']
  @customer_phone = customer['phone']
  @customer_email = customer['email']
  @customer_country_code = customer['country_code']
  @customer_total_ending_point = customer['total_ending_point']

  # Booking by info
  booking_by = data['booking_by'] || {}
  @booking_by_account_name = booking_by['account_name']
  @booking_by_user_branch = booking_by['user_branch']
  @booking_by_contact_name = booking_by['contact_name']
  @booking_by_contact_phone = booking_by['contact_phone']
  @booking_by_contact_email = booking_by['contact_email']
  @booking_by_user_permission = booking_by['user_permission']
  @booking_by_user_location = booking_by['user_location']

  # Reseller info
  reseller = data['reseller'] || {}
  @reseller_account_name = reseller['account_name']
  @reseller_user_branch = reseller['user_branch']
  @reseller_contact_name = reseller['contact_name']
  @reseller_contact_phone = reseller['contact_phone']
  @reseller_contact_email = reseller['contact_email']
  @reseller_user_permission = reseller['user_permission']
  @reseller_user_location = reseller['user_location']

  # Release info
  release = data['release'] || {}
  @release_account_name = release['account_name']
  @release_user_branch = release['user_branch']
  @release_contact_name = release['contact_name']
  @release_contact_phone = release['contact_phone']
  @release_contact_email = release['contact_email']
  @release_user_permission = release['user_permission']
  @release_user_location = release['user_location']

  # Direction info
  direction = data['direction'] || {}
  @travel_time = direction['travel_time']
  @dire_code = direction['dire_code']
  @dire_remark = direction['dire_remark']

  # From location
  from_location = direction['from_location'] || {}
  @from_location_id = from_location['location_id']
  @from_location_name = from_location['loca_name']
  @from_location_name_kh = from_location['loca_name_kh']
  @from_location_code = from_location['loca_code']

  # To location
  to_location = direction['to_location'] || {}
  @to_location_id = to_location['location_id']
  @to_location_name = to_location['loca_name']
  @to_location_name_kh = to_location['loca_name_kh']
  @to_location_code = to_location['loca_code']
end

Instance Attribute Details

#booking_by_account_nameObject

Booking by info



17
18
19
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 17

def 
  @booking_by_account_name
end

#booking_by_contact_emailObject

Booking by info



17
18
19
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 17

def booking_by_contact_email
  @booking_by_contact_email
end

#booking_by_contact_nameObject

Booking by info



17
18
19
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 17

def booking_by_contact_name
  @booking_by_contact_name
end

#booking_by_contact_phoneObject

Booking by info



17
18
19
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 17

def booking_by_contact_phone
  @booking_by_contact_phone
end

#booking_by_user_branchObject

Booking by info



17
18
19
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 17

def booking_by_user_branch
  @booking_by_user_branch
end

#booking_by_user_locationObject

Booking by info



17
18
19
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 17

def booking_by_user_location
  @booking_by_user_location
end

#booking_by_user_permissionObject

Booking by info



17
18
19
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 17

def booking_by_user_permission
  @booking_by_user_permission
end

#booking_codeObject

Returns the value of attribute booking_code.



7
8
9
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 7

def booking_code
  @booking_code
end

#booking_dateObject

Returns the value of attribute booking_date.



7
8
9
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 7

def booking_date
  @booking_date
end

#change_numObject

Returns the value of attribute change_num.



7
8
9
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 7

def change_num
  @change_num
end

#customer_country_codeObject

Customer info



13
14
15
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 13

def customer_country_code
  @customer_country_code
end

#customer_emailObject

Customer info



13
14
15
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 13

def customer_email
  @customer_email
end

#customer_full_nameObject

Customer info



13
14
15
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 13

def customer_full_name
  @customer_full_name
end

#customer_idObject

Returns the value of attribute customer_id.



7
8
9
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 7

def customer_id
  @customer_id
end

#customer_phoneObject

Customer info



13
14
15
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 13

def customer_phone
  @customer_phone
end

#customer_total_ending_pointObject

Customer info



13
14
15
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 13

def customer_total_ending_point
  @customer_total_ending_point
end

#departure_dateObject

Returns the value of attribute departure_date.



7
8
9
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 7

def departure_date
  @departure_date
end

#dire_codeObject

Direction info



32
33
34
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 32

def dire_code
  @dire_code
end

#dire_remarkObject

Direction info



32
33
34
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 32

def dire_remark
  @dire_remark
end

#direction_idObject

Returns the value of attribute direction_id.



7
8
9
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 7

def direction_id
  @direction_id
end

#from_location_codeObject

Location info



35
36
37
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 35

def from_location_code
  @from_location_code
end

#from_location_idObject

Location info



35
36
37
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 35

def from_location_id
  @from_location_id
end

#from_location_nameObject

Location info



35
36
37
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 35

def from_location_name
  @from_location_name
end

#from_location_name_khObject

Location info



35
36
37
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 35

def from_location_name_kh
  @from_location_name_kh
end

#msgObject

Returns the value of attribute msg.



7
8
9
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 7

def msg
  @msg
end

#pay_dateObject

Returns the value of attribute pay_date.



7
8
9
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 7

def pay_date
  @pay_date
end

#payment_idObject

Returns the value of attribute payment_id.



7
8
9
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 7

def payment_id
  @payment_id
end

#payment_typeObject

Returns the value of attribute payment_type.



7
8
9
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 7

def payment_type
  @payment_type
end

#release_account_nameObject

Release info



27
28
29
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 27

def 
  @release_account_name
end

#release_byObject

Returns the value of attribute release_by.



7
8
9
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 7

def release_by
  @release_by
end

#release_contact_emailObject

Release info



27
28
29
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 27

def release_contact_email
  @release_contact_email
end

#release_contact_nameObject

Release info



27
28
29
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 27

def release_contact_name
  @release_contact_name
end

#release_contact_phoneObject

Release info



27
28
29
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 27

def release_contact_phone
  @release_contact_phone
end

#release_user_branchObject

Release info



27
28
29
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 27

def release_user_branch
  @release_user_branch
end

#release_user_locationObject

Release info



27
28
29
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 27

def release_user_location
  @release_user_location
end

#release_user_permissionObject

Release info



27
28
29
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 27

def release_user_permission
  @release_user_permission
end

#remarkObject

Returns the value of attribute remark.



7
8
9
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 7

def remark
  @remark
end

#reseller_account_nameObject

Reseller info



22
23
24
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 22

def 
  @reseller_account_name
end

#reseller_byObject

Returns the value of attribute reseller_by.



7
8
9
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 7

def reseller_by
  @reseller_by
end

#reseller_contact_emailObject

Reseller info



22
23
24
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 22

def reseller_contact_email
  @reseller_contact_email
end

#reseller_contact_nameObject

Reseller info



22
23
24
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 22

def reseller_contact_name
  @reseller_contact_name
end

#reseller_contact_phoneObject

Reseller info



22
23
24
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 22

def reseller_contact_phone
  @reseller_contact_phone
end

#reseller_user_branchObject

Reseller info



22
23
24
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 22

def reseller_user_branch
  @reseller_user_branch
end

#reseller_user_locationObject

Reseller info



22
23
24
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 22

def reseller_user_location
  @reseller_user_location
end

#reseller_user_permissionObject

Reseller info



22
23
24
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 22

def reseller_user_permission
  @reseller_user_permission
end

#seat_numsObject

Returns the value of attribute seat_nums.



7
8
9
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 7

def seat_nums
  @seat_nums
end

#session_tokenObject

Returns the value of attribute session_token.



7
8
9
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 7

def session_token
  @session_token
end

#statusObject

Returns the value of attribute status.



7
8
9
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 7

def status
  @status
end

#to_location_codeObject

Returns the value of attribute to_location_code.



7
8
9
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 7

def to_location_code
  @to_location_code
end

#to_location_idObject

Returns the value of attribute to_location_id.



7
8
9
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 7

def to_location_id
  @to_location_id
end

#to_location_nameObject

Returns the value of attribute to_location_name.



7
8
9
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 7

def to_location_name
  @to_location_name
end

#to_location_name_khObject

Returns the value of attribute to_location_name_kh.



7
8
9
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 7

def to_location_name_kh
  @to_location_name_kh
end

#total_amountObject

Returns the value of attribute total_amount.



7
8
9
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 7

def total_amount
  @total_amount
end

#total_bonusObject

Returns the value of attribute total_bonus.



7
8
9
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 7

def total_bonus
  @total_bonus
end

#total_commissionObject

Returns the value of attribute total_commission.



7
8
9
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 7

def total_commission
  @total_commission
end

#total_discountObject

Returns the value of attribute total_discount.



7
8
9
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 7

def total_discount
  @total_discount
end

#total_fee_chargeObject

Returns the value of attribute total_fee_charge.



7
8
9
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 7

def total_fee_charge
  @total_fee_charge
end

#total_net_priceObject

Returns the value of attribute total_net_price.



7
8
9
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 7

def total_net_price
  @total_net_price
end

#total_seatObject

Returns the value of attribute total_seat.



7
8
9
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 7

def total_seat
  @total_seat
end

#travel_timeObject

Direction info



32
33
34
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 32

def travel_time
  @travel_time
end

#unit_priceObject

Returns the value of attribute unit_price.



7
8
9
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 7

def unit_price
  @unit_price
end

Instance Method Details

#idObject

Returns the booking ID



123
124
125
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 123

def id
  booking_code
end

#pricing_summaryObject

Returns pricing summary



138
139
140
141
142
143
144
145
146
147
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 138

def pricing_summary
  {
    unit_price: unit_price,
    total_amount: total_amount,
    total_discount: total_discount,
    total_commission: total_commission,
    total_net_price: total_net_price,
    currency: 'KHR'
  }
end

#seat_numbersObject

Returns the seat number as an array



133
134
135
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 133

def seat_numbers
  seat_nums.to_s.split(',').map(&:strip)
end

#success?Boolean

Returns true if the transaction was successful

Returns:

  • (Boolean)


128
129
130
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 128

def success?
  status == true
end

#to_hObject

Returns a hash representation



150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/booking_transaction.rb', line 150

def to_h # rubocop:disable Metrics/AbcSize
  {
    id: id,
    session_token: session_token,
    booking_code: booking_code,
    unit_price: unit_price,
    payment_type: payment_type,
    customer_id: customer_id,
    payment_id: payment_id,
    direction_id: direction_id,
    booking_date: booking_date,
    departure_date: departure_date,
    pay_date: pay_date,
    remark: remark,
    seat_nums: seat_nums,
    seat_numbers: seat_numbers,
    total_seat: total_seat,
    total_amount: total_amount,
    total_discount: total_discount,
    total_commission: total_commission,
    total_bonus: total_bonus,
    total_net_price: total_net_price,
    total_fee_charge: total_fee_charge,
    reseller_by: reseller_by,
    release_by: release_by,
    status: status,
    success: success?,
    message: msg,
    pricing: pricing_summary,
    customer: {
      full_name: customer_full_name,
      phone: customer_phone,
      email: customer_email,
      country_code: customer_country_code,
      total_ending_point: customer_total_ending_point
    },
    booking_by: {
      account_name: ,
      user_branch: booking_by_user_branch,
      contact_name: booking_by_contact_name,
      contact_phone: booking_by_contact_phone,
      contact_email: booking_by_contact_email,
      user_permission: booking_by_user_permission,
      user_location: booking_by_user_location
    },
    reseller: {
      account_name: ,
      user_branch: reseller_user_branch,
      contact_name: reseller_contact_name,
      contact_phone: reseller_contact_phone,
      contact_email: reseller_contact_email,
      user_permission: reseller_user_permission,
      user_location: reseller_user_location
    },
    release: {
      account_name: ,
      user_branch: release_user_branch,
      contact_name: release_contact_name,
      contact_phone: release_contact_phone,
      contact_email: release_contact_email,
      user_permission: release_user_permission,
      user_location: release_user_location
    },
    direction: {
      direction_id: direction_id,
      from_location_id: from_location_id,
      to_location_id: to_location_id,
      travel_time: travel_time,
      dire_code: dire_code,
      dire_remark: dire_remark,
      from_location: {
        location_id: from_location_id,
        loca_name: from_location_name,
        loca_name_kh: from_location_name_kh,
        loca_code: from_location_code
      },
      to_location: {
        location_id: to_location_id,
        loca_name: to_location_name,
        loca_name_kh: to_location_name_kh,
        loca_code: to_location_code
      }
    }
  }
end