37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/stripe/cli/commands/coupons.rb', line 37
def create
unless options[:percent_off] || options[:amount_off]
discount = ask('(e.g. 25% or $10) specify discount:')
if discount.end_with?( '%' )
options[:percent_off] = discount.gsub(/[^\d]/,"").to_i
else
options[:amount_off] = discount.gsub(/[^\d]/,"").to_i
end
end
options[:id] ||= ask('Coupon ID:')
options[:duration] ||= ask('(`forever`,`once`, or `repeating`) duration:')
options[:duration_in_months] ||= ask('for how many months?') if options[:duration] == "repeating"
options[:redeem_by] ||= ask('expire on:')
if options[:redeem_by].empty?
options.delete(:redeem_by)
else
options[:redeem_by] = Chronic.parse(options[:redeem_by]).to_i.to_s
end
super Stripe::Coupon, options
end
|