stripe-cli 1.1.0 → 1.1.1

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: 34d59db8c8b1fabf38d842025e35b450d4ee01ac
4
- data.tar.gz: 70af264df94f2733a40b2d18ea9b54a34d90cdd1
3
+ metadata.gz: e2b48859bb69cc6e13ce435be2dbab05b4161d11
4
+ data.tar.gz: ad88ef63c91fbef74e9b6b4ff0053c6db8c07942
5
5
  SHA512:
6
- metadata.gz: 5ad46cf415dd29857dcd850411e86babe213146a4d130bb5c8ffd28015f277293eb0b478b459c849b2c2a212818eaa35936924e2107b8807e2bb618f18a8e068
7
- data.tar.gz: f379088cb35aa572e378b0163fa1da2f4ad2d17050cf5c0a118e6a388e3316c11e0d1eb437cb83bef6eb8687893005374d1a1b71984cbcd4e4c2eef06e519677
6
+ metadata.gz: 84b1ed0a0bf293d4f12bdd3f87f8b66e6eb614b0b5b3de814c1e6d66cac7d818015ade39ff9557bcd0d950ab86a60bf2bbadd6b82c6e7e463ad7d4a51d11e6bd
7
+ data.tar.gz: b2194d88909c8c22e046da67ef9b02413fee8c3bd3c40cd453d92136b5db7a8595d0af29703e249126e9dd00a4db8c8944c6fda701cee32e18764067847991a3
data/README.md CHANGED
@@ -75,15 +75,15 @@ or
75
75
 
76
76
  ## uniform behavior
77
77
 
78
- The Stripe API is very consistant. Consistency makes using the api intuitive. This utility strives to maintain Stripe's consistency. Depending on which [C.R.U.D.](http://wikipedia.org/wiki/Create,_read,_update_and_delete) operation you are after, you can pretty much count on a few standard options to be available.
78
+ The Stripe API is very consistant. Consistency makes using the api intuitive. What makes an api consistant? For one, uniform parameters across api resources. Here are a few examples of uniform behavior within this utility.
79
79
 
80
- ### stripe (subcommand) list ...
80
+ #### list operations
81
81
 
82
82
  specify how many results, between 1 and 100, should be returned (default is 10)
83
83
 
84
84
  ... list [--count=COUNT]
85
85
 
86
- specify the starting index for this result set, relative to the entire result set (usefull in combination with `--count` for paginating results)
86
+ specify the starting index for this result set, relative to the entire result set (useful in combination with `--count` for paginating results)
87
87
 
88
88
  ... list [--offset=OFFSET]
89
89
 
@@ -97,6 +97,10 @@ or
97
97
  $ stripe charges create [--amount=AMOUNT]
98
98
  Name on Card: __
99
99
 
100
+ Api errors are rescued and their messages displayed for you to read easily. No more `barfing` to `stdout` ...hopefully
101
+
102
+ ![error rescue example](./error_message_display.png)
103
+
100
104
  ### Charges
101
105
 
102
106
  $ stripe charges list
data/lib/stripe/cli.rb CHANGED
@@ -2,6 +2,7 @@ require "thor"
2
2
  require "stripe"
3
3
  require "stripe/cli/version"
4
4
  require "awesome_print"
5
+ require "stripe/utils"
5
6
 
6
7
  module Stripe
7
8
  module CLI
@@ -3,9 +3,12 @@ require 'parseconfig'
3
3
  module Stripe
4
4
  module CLI
5
5
  class Command < Thor
6
+ @@config = File.expand_path('~/.stripecli')
7
+
6
8
  class_option :key, :aliases => :k
7
9
  class_option :env, :aliases => :e
8
10
  class_option :version, :aliases => :v
11
+
9
12
  protected
10
13
 
11
14
  def api_key
@@ -23,7 +26,7 @@ module Stripe
23
26
  def stored_api_option option
24
27
  if File.exists?(config_file)
25
28
  if environment
26
- config[environment][option.to_s]
29
+ config[environment][option.to_s] || config[option.to_s]
27
30
  else
28
31
  config[option.to_s]
29
32
  end
@@ -35,7 +38,7 @@ module Stripe
35
38
  end
36
39
 
37
40
  def config_file
38
- File.expand_path('~/.stripecli')
41
+ @@config
39
42
  end
40
43
 
41
44
  def list klass, options
@@ -2,6 +2,8 @@ module Stripe
2
2
  module CLI
3
3
  module Commands
4
4
  class Charges < Command
5
+ include Stripe::Utils
6
+
5
7
  desc "list", "List charges"
6
8
  option :count
7
9
  option :customer
@@ -39,26 +41,12 @@ module Stripe
39
41
  option :currency, :default => 'usd'
40
42
  option :description
41
43
  option :capture, :type => :boolean, :default => true
42
-
44
+ option :metadata, :type => :hash
43
45
  def create
44
46
  options[:amount] ||= ask('Amount in dollars:')
45
47
  options[:amount] = (Float(options[:amount]) * 100).to_i
46
48
 
47
- unless options[:card] || options[:customer]
48
- options[:card_name] ||= ask('Name on Card:')
49
- options[:card_number] ||= ask('Card number:')
50
- options[:card_cvc] ||= ask('CVC code:')
51
- options[:card_exp_month] ||= ask('expiration month:')
52
- options[:card_exp_year] ||= ask('expiration year:')
53
-
54
- options[:card] = {
55
- :number => options.delete(:card_number),
56
- :exp_month => options.delete(:card_exp_month),
57
- :exp_year => options.delete(:card_exp_year),
58
- :cvc => options.delete(:card_cvc),
59
- :name => options.delete(:card_name)
60
- }
61
- end
49
+ options[:card] ||= credit_card( options ) unless options[:customer]
62
50
 
63
51
  super Stripe::Charge, options
64
52
  end
@@ -2,6 +2,8 @@ module Stripe
2
2
  module CLI
3
3
  module Commands
4
4
  class Customers < Command
5
+ include Stripe::Utils
6
+
5
7
  desc "list", "List customers"
6
8
  option :count
7
9
  option :offset
@@ -34,7 +36,7 @@ module Stripe
34
36
  option :card_exp_year
35
37
  option :card_cvc
36
38
  option :card_name
37
-
39
+ option :metadata, :type => :hash
38
40
  def create
39
41
  options[:email] ||= ask('Customer\'s Email:')
40
42
  options[:description] ||= ask('Provide a description:')
@@ -44,22 +46,9 @@ module Stripe
44
46
  else
45
47
  options[:coupon] ||= ask('Apply a coupon:')
46
48
  end
49
+ options.delete( :coupon ) if options[:coupon] == ""
47
50
 
48
- if options[:plan]
49
- options[:card_name] ||= ask('Name on Card:')
50
- options[:card_number] ||= ask('Card number:')
51
- options[:card_cvc] ||= ask('CVC code:')
52
- options[:card_exp_month] ||= ask('expiration month:')
53
- options[:card_exp_year] ||= ask('expiration year:')
54
-
55
- options[:card] = {
56
- :number => options.delete(:card_number),
57
- :exp_month => options.delete(:card_exp_month),
58
- :exp_year => options.delete(:card_exp_year),
59
- :cvc => options.delete(:card_cvc),
60
- :name => options.delete(:card_name)
61
- }
62
- end unless options[:card]
51
+ options[:card] ||= credit_card( options ) if options[:plan]
63
52
 
64
53
  super Stripe::Customer, options
65
54
  end
@@ -33,7 +33,7 @@ module Stripe
33
33
  option :country
34
34
  option :account_number
35
35
  option :routing_number
36
-
36
+ option :metadata, :type => :hash
37
37
  def create
38
38
  options[:name] ||= ask('Recipient\'s Name:')
39
39
  options[:email] ||= ask('Recipient\'s Email:')
@@ -2,6 +2,7 @@ module Stripe
2
2
  module CLI
3
3
  module Commands
4
4
  class Tokens < Command
5
+ include Stripe::Utils
5
6
 
6
7
  desc "find ID", "Find a Token"
7
8
  def find event_id
@@ -22,25 +23,11 @@ module Stripe
22
23
  def create type
23
24
  case type
24
25
  when 'card', 'credit_card'
25
- unless options[:card]
26
- options[:card_name] ||= ask('Name on Card:')
27
- options[:card_number] ||= ask('Card number:')
28
- options[:card_cvc] ||= ask('CVC code:')
29
- options[:card_exp_month] ||= ask('expiration month:')
30
- options[:card_exp_year] ||= ask('expiration year:')
31
-
32
- options[:card] = {
33
- :number => options.delete(:card_number),
34
- :exp_month => options.delete(:card_exp_month),
35
- :exp_year => options.delete(:card_exp_year),
36
- :cvc => options.delete(:card_cvc),
37
- :name => options.delete(:card_name)
38
- }
39
- options.delete(:bank_account)
40
- options.delete(:country)
41
- options.delete(:routing_number)
42
- options.delete(:account_number)
43
- end
26
+ options[:card] ||= credit_card( options )
27
+ options.delete(:bank_account)
28
+ options.delete(:country)
29
+ options.delete(:routing_number)
30
+ options.delete(:account_number)
44
31
  when 'account', 'bank_account'
45
32
  unless options[:bank_account]
46
33
  options[:account_number] ||= ask('Account Number:')
@@ -24,6 +24,8 @@ module Stripe
24
24
  option :description
25
25
  option :statement_descriptor
26
26
  option :balance, :type => :boolean
27
+ option :self, :type => :boolean
28
+ option :metadata, :type => :hash
27
29
  def create
28
30
  if options.delete(:balance) == true
29
31
  options[:amount] = Stripe::Balance.retrieve(api_key).available.first.amount
@@ -31,8 +33,14 @@ module Stripe
31
33
  options[:amount] ||= ask('Amount in Dollars:')
32
34
  options[:amount] = (Float(options[:amount]) * 100).to_i
33
35
  end
34
- options[:recipient] ||= ask('Recipient ID or self:')
35
- options[:recipient] = create_recipient[:id] if options[:recipient] == ""
36
+
37
+ if options.delete(:self) == true
38
+ options[:recipient] = 'self'
39
+ else
40
+ options[:recipient] ||= ask('Recipient ID or self:')
41
+ options[:recipient] = create_recipient[:id] if options[:recipient] == ""
42
+ end
43
+
36
44
  super Stripe::Transfer, options
37
45
  end
38
46
 
@@ -1,5 +1,5 @@
1
1
  module Stripe
2
2
  module CLI
3
- VERSION = "1.1.0"
3
+ VERSION = "1.1.1"
4
4
  end
5
5
  end
@@ -0,0 +1,15 @@
1
+ module Stripe
2
+ module Utils
3
+
4
+ def credit_card options = {}
5
+ {
6
+ :name => options.delete(:card_name) || ask('Name on Card:'),
7
+ :number => options.delete(:card_number) || ask('Card number:'),
8
+ :cvc => options.delete(:card_cvc) || ask('CVC code:'),
9
+ :exp_month => options.delete(:card_exp_month) || ask('expiration month:'),
10
+ :exp_year => options.delete(:card_exp_year) || ask('expiration year:')
11
+ }
12
+ end
13
+
14
+ end
15
+ end
data/spec/command_spec.rb CHANGED
@@ -1,13 +1,9 @@
1
1
  require 'rspec'
2
2
  require_relative '../lib/stripe/cli.rb'
3
3
 
4
- Stripe::CLI::Command.class_eval do
5
- protected
6
- def api_key
7
- "stripe-key"
8
- end
9
- end
10
-
4
+ f = Tempfile.new('config')
5
+ f.write "key = stripe-key" and f.rewind
6
+ Stripe::CLI::Command.class_variable_set :@@config, f
11
7
 
12
8
  describe Stripe::CLI::Command do
13
9
  let(:_id_) { "random-id-string" }
data/stripe-cli.gemspec CHANGED
@@ -8,23 +8,26 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Stripe::CLI::VERSION
9
9
  spec.authors = ["Alex MacCaw", "Andy Cohen"]
10
10
  spec.email = ["alex@stripe.com", "outlawandy@gmail.com"]
11
- spec.description = %q{A `GIT style` Command line utility for accessing the Stripe API}
11
+ spec.description = <<-DESC.gsub("\t","")
12
+ a git-style cli, offering instant access to all of the Stripe API right from the console.
13
+ With an emphasis on convenience and productivity and a commitment to pretty, colorful, but most of all READABLE output.
14
+ DESC
12
15
  spec.summary = %q{Command line interface to Stripe}
13
16
  spec.homepage = "https://stripe.com"
14
17
  spec.license = "MIT"
15
18
 
16
- spec.files = `git ls-files`.split($/)
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.files = `git ls-files`.split($/).delete_if{ |f| "png" == f[/\.(.*)$/,1] }# don't include example images
20
+ spec.bindir = 'bin'
18
21
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
22
  spec.require_paths = ["lib"]
20
23
  spec.executables = ["stripe"]
21
24
 
22
25
  spec.add_development_dependency "bundler", "~> 1.3"
23
26
  spec.add_development_dependency "rake"
27
+ spec.add_development_dependency "rspec"
24
28
  spec.add_dependency "thor", "~> 0.18.1"
25
- spec.add_dependency "stripe", "~> 1.8.6"
29
+ spec.add_dependency "stripe", "~> 1.8.8"
26
30
  spec.add_dependency "awesome_print"
27
31
  spec.add_dependency "parseconfig"
28
32
  spec.add_dependency "chronic"
29
- spec.add_development_dependency "rspec"
30
33
  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.1.0
4
+ version: 1.1.1
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-06 00:00:00.000000000 Z
12
+ date: 2013-10-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -39,6 +39,20 @@ dependencies:
39
39
  - - '>='
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rspec
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
42
56
  - !ruby/object:Gem::Dependency
43
57
  name: thor
44
58
  requirement: !ruby/object:Gem::Requirement
@@ -59,14 +73,14 @@ dependencies:
59
73
  requirements:
60
74
  - - ~>
61
75
  - !ruby/object:Gem::Version
62
- version: 1.8.6
76
+ version: 1.8.8
63
77
  type: :runtime
64
78
  prerelease: false
65
79
  version_requirements: !ruby/object:Gem::Requirement
66
80
  requirements:
67
81
  - - ~>
68
82
  - !ruby/object:Gem::Version
69
- version: 1.8.6
83
+ version: 1.8.8
70
84
  - !ruby/object:Gem::Dependency
71
85
  name: awesome_print
72
86
  requirement: !ruby/object:Gem::Requirement
@@ -109,21 +123,9 @@ dependencies:
109
123
  - - '>='
110
124
  - !ruby/object:Gem::Version
111
125
  version: '0'
112
- - !ruby/object:Gem::Dependency
113
- name: rspec
114
- requirement: !ruby/object:Gem::Requirement
115
- requirements:
116
- - - '>='
117
- - !ruby/object:Gem::Version
118
- version: '0'
119
- type: :development
120
- prerelease: false
121
- version_requirements: !ruby/object:Gem::Requirement
122
- requirements:
123
- - - '>='
124
- - !ruby/object:Gem::Version
125
- version: '0'
126
- description: A `GIT style` Command line utility for accessing the Stripe API
126
+ description: |2
127
+ a git-style cli, offering instant access to all of the Stripe API right from the console.
128
+ With an emphasis on convenience and productivity and a commitment to pretty, colorful, but most of all READABLE output.
127
129
  email:
128
130
  - alex@stripe.com
129
131
  - outlawandy@gmail.com
@@ -139,7 +141,6 @@ files:
139
141
  - Rakefile
140
142
  - bin/stripe
141
143
  - example.conf
142
- - example.png
143
144
  - lib/stripe/cli.rb
144
145
  - lib/stripe/cli/command.rb
145
146
  - lib/stripe/cli/commands.rb
@@ -156,7 +157,7 @@ files:
156
157
  - lib/stripe/cli/commands/transfers.rb
157
158
  - lib/stripe/cli/runner.rb
158
159
  - lib/stripe/cli/version.rb
159
- - output.png
160
+ - lib/stripe/utils.rb
160
161
  - spec/command_spec.rb
161
162
  - stripe-cli.gemspec
162
163
  homepage: https://stripe.com
data/example.png DELETED
Binary file
data/output.png DELETED
Binary file