stripe-cli 1.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5923ebb4d766facc1a20aa141bbb9b2fa4c20414
4
- data.tar.gz: ad96a4646bedecc024a25c32d7aa02a227621557
3
+ metadata.gz: 34d59db8c8b1fabf38d842025e35b450d4ee01ac
4
+ data.tar.gz: 70af264df94f2733a40b2d18ea9b54a34d90cdd1
5
5
  SHA512:
6
- metadata.gz: 7d1277e104b7f9c6dd41077715252cad28cc17f200773425167497a479a1609314142c8fd9aad06d156da384c43e5fb78b1938f3fdd4f93cf6193247687a2c43
7
- data.tar.gz: 2752a182355bde4ba24a4f782ecada84f5911802ff0578761465fcbfcb0976fdcc7e22a3dd5373b812ed2158ae5f9eec2853066ab8ce45382b9aae7094c65411
6
+ metadata.gz: 5ad46cf415dd29857dcd850411e86babe213146a4d130bb5c8ffd28015f277293eb0b478b459c849b2c2a212818eaa35936924e2107b8807e2bb618f18a8e068
7
+ data.tar.gz: f379088cb35aa572e378b0163fa1da2f4ad2d17050cf5c0a118e6a388e3316c11e0d1eb437cb83bef6eb8687893005374d1a1b71984cbcd4e4c2eef06e519677
data/README.md CHANGED
@@ -12,9 +12,9 @@ Note that all JSON-style epoch timestamps have been converted to **real life** D
12
12
 
13
13
  $ gem install stripe-cli
14
14
 
15
- Actually, the gem version is extremely stale right now. I hope to be able to update it soon. Until then, there are a couple of <strike>hacks</strike> options available.
16
15
 
17
- 1) clone the repo and build the gem locally yourself
16
+
17
+ you may also clone the repo and build the gem locally yourself
18
18
 
19
19
  $ git clone https://github.com/stripe-contrib/stripe-cli.git
20
20
  $ cd ./stripe-cli
@@ -24,14 +24,6 @@ Actually, the gem version is extremely stale right now. I hope to be able to up
24
24
  > because RubyGems looks **first** at the **current directory** before moving on to [rubygems.org](https://rubygems.org), that last step will install the local gem you just built.
25
25
 
26
26
 
27
- or
28
-
29
- 2) bundler can be used to automate this same procedure
30
-
31
- > in a Gemfile, write:
32
-
33
- gem 'stripe-cli', :git => 'git@github.com:stripe-contrib/stripe-cli.git'
34
-
35
27
 
36
28
  ## Configuration
37
29
 
@@ -39,28 +39,28 @@ module Stripe
39
39
  end
40
40
 
41
41
  def list klass, options
42
- Stripe.api_version = api_version unless api_version.nil?
43
- output klass.all( options, api_key )
42
+ request klass, :all, options, api_key
44
43
  end
45
44
 
46
45
  def find klass, id
47
- Stripe.api_version = api_version unless api_version.nil?
48
- output klass.retrieve( id, api_key )
46
+ request klass, :retrieve, id, api_key
49
47
  end
50
48
 
51
49
  def delete klass, id
52
- Stripe.api_version = api_version unless api_version.nil?
53
- output klass.new( id, api_key ).delete
50
+ request klass.new( id, api_key ), :delete
54
51
  end
55
52
 
56
53
  def create klass, options
57
- Stripe.api_version = api_version unless api_version.nil?
58
- output klass.create( options, api_key )
54
+ request klass, :create, options, api_key
59
55
  end
60
56
 
61
- def special klass, method, options
57
+ def request object, method, *arguments
62
58
  Stripe.api_version = api_version unless api_version.nil?
63
- output klass.new( options, api_key ).send( method )
59
+ begin
60
+ output object.send method, *arguments
61
+ rescue StripeError => e
62
+ output e.message
63
+ end
64
64
  end
65
65
 
66
66
  private
@@ -74,24 +74,24 @@ module Stripe
74
74
  when Array
75
75
  object.map {|o| inspect(o) }
76
76
  when Hash
77
- object.inject({}) do |hash, (key, value)|
78
- hash[key] = inspect( value )
79
- hash
80
- end
77
+ handle_hash object
81
78
  when Stripe::ListObject
82
79
  inspect object.data
83
80
  when Stripe::StripeObject
84
81
  inspect object.to_hash
85
82
  when Numeric
86
- if object > 1000000000
87
- Time.at object
88
- else
89
- object
90
- end
83
+ object > 1000000000 ? Time.at( object ) : object
91
84
  else
92
85
  object
93
86
  end
94
87
  end
88
+
89
+ def handle_hash object
90
+ object.inject({}) do |hash, (key, value)|
91
+ hash[key] = inspect( value )
92
+ hash
93
+ end
94
+ end
95
95
  end
96
96
  end
97
97
  end
@@ -4,7 +4,7 @@ module Stripe
4
4
  class Balance < Command
5
5
  desc "current", "show currently available and pending balance figures"
6
6
  def current
7
- output Stripe::Balance.retrieve(api_key)
7
+ request Stripe::Balance, :retrieve, api_key
8
8
  end
9
9
 
10
10
  default_command :current
@@ -16,13 +16,15 @@ module Stripe
16
16
  end
17
17
 
18
18
  desc "refund ID", "Refund a charge"
19
+ option :amount, :type => :numeric
19
20
  def refund charge_id
20
- special Stripe::Charge, :refund, charge_id
21
+ options[:amount] = (Float(options[:amount]) * 100).to_i
22
+ request Stripe::Charge.new(charge_id, api_key), :refund, options
21
23
  end
22
24
 
23
25
  desc "capture ID", "Capture a charge"
24
26
  def capture charge_id
25
- special Stripe::Charge, :capture, charge_id
27
+ request Stripe::Charge.new(charge_id, api_key), :capture
26
28
  end
27
29
 
28
30
  desc "create", "Create a charge"
@@ -36,11 +36,14 @@ module Stripe
36
36
  option :card_name
37
37
 
38
38
  def create
39
- say('All of the following are OPTIONAL parameters...')
40
- options[:email] ||= ask('Customer\'s Email:')
39
+ options[:email] ||= ask('Customer\'s Email:')
41
40
  options[:description] ||= ask('Provide a description:')
42
- options[:plan] ||= ask('Assign a plan:')
43
- options[:coupon] ||= ask('Apply a coupon:')
41
+ options[:plan] ||= ask('Assign a plan:')
42
+ if options[:plan] == ""
43
+ options.delete :plan
44
+ else
45
+ options[:coupon] ||= ask('Apply a coupon:')
46
+ end
44
47
 
45
48
  if options[:plan]
46
49
  options[:card_name] ||= ask('Name on Card:')
@@ -18,17 +18,17 @@ module Stripe
18
18
 
19
19
  desc "close ID", "close an unpaid invoice"
20
20
  def close invoice_id
21
- special Stripe::Invoice, :close, invoice_id
21
+ request Stripe::Invoice.new(invoice_id, api_key), :close
22
22
  end
23
23
 
24
24
  desc "pay ID", "trigger an open invoice to be paid immediately"
25
25
  def pay invoice_id
26
- special Stripe::Invoice, :pay, invoice_id
26
+ request Stripe::Invoice.new(invoice_id, api_key), :pay
27
27
  end
28
28
 
29
29
  desc "upcoming CUSTOMER", "find the upcoming invoice for CUSTOMER"
30
30
  def upcoming customer_id
31
- special Stripe::Invoice, :upcoming, {:customer => customer_id}
31
+ request Stripe::Invoice, :upcoming, {:customer => customer_id}, api_key
32
32
  end
33
33
  end
34
34
  end
@@ -39,7 +39,7 @@ module Stripe
39
39
  options[:email] ||= ask('Recipient\'s Email:')
40
40
  options[:type] ||= if options.delete(:individual) then 'individual'
41
41
  elsif options.delete(:corporation) then 'corporation'
42
- else ask('Corporation? (Y/n)').downcase.start_with?('y') ? 'corporation' : 'individual'
42
+ else yes?('Corporation? (Y/n)') ? 'corporation' : 'individual'
43
43
  end
44
44
  options[:tax_id] ||= case options[:type]
45
45
  when 'individual' then ask('Tax ID (SSN):')
@@ -1,5 +1,5 @@
1
1
  module Stripe
2
2
  module CLI
3
- VERSION = "1.0.2"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stripe-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex MacCaw
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-10-01 00:00:00.000000000 Z
12
+ date: 2013-10-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler