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
|
2019-06-12 12:22:38 +02:00
|
|
|
attr_accessor :user_id, :operator_profile_id
|
2019-04-25 15:09:37 +02:00
|
|
|
|
2019-06-12 12:22:38 +02:00
|
|
|
def initialize(user_id, operator_profile_id)
|
2019-04-25 15:09:37 +02:00
|
|
|
@user_id = user_id
|
2019-06-12 12:22:38 +02:00
|
|
|
@operator_profile_id = operator_profile_id
|
2019-04-25 15:09:37 +02:00
|
|
|
end
|
2018-12-11 15:07:21 +01:00
|
|
|
|
2020-05-06 12:43:47 +02:00
|
|
|
def pay_and_save(reservation, payment_details: nil, payment_intent_id: nil)
|
2019-06-06 16:34:53 +02:00
|
|
|
reservation.statistic_profile_id = StatisticProfile.find_by(user_id: user_id).id
|
2020-05-06 12:43:47 +02:00
|
|
|
reservation.save_with_payment(operator_profile_id, payment_details, payment_intent_id)
|
2018-12-11 15:07:21 +01:00
|
|
|
end
|
2019-03-18 11:11:09 +01:00
|
|
|
end
|