stripe-cli 1.8.0 → 1.8.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 36fee7ef4d1a6f6173c8fb3c6da780b21d45e0f4
4
- data.tar.gz: 3d5426b463809009fc79e91e85c53d7fd238df27
3
+ metadata.gz: 2c011a0b4876f5117b209ae046b3324a5563fe03
4
+ data.tar.gz: 10c2cda7d172ee7bf3276884919b004b2eb4d2bc
5
5
  SHA512:
6
- metadata.gz: dd60ff68b1a6ee310f3bdd47357aebc40b9e29c287d3ebb2089d17d58a378094f748c8599558ee1d824b0839291e2b17c465c3017daa4a1c6e52fcbb78bd83fb
7
- data.tar.gz: 33d671b2eba22025ae8896914669cb94e619f66662e1ab5bec7fec2701e32ced17c165c15faa57a365f0ed7bc72d5e9c3981d3cca22bf63d0a4f83b6ecac6b70
6
+ metadata.gz: c4394c23d23222509f14210f0b92c82247fa1d6532194b4c93ff879ff1c35f256161ec8c1f26ee5ccc13f8e89be666a76798a347bd3eaff14be57956a89bf815
7
+ data.tar.gz: 7726d0daccaf4cd42e1bc0ac6cc4c1ac217662bb69f1ed1d18e432a226f06557068dde33504af1cb1eb0962a6ac610a7f47122b73c40aef9784ec2d8ce241a78
data/README.md CHANGED
@@ -63,7 +63,7 @@ If you choose to go this route, make sure to add `.stripecli` to your `.gitignor
63
63
 
64
64
  By default, Date/Time stamps are converted automatically to your local machine time. No more Epoch/Unix timestamp garbage!
65
65
 
66
- If you'd prefer to have time Date/Time stamps to be converted to UTC time, set the config option `dates` or `-d` to `utc`. You can also set it to `unix` to see the original Unix timestamp passed from the API. By default, it uses `local`.
66
+ If you'd prefer to have time Date/Time stamps converted to UTC time, set the config option `dates` or `-d` to `utc`. You can also set it to `unix` to see the original Unix timestamp passed from the API. By default, it uses `local`.
67
67
 
68
68
  ### Dollars vs. Cents
69
69
 
@@ -92,13 +92,13 @@ If you need to adjust this setting temporarily, there are global flags which may
92
92
 
93
93
  ## General Features & Flexibility
94
94
 
95
- Any parameters accepted by the [stripe api](https://stripe.com/docs/api) are acceptable options to pass into commands, including metadata.
95
+ Any parameters accepted by the [stripe api](https://stripe.com/docs/api) are acceptable options to pass into commands, including metadata and the `expand` parameter.
96
96
 
97
97
  $ stripe charges create --amount=9.98 --description=a\ must\ have --number=4242424242424242 --cvc=123 --exp-month=10 --exp-year=2020
98
98
 
99
99
  or
100
100
 
101
- $ stripe charges create --amount=16.72 --token=tok_abc123 --metadata=foo:bar meta:really\ meta\ data
101
+ $ stripe charges create --amount=16.72 --token=tok_abc123 --metadata=foo:bar meta:baz --expand=balance_transaction
102
102
 
103
103
  or
104
104
 
@@ -169,8 +169,11 @@ Api errors are rescued and their messages displayed for you to read. No more `b
169
169
  [-k | --key=KEY] # One of your API secret keys, provided by Stripe
170
170
  [-e | --env=ENV] # expects a `~/.stripecli` file with section headers for any string passed into it
171
171
  [-v | --version=VERSION] # Stripe API version-date. Looks like `YYYY-MM-DD`
172
+ [-d | --dates=DATES] # Date Style. It should be either local, utc, or unix. Defaults to local.
172
173
  [--dollar-amounts] # configuration flag setting expected currency units to dollars
173
174
  [--no-dollar-amounts] # configuration flag setting expected currency units to cents
175
+ [--strip-nils] # use this flag to strip nil-valued attributes from the output
176
+ [--expand=one two three] # one or more ID properties of the response you'd like expanded into full objects
174
177
 
175
178
  ## Command Documentation
176
179
 
@@ -605,17 +608,17 @@ Api errors are rescued and their messages displayed for you to read. No more `b
605
608
  ### Invoice Items
606
609
 
607
610
  Commands:
608
- stripe invoice_items create # Create a new invoice item for customer
609
- stripe invoice_items delete ID # Delete a invoice item
610
- stripe invoice_items find ID # Find an invoice item
611
- stripe invoice_items help [COMMAND] # Describe subcommands or one specific subcommand
612
- stripe invoice_items list # List invoice items (optionally by customer_id)
611
+ stripe invoice-items create # Create a new invoice item for customer
612
+ stripe invoice-items delete ID # Delete a invoice item
613
+ stripe invoice-items find ID # Find an invoice item
614
+ stripe invoice-items help [COMMAND] # Describe subcommands or one specific subcommand
615
+ stripe invoice-items list # List invoice items (optionally by customer_id)
613
616
 
614
617
 
615
618
  #### Invoice Item Create
616
619
 
617
620
  Usage:
618
- stripe create
621
+ stripe invoice-item create
619
622
 
620
623
  Options:
621
624
  [--customer=CUSTOMER] # The ID of customer for the invoice item
@@ -633,21 +636,21 @@ Api errors are rescued and their messages displayed for you to read. No more `b
633
636
  #### Invoice Item Delete
634
637
 
635
638
  Usage:
636
- stripe delete ID
639
+ stripe invoice-item delete ID
637
640
 
638
641
  Delete a invoice item
639
642
 
640
643
  #### Invoice Item Find
641
644
 
642
645
  Usage:
643
- stripe find ID
646
+ stripe invoice-item find ID
644
647
 
645
648
  Find an invoice item
646
649
 
647
650
  #### Invoice Item List
648
651
 
649
652
  Usage:
650
- stripe list
653
+ stripe invoice-items list
651
654
 
652
655
  Options:
653
656
  [--starting-after=STARTING_AFTER] # The ID of the last object in the previous paged result set. For cursor-based pagination.
data/changelog.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Stripe-CLI Project Change Log
2
2
 
3
+ ## 1.8.3
4
+
5
+ - new command-line option `--expand` provides support for Stripe API expansions
6
+ - https://stripe.com/docs/api#expanding_objects
7
+ - stripe-ruby dependancy updated to version 1.24.0
8
+
9
+ ## 1.8.2
10
+
11
+ - bug fixes
12
+ - it was previously possible for certain command-line arguments to be passed through to the Stripe API resulting in API exceptions.
13
+ - creating tokens would fail for bank account type
14
+
15
+ ## 1.8.1
16
+
17
+ - new configuration option to strip nil-valued attributes from command-line output
18
+ - use on command-line with global flag `--strip-nils`
19
+ - or set in config-file with `strip_nils=true`
20
+ - override config-file setting with global command-line flag `--no-strip-nils`
21
+
3
22
  ## 1.8.0
4
23
 
5
24
  - top-level `invoice_items` command
@@ -1,6 +1,8 @@
1
1
  default = test
2
2
  version = "2014-07-22"
3
3
  dollar_amounts = false
4
+ dates = "utc"
5
+ strip_nils = true
4
6
 
5
7
  [test]
6
8
  key = sk_test_abc123def456ghi789jklmno
@@ -11,4 +13,4 @@ dollar_amounts = false
11
13
  [new-api]
12
14
  key = sk_test_abc123def456ghi789jklmno
13
15
  version = "2014-09-08"
14
- dollar_amounts = true
16
+ dollar_amounts = true
@@ -11,6 +11,8 @@ module Stripe
11
11
  class_option :version, :aliases => :v, :type => :string, :desc => "Stripe API version-date. Looks like `YYYY-MM-DD`"
12
12
  class_option :dates, :aliases => :d, :type => :string, :desc => "Date Style. It should be either local, utc, or unix. Defaults to local.", :enum => %w(local utc unix)
13
13
  class_option :dollar_amounts, :type => :boolean, :desc => "set expected currency units to dollars or cents"
14
+ class_option :strip_nils, :type => :boolean, :desc => "use this flag to strip nil valued attributes from the output"
15
+ class_option :expand, :type => :array, :desc => "one or more ID properties of the response you'd like expanded into full objects"
14
16
 
15
17
 
16
18
  protected
@@ -27,13 +29,16 @@ module Stripe
27
29
  @env ||= options.delete(:env) || config['default']
28
30
  end
29
31
 
30
- def dates
31
- @dates ||= options.delete(:dates) || stored_api_option('dates')
32
+ def date_format
33
+ options.delete(:dates) || stored_api_option('dates')
32
34
  end
33
35
 
34
36
  def dollar_amounts
35
- param_option = options.delete(:dollar_amounts)
36
- param_option.nil? ? stored_api_option('dollar_amounts') == 'false' ? false : true : param_option
37
+ options.delete(:dollar_amounts) { !(stored_api_option('dollar_amounts') == 'false') }
38
+ end
39
+
40
+ def strip_nils?
41
+ options.delete(:strip_nils) { stored_api_option('strip_nils') == "true" }
37
42
  end
38
43
 
39
44
  def stored_api_option option
@@ -55,11 +60,11 @@ module Stripe
55
60
  end
56
61
 
57
62
  def list klass, options
58
- request klass, :all, options, api_key
63
+ request klass, :all, options
59
64
  end
60
65
 
61
66
  def find klass, id
62
- request klass, :retrieve, id, api_key
67
+ request klass, :retrieve, {:id => id, :expand => options[:expand]}
63
68
  end
64
69
 
65
70
  def delete klass, id
@@ -67,11 +72,11 @@ module Stripe
67
72
  end
68
73
 
69
74
  def create klass, options
70
- request klass, :create, options, api_key
75
+ request klass, :create, options
71
76
  end
72
77
 
73
78
  def request object, method, *arguments
74
- Stripe.api_version = api_version unless api_version.nil?
79
+ pre_request_setup
75
80
  begin
76
81
  output object.send method, *arguments
77
82
  rescue StripeError => e
@@ -90,18 +95,7 @@ module Stripe
90
95
  when Stripe::StripeObject
91
96
  inspect object.instance_variable_get(:@values)
92
97
  when Numeric
93
- if object > 1000000000
94
- case dates
95
- when 'unix' then
96
- object
97
- when 'utc'
98
- Time.at( object ).utc
99
- else
100
- Time.at( object )
101
- end
102
- else
103
- object
104
- end
98
+ object > 1000000000 ? handle_date(object) : object
105
99
  else
106
100
  object
107
101
  end
@@ -114,12 +108,32 @@ module Stripe
114
108
  ap inspect( objects ), :indent => -2
115
109
  end
116
110
 
111
+ # strip non-api params from options hash
112
+ # set api_version & api_key
113
+ def pre_request_setup
114
+ @strip_nils = strip_nils?
115
+ @date_format = date_format
116
+ Stripe.api_key = api_key
117
+ Stripe.api_version = api_version unless api_version.nil?
118
+ end
119
+
117
120
  def handle_hash object
118
121
  object.inject({}) do |hash, (key, value)|
119
- hash[key] = inspect( value )
122
+ hash[key] = inspect( value ) unless @strip_nils && value.nil?
120
123
  hash
121
124
  end
122
125
  end
126
+
127
+ def handle_date object
128
+ case @date_format
129
+ when 'unix' then
130
+ object
131
+ when 'utc'
132
+ Time.at( object ).utc
133
+ else
134
+ Time.at( object )
135
+ end
136
+ end
123
137
  end
124
138
  end
125
139
  end
@@ -69,14 +69,7 @@ module Stripe
69
69
  options[:bank_account] = bank_account( options )
70
70
  end
71
71
 
72
- options.delete :country
73
- options.delete :account_number
74
- options.delete :routing_number
75
- options.delete :card_number
76
- options.delete :card_exp_month
77
- options.delete :card_exp_year
78
- options.delete :card_cvc
79
- options.delete :card_name
72
+ options.delete_if {|option,_| strip_list.include? option }
80
73
 
81
74
  super Stripe::Recipient, options
82
75
  end
@@ -88,6 +81,11 @@ module Stripe
88
81
  opt.delete(:corporation) ? 'corporation' :
89
82
  yes?('Corporation? [yN]') ? 'corporation' : 'individual'
90
83
  end
84
+
85
+ def strip_list
86
+ %i( card_number card_exp_month card_exp_year card_cvc card_name country routing_number account_number )
87
+ end
88
+
91
89
  end
92
90
  end
93
91
  end
@@ -21,20 +21,26 @@ module Stripe
21
21
  option :routing_number, :desc => "ACH routing number for bank account"
22
22
  option :account_number, :desc => "account number of bank account. Must be a checking account"
23
23
  def create type
24
- case type
24
+ opt_symbol, value_hash = case type
25
25
  when 'card', 'credit_card', 'credit card'
26
- credit_card = credit_card( options )
27
- options = {}
28
- options[:card] = credit_card
26
+ [ :card, credit_card( options ) ]
29
27
  when 'account', 'bank_account', 'bank account'
30
- bank_account = bank_account( options )
31
- options = {}
32
- options[:bank_account] = bank_account
28
+ [ :bank_account, bank_account( options ) ]
33
29
  end
34
30
 
31
+ options.delete_if {|option,_| strip_list.include? option }
32
+
33
+ options[opt_symbol] = value_hash
34
+
35
35
  super Stripe::Token, options
36
36
  end
37
37
 
38
+ private
39
+
40
+ def strip_list
41
+ %i( card card_number card_exp_month card_exp_year card_cvc card_name bank_account country routing_number account_number )
42
+ end
43
+
38
44
  end
39
45
  end
40
46
  end
@@ -1,5 +1,5 @@
1
1
  module Stripe
2
2
  module CLI
3
- VERSION = "1.8.0"
3
+ VERSION = "1.8.3"
4
4
  end
5
5
  end
data/stripe-cli.gemspec CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.add_development_dependency 'bundler', '~> 1.3'
26
26
  spec.add_development_dependency 'rspec', '~> 2.12', '>= 2.12.0'
27
27
  spec.add_runtime_dependency 'thor', '~> 0.18', '>= 0.18.1'
28
- spec.add_runtime_dependency 'stripe', '~> 1.12', '>= 1.12.0'
28
+ spec.add_runtime_dependency 'stripe', '~> 1.24.0', '>= 1.24.0'
29
29
  spec.add_runtime_dependency 'awesome_print', '~> 1.2', '>= 1.2.0'
30
30
  spec.add_runtime_dependency 'parseconfig', '~> 1.0', '>= 1.0.4'
31
31
  spec.add_runtime_dependency 'chronic', '~> 0.10', '>= 0.10.2'
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.8.0
4
+ version: 1.8.3
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: 2015-07-24 00:00:00.000000000 Z
12
+ date: 2015-08-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -71,20 +71,20 @@ dependencies:
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: '1.12'
74
+ version: 1.24.0
75
75
  - - ">="
76
76
  - !ruby/object:Gem::Version
77
- version: 1.12.0
77
+ version: 1.24.0
78
78
  type: :runtime
79
79
  prerelease: false
80
80
  version_requirements: !ruby/object:Gem::Requirement
81
81
  requirements:
82
82
  - - "~>"
83
83
  - !ruby/object:Gem::Version
84
- version: '1.12'
84
+ version: 1.24.0
85
85
  - - ">="
86
86
  - !ruby/object:Gem::Version
87
- version: 1.12.0
87
+ version: 1.24.0
88
88
  - !ruby/object:Gem::Dependency
89
89
  name: awesome_print
90
90
  requirement: !ruby/object:Gem::Requirement