mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-11-29 10:24:20 +01:00
improved ruby syntax to match coding rules in some services
This commit is contained in:
parent
21c7484396
commit
4dfe02bebf
@ -1,19 +1,20 @@
|
|||||||
module Reservations
|
# frozen_string_literal: true
|
||||||
class Reserve
|
|
||||||
attr_accessor :user_id, :operator_id
|
|
||||||
|
|
||||||
def initialize(user_id, operator_id)
|
# Provides helper methods for Reservation actions
|
||||||
@user_id = user_id
|
class Reservations::Reserve
|
||||||
@operator_id = operator_id
|
attr_accessor :user_id, :operator_id
|
||||||
end
|
|
||||||
|
|
||||||
def pay_and_save(reservation, payment_method, coupon)
|
def initialize(user_id, operator_id)
|
||||||
reservation.user_id = user_id
|
@user_id = user_id
|
||||||
if payment_method == :local
|
@operator_id = operator_id
|
||||||
reservation.save_with_local_payment(operator_id, coupon)
|
end
|
||||||
elsif payment_method == :stripe
|
|
||||||
reservation.save_with_payment(operator_id, coupon)
|
def pay_and_save(reservation, payment_method, coupon)
|
||||||
end
|
reservation.user_id = user_id
|
||||||
|
if payment_method == :local
|
||||||
|
reservation.save_with_local_payment(operator_id, coupon)
|
||||||
|
elsif payment_method == :stripe
|
||||||
|
reservation.save_with_payment(operator_id, coupon)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,34 +1,35 @@
|
|||||||
module Subscriptions
|
# frozen_string_literal: true
|
||||||
class Subscribe
|
|
||||||
attr_accessor :user_id, :operator_id
|
|
||||||
|
|
||||||
def initialize(user_id, operator_id)
|
# Provides helper methods for Subscription actions
|
||||||
@user_id = user_id
|
class Subscriptions::Subscribe
|
||||||
@operator_id = operator_id
|
attr_accessor :user_id, :operator_id
|
||||||
end
|
|
||||||
|
|
||||||
def pay_and_save(subscription, payment_method, coupon, invoice)
|
def initialize(user_id, operator_id)
|
||||||
subscription.user_id = user_id
|
@user_id = user_id
|
||||||
if payment_method == :local
|
@operator_id = operator_id
|
||||||
subscription.save_with_local_payment(operator_id, invoice, coupon)
|
end
|
||||||
elsif payment_method == :stripe
|
|
||||||
subscription.save_with_payment(operator_id, invoice, coupon)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def extend_subscription(subscription, new_expiration_date, free_days)
|
def pay_and_save(subscription, payment_method, coupon, invoice)
|
||||||
return subscription.free_extend(new_expiration_date) if free_days
|
subscription.user_id = user_id
|
||||||
|
if payment_method == :local
|
||||||
new_sub = Subscription.create(
|
subscription.save_with_local_payment(operator_id, invoice, coupon)
|
||||||
plan_id: subscription.plan_id,
|
elsif payment_method == :stripe
|
||||||
user_id: subscription.user_id,
|
subscription.save_with_payment(operator_id, invoice, coupon)
|
||||||
expiration_date: new_expiration_date
|
|
||||||
)
|
|
||||||
if new_sub.save
|
|
||||||
new_sub.user.generate_subscription_invoice(operator_id)
|
|
||||||
return new_sub
|
|
||||||
end
|
|
||||||
false
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def extend_subscription(subscription, new_expiration_date, free_days)
|
||||||
|
return subscription.free_extend(new_expiration_date) if free_days
|
||||||
|
|
||||||
|
new_sub = Subscription.create(
|
||||||
|
plan_id: subscription.plan_id,
|
||||||
|
user_id: subscription.user_id,
|
||||||
|
expiration_date: new_expiration_date
|
||||||
|
)
|
||||||
|
if new_sub.save
|
||||||
|
new_sub.user.generate_subscription_invoice(operator_id)
|
||||||
|
return new_sub
|
||||||
|
end
|
||||||
|
false
|
||||||
|
end
|
||||||
end
|
end
|
Loading…
Reference in New Issue
Block a user