jam-cloud/ruby/lib/jam_ruby/subscription_definitions.rb

107 lines
3.1 KiB
Ruby

module JamRuby
class SubscriptionDefinitions
JAM_SILVER = 'jamsubsilver'
JAM_SILVER_YEARLY = 'jamsubsilveryearly'
JAM_GOLD = 'jamsubgold'
JAM_GOLD_YEARLY = 'jamsubgoldyearly'
JAM_PLATINUM = 'jamsubplatinum'
JAM_PLATINUM_YEARLY = 'jamsubplatinumyearly'
# ALL IN HOURS
FREE_PLAY_TIME_PER_SESSION = 1
FREE_PLAY_TIME_PER_MONTH = 4
SILVER_PLAY_TIME_PER_SESSION = nil # unlimited
SILVER_PLAY_TIME_PER_MONTH = 10
GOLD_PLAY_TIME_PER_SESSION = nil # unlimited
GOLD_PLAY_TIME_PER_MONTH = nil # unlimited
PLATINUM_PLAY_TIME_PER_SESSION = nil # unlimited
PLATINUM_PLAY_TIME_PER_MONTH = nil # unlimited
MONTHLY_PLANS = [
nil,
JAM_SILVER,
JAM_GOLD,
JAM_PLATINUM
]
FREE_PLAN = {
play_time_per_month: FREE_PLAY_TIME_PER_MONTH,
play_time_per_session: FREE_PLAY_TIME_PER_SESSION,
can_record_audio: false,
can_use_video: false,
can_record_video: false,
can_record_wave: false,
video_resolution: 1,
audio_max_bitrate: 1, # 128
can_broadcast: false,
broadcasting_type: 3,
max_players: 4,
pro_audio: false,
name: 'Free'
}
SILVER_PLAN = {
play_time_per_month: SILVER_PLAY_TIME_PER_MONTH,
play_time_per_session: SILVER_PLAY_TIME_PER_SESSION,
can_record_audio: false,
can_record_video: false,
can_use_video: true,
can_record_wave: true,
video_resolution: 1, # CIF in the backend
audio_max_bitrate: 2, #192
can_broadcast: true,
broadcasting_type: 3,
max_players: 6,
pro_audio: false,
name: 'Silver'
}
GOLD_PLAN = {
play_time_per_month: GOLD_PLAY_TIME_PER_MONTH,
play_time_per_session: GOLD_PLAY_TIME_PER_SESSION,
can_record_audio: true,
can_record_video: true,
can_use_video: true,
can_record_wave: true,
video_resolution: 3, # 720p in the backend
audio_max_bitrate: 3, #256
can_broadcast: true,
broadcasting_type: 3,
max_players: nil,
pro_audio: true,
name: 'Gold'
}
PLATINUM_PLAN = {
play_time_per_month: PLATINUM_PLAY_TIME_PER_MONTH,
play_time_per_session: PLATINUM_PLAY_TIME_PER_SESSION,
can_record_audio: true,
can_record_video: true,
can_use_video: true,
can_record_wave: true,
video_resolution: 4, # 1080p in the backend
audio_max_bitrate: 5, #512
can_broadcast: true,
broadcasting_type: 3,
max_players: nil,
pro_audio: true,
name: 'Platinum'
}
def self.rules(plan_code)
if plan_code == nil
FREE_PLAN
elsif plan_code == JAM_SILVER || plan_code == JAM_SILVER_YEARLY
SILVER_PLAN
elsif plan_code == JAM_GOLD || plan_code == JAM_GOLD_YEARLY
GOLD_PLAN
elsif plan_code == JAM_PLATINUM || plan_code == JAM_PLATINUM_YEARLY
PLATINUM_PLAN
else
raise "unknown plan #{plan_code}"
end
end
end
end