stripe 5.23.0 → 5.23.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
  SHA256:
3
- metadata.gz: 339246c958404a761dbafcfbd76acfcf7f2223838e41efd928babd1624f1f173
4
- data.tar.gz: 8d7385cfe0066b9dd4ad53a2f3d3ebcace2b22f77b27cd8fe252bfb7f58118e4
3
+ metadata.gz: 33f1cdd1289229d711bcba485944474bfc3b645aaf0402bf2d4236eff4a87a4e
4
+ data.tar.gz: d2e05e209525b15095fcdbbfacb9f3e05ce4d7eb902c06c19f468bbd5a192184
5
5
  SHA512:
6
- metadata.gz: 3170fd6a145e41cc69b25ddbeb20cc88064fb4011ee89438d07362c745c2990523c1ea25c319c25910e5670bba7f27d97b2453462fc441c31d0db3b0ff761c46
7
- data.tar.gz: bc2ae7b487bfd0a7957e360862188bcda79f9f851504162ec9c30ecf3c0a824a2050e73a0e5d3ceb3840511b8585b4710e3a97864b3eb7e0ddcb315b79f60a8d
6
+ metadata.gz: 2dcb34a7af495d2a704d3b48c35b08b1680bb24ea541e46e90c247ca57689fbaf213f798ef018a9fa9ed17644e42e76b7666f8fac2dd104f495f460492c5fb99
7
+ data.tar.gz: 232b4bef2acfc1b452ee1314c67d6e688a01a5860e4be93ad49491b65506cc3e10763c3a1090e2aeaa5137a1438f42a8f7e4f7741f4e1909f894ddb5dcef3639
@@ -44,10 +44,10 @@ Metrics/ClassLength:
44
44
  - "test/**/*.rb"
45
45
 
46
46
  Metrics/MethodLength:
47
- # There's ~2 long methods in `StripeClient`. If we want to truncate those a
48
- # little, we could move this to be closer to ~30 (but the default of 10 is
49
- # probably too short).
50
- Max: 50
47
+ # There's ~2 long methods in `StripeClient` and one in `NestedResource`. If
48
+ # we want to truncate those a little, we could move this to be closer to ~30
49
+ # (but the default of 10 is probably too short).
50
+ Max: 55
51
51
 
52
52
  Metrics/ModuleLength:
53
53
  Enabled: false
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## 5.23.1 - 2020-08-05
4
+ * [#936](https://github.com/stripe/stripe-ruby/pull/936) Rename API resource's `request` method
5
+
3
6
  ## 5.23.0 - 2020-08-05
4
7
  * [#937](https://github.com/stripe/stripe-ruby/pull/937) Add support for the `PromotionCode` resource and APIs
5
8
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 5.23.0
1
+ 5.23.1
@@ -4,7 +4,7 @@ module Stripe
4
4
  module APIOperations
5
5
  module Create
6
6
  def create(params = {}, opts = {})
7
- resp, opts = request(:post, resource_url, params, opts)
7
+ resp, opts = execute_resource_request(:post, resource_url, params, opts)
8
8
  Util.convert_to_stripe_object(resp.data, opts)
9
9
  end
10
10
  end
@@ -15,15 +15,19 @@ module Stripe
15
15
  # * +opts+ - A Hash of additional options (separate from the params /
16
16
  # object values) to be added to the request. E.g. to allow for an
17
17
  # idempotency_key to be passed in the request headers, or for the
18
- # api_key to be overwritten. See {APIOperations::Request.request}.
18
+ # api_key to be overwritten. See
19
+ # {APIOperations::Request.execute_resource_request}.
19
20
  def delete(id, params = {}, opts = {})
20
- resp, opts = request(:delete, "#{resource_url}/#{id}", params, opts)
21
+ resp, opts = execute_resource_request(:delete,
22
+ "#{resource_url}/#{id}",
23
+ params, opts)
21
24
  Util.convert_to_stripe_object(resp.data, opts)
22
25
  end
23
26
  end
24
27
 
25
28
  def delete(params = {}, opts = {})
26
- resp, opts = request(:delete, resource_url, params, opts)
29
+ resp, opts = execute_resource_request(:delete, resource_url,
30
+ params, opts)
27
31
  initialize_from(resp.data, opts)
28
32
  end
29
33
 
@@ -6,7 +6,7 @@ module Stripe
6
6
  def list(filters = {}, opts = {})
7
7
  opts = Util.normalize_opts(opts)
8
8
 
9
- resp, opts = request(:get, resource_url, filters, opts)
9
+ resp, opts = execute_resource_request(:get, resource_url, filters, opts)
10
10
  obj = ListObject.construct_from(resp.data, opts)
11
11
 
12
12
  # set filters so that we can fetch the same limit, expansions, and
@@ -31,35 +31,36 @@ module Stripe
31
31
  define_singleton_method(:"create_#{resource}") \
32
32
  do |id, params = {}, opts = {}|
33
33
  url = send(resource_url_method, id)
34
- resp, opts = request(:post, url, params, opts)
34
+ resp, opts = execute_resource_request(:post, url, params, opts)
35
35
  Util.convert_to_stripe_object(resp.data, opts)
36
36
  end
37
37
  when :retrieve
38
38
  define_singleton_method(:"retrieve_#{resource}") \
39
39
  do |id, nested_id, opts = {}|
40
40
  url = send(resource_url_method, id, nested_id)
41
- resp, opts = request(:get, url, {}, opts)
41
+ resp, opts = execute_resource_request(:get, url, {}, opts)
42
42
  Util.convert_to_stripe_object(resp.data, opts)
43
43
  end
44
44
  when :update
45
45
  define_singleton_method(:"update_#{resource}") \
46
46
  do |id, nested_id, params = {}, opts = {}|
47
47
  url = send(resource_url_method, id, nested_id)
48
- resp, opts = request(:post, url, params, opts)
48
+ resp, opts = execute_resource_request(:post, url, params, opts)
49
49
  Util.convert_to_stripe_object(resp.data, opts)
50
50
  end
51
51
  when :delete
52
52
  define_singleton_method(:"delete_#{resource}") \
53
53
  do |id, nested_id, params = {}, opts = {}|
54
54
  url = send(resource_url_method, id, nested_id)
55
- resp, opts = request(:delete, url, params, opts)
55
+ resp, opts = execute_resource_request(:delete, url, params,
56
+ opts)
56
57
  Util.convert_to_stripe_object(resp.data, opts)
57
58
  end
58
59
  when :list
59
60
  define_singleton_method(:"list_#{resource_plural}") \
60
61
  do |id, params = {}, opts = {}|
61
62
  url = send(resource_url_method, id)
62
- resp, opts = request(:get, url, params, opts)
63
+ resp, opts = execute_resource_request(:get, url, params, opts)
63
64
  Util.convert_to_stripe_object(resp.data, opts)
64
65
  end
65
66
  else
@@ -4,7 +4,8 @@ module Stripe
4
4
  module APIOperations
5
5
  module Request
6
6
  module ClassMethods
7
- def request(method, url, params = {}, opts = {})
7
+ def execute_resource_request(method, url,
8
+ params = {}, opts = {})
8
9
  params ||= {}
9
10
 
10
11
  error_on_invalid_params(params)
@@ -36,6 +37,17 @@ module Stripe
36
37
  [resp, opts_to_persist]
37
38
  end
38
39
 
40
+ # This method used to be called `request`, but it's such a short name
41
+ # that it eventually conflicted with the name of a field on an API
42
+ # resource (specifically, `Event#request`), so it was renamed to
43
+ # something more unique.
44
+ #
45
+ # The former name had been around for just about forever though, and
46
+ # although all internal uses have been renamed, I've left this alias in
47
+ # place for backwards compatibility. Consider removing it on the next
48
+ # major.
49
+ alias request execute_resource_request
50
+
39
51
  private def error_on_non_string_user_opts(opts)
40
52
  Util::OPTS_USER_SPECIFIED.each do |opt|
41
53
  next unless opts.key?(opt)
@@ -71,10 +83,14 @@ module Stripe
71
83
  base.extend(ClassMethods)
72
84
  end
73
85
 
74
- protected def request(method, url, params = {}, opts = {})
86
+ protected def execute_resource_request(method, url,
87
+ params = {}, opts = {})
75
88
  opts = @opts.merge(Util.normalize_opts(opts))
76
- self.class.request(method, url, params, opts)
89
+ self.class.execute_resource_request(method, url, params, opts)
77
90
  end
91
+
92
+ # See notes on `alias` above.
93
+ alias request execute_resource_request
78
94
  end
79
95
  end
80
96
  end
@@ -15,7 +15,8 @@ module Stripe
15
15
  # * +opts+ - A Hash of additional options (separate from the params /
16
16
  # object values) to be added to the request. E.g. to allow for an
17
17
  # idempotency_key to be passed in the request headers, or for the
18
- # api_key to be overwritten. See {APIOperations::Request.request}.
18
+ # api_key to be overwritten. See
19
+ # {APIOperations::Request.execute_resource_request}.
19
20
  def update(id, params = {}, opts = {})
20
21
  params.each_key do |k|
21
22
  if protected_fields.include?(k)
@@ -23,7 +24,8 @@ module Stripe
23
24
  end
24
25
  end
25
26
 
26
- resp, opts = request(:post, "#{resource_url}/#{id}", params, opts)
27
+ resp, opts = execute_resource_request(:post, "#{resource_url}/#{id}",
28
+ params, opts)
27
29
  Util.convert_to_stripe_object(resp.data, opts)
28
30
  end
29
31
  end
@@ -43,7 +45,8 @@ module Stripe
43
45
  # * +opts+ - A Hash of additional options (separate from the params /
44
46
  # object values) to be added to the request. E.g. to allow for an
45
47
  # idempotency_key to be passed in the request headers, or for the
46
- # api_key to be overwritten. See {APIOperations::Request.request}.
48
+ # api_key to be overwritten. See
49
+ # {APIOperations::Request.execute_resource_request}.
47
50
  def save(params = {}, opts = {})
48
51
  # We started unintentionally (sort of) allowing attributes sent to
49
52
  # +save+ to override values used during the update. So as not to break
@@ -59,7 +62,7 @@ module Stripe
59
62
  # generated a uri for this object with an identifier baked in
60
63
  values.delete(:id)
61
64
 
62
- resp, opts = request(:post, save_url, values, opts)
65
+ resp, opts = execute_resource_request(:post, save_url, values, opts)
63
66
  initialize_from(resp.data, opts)
64
67
  end
65
68
 
@@ -76,7 +76,7 @@ module Stripe
76
76
  end
77
77
 
78
78
  url = "#{resource_url}/#{CGI.escape(id)}/#{CGI.escape(http_path)}"
79
- resp, opts = request(http_verb, url, params, opts)
79
+ resp, opts = execute_resource_request(http_verb, url, params, opts)
80
80
  Util.convert_to_stripe_object(resp.data, opts)
81
81
  end
82
82
  end
@@ -93,7 +93,8 @@ module Stripe
93
93
  end
94
94
 
95
95
  def refresh
96
- resp, opts = request(:get, resource_url, @retrieve_params)
96
+ resp, opts = execute_resource_request(:get, resource_url,
97
+ @retrieve_params)
97
98
  initialize_from(resp.data, opts)
98
99
  end
99
100
 
@@ -105,7 +106,7 @@ module Stripe
105
106
  end
106
107
 
107
108
  protected def request_stripe_object(method:, path:, params:, opts: {})
108
- resp, opts = request(method, path, params, opts)
109
+ resp, opts = execute_resource_request(method, path, params, opts)
109
110
 
110
111
  # If we're getting back this thing, update; otherwise, instantiate.
111
112
  if Util.object_name_matches_class?(resp.data[:object], self.class)
@@ -92,8 +92,8 @@ module Stripe
92
92
 
93
93
  def retrieve(id, opts = {})
94
94
  id, retrieve_params = Util.normalize_id(id)
95
- resp, opts = request(:get, "#{resource_url}/#{CGI.escape(id)}",
96
- retrieve_params, opts)
95
+ url = "#{resource_url}/#{CGI.escape(id)}"
96
+ resp, opts = execute_resource_request(:get, url, retrieve_params, opts)
97
97
  Util.convert_to_stripe_object(resp.data, opts)
98
98
  end
99
99
 
@@ -5,7 +5,7 @@ module Stripe
5
5
  module OAuthOperations
6
6
  extend APIOperations::Request::ClassMethods
7
7
 
8
- def self.request(method, url, params, opts)
8
+ def self.execute_resource_request(method, url, params, opts)
9
9
  opts = Util.normalize_opts(opts)
10
10
  opts[:client] ||= StripeClient.active_client
11
11
  opts[:api_base] ||= Stripe.connect_base
@@ -44,7 +44,7 @@ module Stripe
44
44
  def self.token(params = {}, opts = {})
45
45
  opts = Util.normalize_opts(opts)
46
46
  opts[:api_key] = params[:client_secret] if params[:client_secret]
47
- resp, opts = OAuthOperations.request(
47
+ resp, opts = OAuthOperations.execute_resource_request(
48
48
  :post, "/oauth/token", params, opts
49
49
  )
50
50
  # This is just going to return a generic StripeObject, but that's okay
@@ -54,7 +54,7 @@ module Stripe
54
54
  def self.deauthorize(params = {}, opts = {})
55
55
  opts = Util.normalize_opts(opts)
56
56
  params[:client_id] = get_client_id(params)
57
- resp, opts = OAuthOperations.request(
57
+ resp, opts = OAuthOperations.execute_resource_request(
58
58
  :post, "/oauth/deauthorize", params, opts
59
59
  )
60
60
  # This is just going to return a generic StripeObject, but that's okay
@@ -65,7 +65,7 @@ module Stripe
65
65
  end
66
66
 
67
67
  def persons(params = {}, opts = {})
68
- resp, opts = request(:get, resource_url + "/persons", params, opts)
68
+ resp, opts = execute_resource_request(:get, resource_url + "/persons", params, opts)
69
69
  Util.convert_to_stripe_object(resp.data, opts)
70
70
  end
71
71
 
@@ -10,7 +10,7 @@ module Stripe
10
10
  OBJECT_NAME = "bank_account"
11
11
 
12
12
  def verify(params = {}, opts = {})
13
- resp, opts = request(:post, resource_url + "/verify", params, opts)
13
+ resp, opts = execute_resource_request(:post, resource_url + "/verify", params, opts)
14
14
  initialize_from(resp.data, opts)
15
15
  end
16
16
 
@@ -21,12 +21,12 @@ module Stripe
21
21
  end
22
22
 
23
23
  def self.preview(params, opts = {})
24
- resp, opts = request(:get, resource_url + "/preview", params, opts)
24
+ resp, opts = execute_resource_request(:get, resource_url + "/preview", params, opts)
25
25
  Util.convert_to_stripe_object(resp.data, opts)
26
26
  end
27
27
 
28
28
  def self.list_preview_line_items(params, opts = {})
29
- resp, opts = request(:get, resource_url + "/preview/lines", params, opts)
29
+ resp, opts = execute_resource_request(:get, resource_url + "/preview/lines", params, opts)
30
30
  Util.convert_to_stripe_object(resp.data, opts)
31
31
  end
32
32
  end
@@ -29,7 +29,7 @@ module Stripe
29
29
  end
30
30
 
31
31
  def delete_discount
32
- resp, opts = request(:delete, resource_url + "/discount")
32
+ resp, opts = execute_resource_request(:delete, resource_url + "/discount")
33
33
  initialize_from(resp.data, opts, true)
34
34
  end
35
35
  end
@@ -62,12 +62,12 @@ module Stripe
62
62
  end
63
63
 
64
64
  def self.upcoming(params, opts = {})
65
- resp, opts = request(:get, resource_url + "/upcoming", params, opts)
65
+ resp, opts = execute_resource_request(:get, resource_url + "/upcoming", params, opts)
66
66
  Util.convert_to_stripe_object(resp.data, opts)
67
67
  end
68
68
 
69
69
  def self.list_upcoming_line_items(params, opts = {})
70
- resp, opts = request(:get, resource_url + "/upcoming/lines", params, opts)
70
+ resp, opts = execute_resource_request(:get, resource_url + "/upcoming/lines", params, opts)
71
71
  Util.convert_to_stripe_object(resp.data, opts)
72
72
  end
73
73
  end
@@ -32,13 +32,13 @@ module Stripe
32
32
 
33
33
  url = "#{Customer.resource_url}/#{CGI.escape(customer)}/sources" \
34
34
  "/#{CGI.escape(id)}"
35
- resp, opts = request(:delete, url, params, opts)
35
+ resp, opts = execute_resource_request(:delete, url, params, opts)
36
36
  initialize_from(resp.data, opts)
37
37
  end
38
38
 
39
39
  def source_transactions(params = {}, opts = {})
40
- resp, opts = request(:get, resource_url + "/source_transactions", params,
41
- opts)
40
+ resp, opts = execute_resource_request(:get, resource_url + "/source_transactions", params,
41
+ opts)
42
42
  Util.convert_to_stripe_object(resp.data, opts)
43
43
  end
44
44
  extend Gem::Deprecate
@@ -17,7 +17,7 @@ module Stripe
17
17
  resource_plural: "usage_record_summaries"
18
18
 
19
19
  def usage_record_summaries(params = {}, opts = {})
20
- resp, opts = request(:get, resource_url + "/usage_record_summaries", params, opts)
20
+ resp, opts = execute_resource_request(:get, resource_url + "/usage_record_summaries", params, opts)
21
21
  Util.convert_to_stripe_object(resp.data, opts)
22
22
  end
23
23
  extend Gem::Deprecate
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Stripe
4
- VERSION = "5.23.0"
4
+ VERSION = "5.23.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stripe
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.23.0
4
+ version: 5.23.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stripe