stripe-cli 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .DS_Store
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in stripe-cli.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Alex MacCaw
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,29 @@
1
+ # Stripe::Cli
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'stripe-cli'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install stripe-cli
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'stripe/cli'
4
+ Stripe::CLI::Runner.start
@@ -0,0 +1,12 @@
1
+ require "thor"
2
+ require "stripe"
3
+ require "stripe/cli/version"
4
+ require "awesome_print"
5
+
6
+ module Stripe
7
+ module CLI
8
+ autoload :Command, 'stripe/cli/command'
9
+ autoload :Runner, 'stripe/cli/runner'
10
+ autoload :Commands, 'stripe/cli/commands'
11
+ end
12
+ end
@@ -0,0 +1,50 @@
1
+ require 'parseconfig'
2
+
3
+ module Stripe
4
+ module CLI
5
+ class Command < Thor
6
+ class_option :key, :aliases => :k
7
+
8
+ protected
9
+
10
+ def api_key
11
+ @api_key ||= options[:key] || stored_api_key
12
+ end
13
+
14
+ def stored_api_key
15
+ if File.exists?(config_file)
16
+ ParseConfig.new(config_file)['key']
17
+ end
18
+ end
19
+
20
+ def config_file
21
+ File.expand_path('~/.stripecli')
22
+ end
23
+
24
+ def inspect(object)
25
+ case object
26
+ when Array
27
+ object.map {|o| inspect(o) }
28
+ when Hash
29
+ object.inject({}) do |hash, (key, value)|
30
+ hash[key] = inspect(value)
31
+ hash
32
+ end
33
+ when Stripe::ListObject
34
+ inspect object.data
35
+ when Stripe::StripeObject
36
+ inspect object.to_hash
37
+ else
38
+ object
39
+ end
40
+ end
41
+
42
+ def output(objects)
43
+ ap(
44
+ inspect(objects),
45
+ :indent => -2
46
+ )
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,10 @@
1
+ module Stripe
2
+ module CLI
3
+ module Commands
4
+ autoload :Charges, 'stripe/cli/commands/charges'
5
+ autoload :Customers, 'stripe/cli/commands/customers'
6
+ autoload :Plans, 'stripe/cli/commands/plans'
7
+ autoload :Events, 'stripe/cli/commands/events'
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,71 @@
1
+ module Stripe
2
+ module CLI
3
+ module Commands
4
+ class Charges < Command
5
+ desc "list", "List charges"
6
+ option :count
7
+ option :customer
8
+ option :offset
9
+ def list
10
+ output Stripe::Charge.all(options, api_key)
11
+ end
12
+
13
+ desc "find ID", "Find a charge"
14
+ def find(charge_id)
15
+ output Stripe::Charge.retrieve(charge_id, api_key)
16
+ end
17
+
18
+ desc "refund ID", "Refund a charge"
19
+ def refund(charge_id)
20
+ output Stripe::Charge.new(charge_id, api_key).refund
21
+ end
22
+
23
+ desc "capture ID", "Capture a charge"
24
+ def capture(charge_id)
25
+ output Stripe::Charge.new(charge_id, api_key).capture
26
+ end
27
+
28
+ desc "create", "Create a charge"
29
+ option :card
30
+ option :card_number
31
+ option :card_exp_month
32
+ option :card_exp_year
33
+ option :card_cvc
34
+ option :card_name
35
+ option :amount, :type => :numeric
36
+ option :currency, :default => 'usd'
37
+ option :description
38
+ option :capture, :type => :boolean
39
+
40
+ def create
41
+ options[:amount] ||= ask('Amount in dollars:')
42
+ options[:amount] = (Float(options[:amount]) * 100).to_i
43
+
44
+ unless options[:card]
45
+ options[:card_number] ||= ask('Card number:')
46
+ options[:card_exp_month] ||= ask('Card exp month:')
47
+ options[:card_exp_year] ||= ask('Card exp year:')
48
+ options[:card_cvc] ||= ask('Card CVC:')
49
+ options[:card_name] ||= ask('Card name:')
50
+
51
+ options[:card] = {
52
+ :number => options[:card_number],
53
+ :exp_month => options[:card_exp_month],
54
+ :exp_year => options[:card_exp_year],
55
+ :cvc => options[:card_cvc],
56
+ :name => options[:card_name]
57
+ }
58
+
59
+ options.delete(:card_number)
60
+ options.delete(:card_exp_month)
61
+ options.delete(:card_exp_year)
62
+ options.delete(:card_cvc)
63
+ options.delete(:card_name)
64
+ end
65
+
66
+ output Stripe::Charge.create(options, api_key)
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,25 @@
1
+ module Stripe
2
+ module CLI
3
+ module Commands
4
+ class Customers < Command
5
+ desc "list", "List customers"
6
+ option :count
7
+ option :offset
8
+
9
+ def list
10
+ output Stripe::Customer.all(options, api_key)
11
+ end
12
+
13
+ desc "find ID", "Find a customer"
14
+ def find(customer_id)
15
+ output Stripe::Customer.retrieve(customer_id, api_key)
16
+ end
17
+
18
+ desc "delete ID", "Delete a customer"
19
+ def delete(customer_id)
20
+ output Stripe::Customer.new(customer_id, api_key).delete
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,20 @@
1
+ module Stripe
2
+ module CLI
3
+ module Commands
4
+ class Events < Command
5
+ desc "list", "List events"
6
+ option :count
7
+ option :offset
8
+
9
+ def list
10
+ output Stripe::Event.all(options, api_key)
11
+ end
12
+
13
+ desc "find ID", "Find a event`"
14
+ def find(event_id)
15
+ output Stripe::Event.retrieve(event_id, api_key)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,25 @@
1
+ module Stripe
2
+ module CLI
3
+ module Commands
4
+ class Plans < Command
5
+ desc "list", "List plans"
6
+ option :count
7
+ option :offset
8
+
9
+ def list
10
+ output Stripe::Plan.all(options, api_key)
11
+ end
12
+
13
+ desc "find ID", "Find a plan"
14
+ def find(plan_id)
15
+ output Stripe::Plan.retrieve(plan_id, api_key)
16
+ end
17
+
18
+ desc "delete ID", "Delete a plan"
19
+ def delete(plan_id)
20
+ output Stripe::Plan.new(plan_id, api_key).delete
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,10 @@
1
+ module Stripe
2
+ module CLI
3
+ class Runner < Thor
4
+ register Commands::Charges, 'charges', 'charges', '/charges'
5
+ register Commands::Customers, 'customers', 'customers', '/customers'
6
+ register Commands::Plans, 'plans', 'plans', '/plans'
7
+ register Commands::Events, 'events', 'events', '/events'
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ module Stripe
2
+ module CLI
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'stripe/cli/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "stripe-cli"
8
+ spec.version = Stripe::CLI::VERSION
9
+ spec.authors = ["Alex MacCaw"]
10
+ spec.email = ["alex@stripe.com"]
11
+ spec.description = %q{Command line interface to Stripe}
12
+ spec.summary = %q{Command line interface to Stripe}
13
+ spec.homepage = "https://stripe.com"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+ spec.executables = ["stripe"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.3"
23
+ spec.add_development_dependency "rake"
24
+ spec.add_dependency "thor", "~> 0.18.1"
25
+ spec.add_dependency "stripe", "~> 1.8.3"
26
+ spec.add_dependency "awesome_print"
27
+ spec.add_dependency "parseconfig"
28
+ end
metadata ADDED
@@ -0,0 +1,165 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: stripe-cli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Alex MacCaw
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-06-28 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: thor
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 0.18.1
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.18.1
62
+ - !ruby/object:Gem::Dependency
63
+ name: stripe
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 1.8.3
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 1.8.3
78
+ - !ruby/object:Gem::Dependency
79
+ name: awesome_print
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: parseconfig
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ description: Command line interface to Stripe
111
+ email:
112
+ - alex@stripe.com
113
+ executables:
114
+ - stripe
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - .gitignore
119
+ - Gemfile
120
+ - LICENSE.txt
121
+ - README.md
122
+ - Rakefile
123
+ - bin/stripe
124
+ - lib/stripe/cli.rb
125
+ - lib/stripe/cli/command.rb
126
+ - lib/stripe/cli/commands.rb
127
+ - lib/stripe/cli/commands/charges.rb
128
+ - lib/stripe/cli/commands/customers.rb
129
+ - lib/stripe/cli/commands/events.rb
130
+ - lib/stripe/cli/commands/plans.rb
131
+ - lib/stripe/cli/runner.rb
132
+ - lib/stripe/cli/version.rb
133
+ - stripe-cli.gemspec
134
+ homepage: https://stripe.com
135
+ licenses:
136
+ - MIT
137
+ post_install_message:
138
+ rdoc_options: []
139
+ require_paths:
140
+ - lib
141
+ required_ruby_version: !ruby/object:Gem::Requirement
142
+ none: false
143
+ requirements:
144
+ - - ! '>='
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ segments:
148
+ - 0
149
+ hash: 68450767898144623
150
+ required_rubygems_version: !ruby/object:Gem::Requirement
151
+ none: false
152
+ requirements:
153
+ - - ! '>='
154
+ - !ruby/object:Gem::Version
155
+ version: '0'
156
+ segments:
157
+ - 0
158
+ hash: 68450767898144623
159
+ requirements: []
160
+ rubyforge_project:
161
+ rubygems_version: 1.8.24
162
+ signing_key:
163
+ specification_version: 3
164
+ summary: Command line interface to Stripe
165
+ test_files: []