2021-09-07 20:11:50 +08:00
|
|
|
# frozen_string_literal: true
|
2021-09-24 17:58:42 +08:00
|
|
|
class CustomWizard::Subscription::Subscription
|
2021-08-10 14:45:23 +08:00
|
|
|
include ActiveModel::Serialization
|
|
|
|
|
|
|
|
attr_reader :type,
|
|
|
|
:updated_at
|
|
|
|
|
2021-09-01 10:19:00 +08:00
|
|
|
def initialize(subscription)
|
|
|
|
if subscription
|
|
|
|
@type = subscription.type
|
|
|
|
@updated_at = subscription.updated_at
|
2021-08-10 14:45:23 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-08-18 14:59:43 +08:00
|
|
|
def types
|
2021-10-14 13:41:24 +01:00
|
|
|
%w(none basic advanced)
|
2021-08-18 14:59:43 +08:00
|
|
|
end
|
|
|
|
|
2021-08-10 14:45:23 +08:00
|
|
|
def active?
|
2021-09-01 10:19:00 +08:00
|
|
|
types.include?(type) && updated_at.to_datetime > (Time.zone.now - 2.hours).to_datetime
|
2021-08-10 14:45:23 +08:00
|
|
|
end
|
2021-09-07 20:11:50 +08:00
|
|
|
end
|