class Stripe::CLI::Commands::Coupons

Public Instance Methods

create() click to toggle source
Calls superclass method Stripe::CLI::Command#create
# 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
delete(coupon_id) click to toggle source
Calls superclass method Stripe::CLI::Command#delete
# File lib/stripe/cli/commands/coupons.rb, line 23
def delete coupon_id
  super Stripe::Coupon, coupon_id
end
find(coupon_id) click to toggle source
Calls superclass method Stripe::CLI::Command#find
# File lib/stripe/cli/commands/coupons.rb, line 18
def find coupon_id
  super Stripe::Coupon, coupon_id
end
list() click to toggle source
Calls superclass method Stripe::CLI::Command#list
# File lib/stripe/cli/commands/coupons.rb, line 13
def list
  super Stripe::Coupon, options
end