2019-04-25 15:09:37 +02:00
|
|
|
# frozen_string_literal: true
|
2018-12-11 15:07:21 +01:00
|
|
|
|
2019-04-25 15:09:37 +02:00
|
|
|
# Provides helper methods for Reservation actions
|
|
|
|
class Reservations::Reserve
|
|
|
|
attr_accessor :user_id, :operator_id
|
|
|
|
|
|
|
|
def initialize(user_id, operator_id)
|
|
|
|
@user_id = user_id
|
|
|
|
@operator_id = operator_id
|
|
|
|
end
|
2018-12-11 15:07:21 +01:00
|
|
|
|
2019-04-25 15:09:37 +02:00
|
|
|
def pay_and_save(reservation, payment_method, coupon)
|
2019-06-04 16:50:23 +02:00
|
|
|
reservation.statistic_profile_id = User.find(user_id).statistic_profile.id
|
2019-04-25 15:09:37 +02:00
|
|
|
if payment_method == :local
|
|
|
|
reservation.save_with_local_payment(operator_id, coupon)
|
|
|
|
elsif payment_method == :stripe
|
|
|
|
reservation.save_with_payment(operator_id, coupon)
|
2018-12-11 15:07:21 +01:00
|
|
|
end
|
|
|
|
end
|
2019-03-18 11:11:09 +01:00
|
|
|
end
|