class MockChargebee::Services::CouponsForSubscription
Public Class Methods
new(coupon_ids)
click to toggle source
# File lib/mock_chargebee/services/apply_coupons.rb, line 6 def initialize(coupon_ids) @coupon_ids = coupon_ids end
Public Instance Methods
call()
click to toggle source
# File lib/mock_chargebee/services/apply_coupons.rb, line 10 def call return [] if coupon_ids.empty? coupons.map do |coupon| { "coupon_id" => coupon["id"], "apply_till" => apply_till_from(coupon), "applied_count" => 1, "coupon_code" => nil, } end end
Private Instance Methods
apply_till_from(coupon)
click to toggle source
# File lib/mock_chargebee/services/apply_coupons.rb, line 33 def apply_till_from(coupon) return nil unless coupon["duration_period"] == "limited_period" (Date.today >> coupon["duration_month"]).to_time.to_i end
coupon_ids()
click to toggle source
# File lib/mock_chargebee/services/apply_coupons.rb, line 25 def coupon_ids @coupon_ids || [] end
coupons()
click to toggle source
# File lib/mock_chargebee/services/apply_coupons.rb, line 29 def coupons coupon_ids.values.map { |id| Models::Coupon.find(id) } end