Class: Stripe::CLI::Commands::Subscriptions

Inherits:
Stripe::CLI::Command show all
Includes:
Utils
Defined in:
lib/stripe/cli/commands/subscriptions.rb

Instance Method Summary collapse

Methods inherited from Stripe::CLI::Command

#inspect

Instance Method Details

#cancel(subscription_id) ⇒ Object



57
58
59
60
61
62
63
# File 'lib/stripe/cli/commands/subscriptions.rb', line 57

def cancel subscription_id
  options[:at_period_end] ||= yes?("delay until end of current period? [yN]",:yellow)
  if cust = retrieve_customer(options.delete :customer) and
    subscription = retrieve_subscription(cust, subscription_id)
      request subscription, :delete, options
  end
end

#createObject



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/stripe/cli/commands/subscriptions.rb', line 41

def create
  options[:plan]      ||= ask('Assign a plan:')
  options.delete( :plan ) if options[:plan] == ""
  options[:coupon]    ||= ask('Apply a coupon:')
  options.delete( :coupon ) if options[:coupon] == ""
  options[:card]      ||= credit_card( options ) if yes?("add a new credit card? [yN]",:yellow)
  options[:trial_end] = Chronic.parse(options[:trial_end]).to_i.to_s if options[:trial_end]
  if cust = retrieve_customer(options.delete :customer)
    super cust.subscriptions, options
  end
end

#find(subscription_id) ⇒ Object



23
24
25
26
27
# File 'lib/stripe/cli/commands/subscriptions.rb', line 23

def find subscription_id
  if cust = retrieve_customer(options.delete :customer)
    super cust.subscriptions, subscription_id
  end
end

#listObject



15
16
17
18
19
# File 'lib/stripe/cli/commands/subscriptions.rb', line 15

def list
  if cust = retrieve_customer(options.delete :customer)
    super cust.subscriptions, options
  end
end

#reactivate(subscription_id) ⇒ Object



67
68
69
70
71
72
# File 'lib/stripe/cli/commands/subscriptions.rb', line 67

def reactivate subscription_id
  if cust = retrieve_customer(options.delete :customer) and
    subscription = retrieve_subscription(cust, subscription_id)
      request subscription, :save
  end
end