2018-12-11 15:07:21 +01:00
|
|
|
module Reservations
|
|
|
|
class Reserve
|
2019-03-18 11:11:09 +01:00
|
|
|
attr_accessor :user_id, :operator_id
|
2018-12-11 15:07:21 +01:00
|
|
|
|
2019-03-18 11:11:09 +01:00
|
|
|
def initialize(user_id, operator_id)
|
2018-12-11 15:07:21 +01:00
|
|
|
@user_id = user_id
|
2019-03-18 11:11:09 +01:00
|
|
|
@operator_id = operator_id
|
2018-12-11 15:07:21 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def pay_and_save(reservation, payment_method, coupon)
|
|
|
|
reservation.user_id = user_id
|
|
|
|
if payment_method == :local
|
2019-03-18 11:11:09 +01:00
|
|
|
reservation.save_with_local_payment(operator_id, coupon)
|
2018-12-11 15:07:21 +01:00
|
|
|
elsif payment_method == :stripe
|
2019-03-18 11:11:09 +01:00
|
|
|
reservation.save_with_payment(operator_id, coupon)
|
2018-12-11 15:07:21 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2019-03-18 11:11:09 +01:00
|
|
|
end
|