stripe 10.14.0 → 10.15.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
  SHA256:
3
- metadata.gz: 4e005b6f71d3104349ec84fd1828b46bd94131b49a746233231654a682da91a1
4
- data.tar.gz: c04f1e21e02e4a615a6477cddd1dc11130998ffcc90d2afc66ad73131e435cfa
3
+ metadata.gz: 2c6299b4afca3ee89da389e6dc45eee600eba9f3dfa66fa7120826e4dc9ce006
4
+ data.tar.gz: 66073d85adc239428168012cc7585401347ea5ac4384ec910e13aa49c2d44dcb
5
5
  SHA512:
6
- metadata.gz: 8f56042df34d499b9fb85a4e8fba37a9a048cc9830caad148442fd629d34c943c5c5ea425e066007625a6bb8124de7cd53223a511d09fd495bba068038b2375d
7
- data.tar.gz: 175595f2208cfdb6c952d4b163e2e86121e0bd0fe1afc0164368f5cbf72e471a46a0ff721274c1e1fd8de329c71f91029790573a99a4b94a782b22be16fa585e
6
+ metadata.gz: 8535cb9457a19a0acbf7d3faf0e77efc0b457f36c30adc80196b53d771db7f7170da9517f9f0cbb656ed6701411f34ba981f64e2f5f7256e67f66662d7e3f57a
7
+ data.tar.gz: 1a8732f5540d740710a136fbe0a3c29f56b6d4ed904411fcec573aa30901d38a84830795c0f03aee4dc6e670fa35ed189c230c361f3e9776b9912af9af7c7892
data/CHANGELOG.md CHANGED
@@ -1,4 +1,13 @@
1
1
  # Changelog
2
+ ## 10.15.0 - 2024-04-09
3
+ * [#1377](https://github.com/stripe/stripe-ruby/pull/1377) Add last_response to StripeObject
4
+ * Users can now retrieve raw response from the returned resource, using the `last_response` property. See [README](https://github.com/stripe/stripe-ruby/blob/master/README.md) for an example.
5
+ * [#1372](https://github.com/stripe/stripe-ruby/pull/1372) Update generated code
6
+ * Add support for new resources `Entitlements.ActiveEntitlement` and `Entitlements.Feature`
7
+ * Add support for `list` and `retrieve` methods on resource `ActiveEntitlement`
8
+ * Add support for `create`, `list`, `retrieve`, and `update` methods on resource `Feature`
9
+ * [#1366](https://github.com/stripe/stripe-ruby/pull/1366) Move executables to `exe` folder
10
+
2
11
  ## 10.14.0 - 2024-03-28
3
12
  * [#1369](https://github.com/stripe/stripe-ruby/pull/1369) Update generated code
4
13
  * Add support for new resources `Billing.MeterEventAdjustment`, `Billing.MeterEvent`, and `Billing.Meter`
data/OPENAPI_VERSION CHANGED
@@ -1 +1 @@
1
- v908
1
+ v938
data/README.md CHANGED
@@ -150,15 +150,13 @@ puts customer.unknown # raises NoMethodError
150
150
 
151
151
  ### Accessing a response object
152
152
 
153
- Get access to response objects by initializing a client and using its `request`
154
- method:
153
+ Get access to response objects by using the `last_response` property of the returned resource:
155
154
 
156
155
  ```ruby
157
- client = Stripe::StripeClient.new
158
- customer, resp = client.request do
159
- Stripe::Customer.retrieve('cus_123456789',)
160
- end
161
- puts resp.request_id
156
+ customer = Stripe::Customer.retrieve('cus_123456789')
157
+
158
+ print(customer.last_response.http_status) # to retrieve status code
159
+ print(customer.last_response.http_headers) # to retrieve headers
162
160
  ```
163
161
 
164
162
  ### Configuring a proxy
data/VERSION CHANGED
@@ -1 +1 @@
1
- 10.14.0
1
+ 10.15.0
@@ -27,7 +27,7 @@ module Stripe
27
27
 
28
28
  private def request_stripe_object(method:, path:, params:, opts: {}, usage: [])
29
29
  resp, opts = execute_resource_request(method, path, params, opts, usage)
30
- Util.convert_to_stripe_object_with_params(resp.data, params, opts)
30
+ Util.convert_to_stripe_object_with_params(resp.data, params, opts, resp)
31
31
  end
32
32
 
33
33
  private def execute_resource_request_internal(client_request_method_sym,
@@ -129,7 +129,7 @@ module Stripe
129
129
 
130
130
  private def request_stripe_object(method:, path:, params:, opts: {}, usage: [])
131
131
  resp, opts = execute_resource_request(method, path, params, opts, usage)
132
- Util.convert_to_stripe_object_with_params(resp.data, params, opts)
132
+ Util.convert_to_stripe_object_with_params(resp.data, params, opts, resp)
133
133
  end
134
134
 
135
135
  # See notes on `alias` above.
@@ -67,7 +67,7 @@ module Stripe
67
67
  values.delete(:id)
68
68
 
69
69
  resp, opts = execute_resource_request(:post, save_url, values, opts, ["save"])
70
- initialize_from(resp.data, opts)
70
+ initialize_from(resp.data, opts, resp)
71
71
  end
72
72
  extend Gem::Deprecate
73
73
  deprecate :save, "the `update` class method (for examples " \
@@ -62,7 +62,7 @@ module Stripe
62
62
  values = serialize_params(self).merge(params)
63
63
 
64
64
  resp, opts = execute_resource_request(:post, resource_url, values, opts, ["save"])
65
- initialize_from(resp.data, opts)
65
+ initialize_from(resp.data, opts, resp)
66
66
  end
67
67
  extend Gem::Deprecate
68
68
  deprecate :save, "the `update` class method (for examples " \
@@ -89,7 +89,7 @@ module Stripe
89
89
  def refresh
90
90
  resp, opts = execute_resource_request(:get, resource_url,
91
91
  @retrieve_params)
92
- initialize_from(resp.data, opts)
92
+ initialize_from(resp.data, opts, resp)
93
93
  end
94
94
 
95
95
  def self.retrieve(id, opts = {})
@@ -104,9 +104,9 @@ module Stripe
104
104
 
105
105
  # If we're getting back this thing, update; otherwise, instantiate.
106
106
  if Util.object_name_matches_class?(resp.data[:object], self.class)
107
- initialize_from(resp.data, opts)
107
+ initialize_from(resp.data, opts, resp)
108
108
  else
109
- Util.convert_to_stripe_object_with_params(resp.data, params, opts)
109
+ Util.convert_to_stripe_object_with_params(resp.data, params, opts, resp)
110
110
  end
111
111
  end
112
112
 
@@ -48,6 +48,8 @@ module Stripe
48
48
  CustomerSession.object_name => CustomerSession,
49
49
  Discount.object_name => Discount,
50
50
  Dispute.object_name => Dispute,
51
+ Entitlements::ActiveEntitlement.object_name => Entitlements::ActiveEntitlement,
52
+ Entitlements::Feature.object_name => Entitlements::Feature,
51
53
  EphemeralKey.object_name => EphemeralKey,
52
54
  Event.object_name => Event,
53
55
  ExchangeRate.object_name => ExchangeRate,
@@ -86,6 +88,7 @@ module Stripe
86
88
  Plan.object_name => Plan,
87
89
  Price.object_name => Price,
88
90
  Product.object_name => Product,
91
+ ProductFeature.object_name => ProductFeature,
89
92
  PromotionCode.object_name => PromotionCode,
90
93
  Quote.object_name => Quote,
91
94
  Radar::EarlyFraudWarning.object_name => Radar::EarlyFraudWarning,
@@ -0,0 +1,26 @@
1
+ # File generated from our OpenAPI spec
2
+ # frozen_string_literal: true
3
+
4
+ module Stripe
5
+ module Entitlements
6
+ # An active entitlement describes access to a feature for a customer.
7
+ class ActiveEntitlement < APIResource
8
+ extend Stripe::APIOperations::List
9
+
10
+ OBJECT_NAME = "entitlements.active_entitlement"
11
+ def self.object_name
12
+ "entitlements.active_entitlement"
13
+ end
14
+
15
+ # Retrieve a list of active entitlements for a customer
16
+ def self.list(filters = {}, opts = {})
17
+ request_stripe_object(
18
+ method: :get,
19
+ path: "/v1/entitlements/active_entitlements",
20
+ params: filters,
21
+ opts: opts
22
+ )
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,49 @@
1
+ # File generated from our OpenAPI spec
2
+ # frozen_string_literal: true
3
+
4
+ module Stripe
5
+ module Entitlements
6
+ # A feature represents a monetizable ability or functionality in your system.
7
+ # Features can be assigned to products, and when those products are purchased, Stripe will create an entitlement to the feature for the purchasing customer.
8
+ class Feature < APIResource
9
+ extend Stripe::APIOperations::Create
10
+ extend Stripe::APIOperations::List
11
+ include Stripe::APIOperations::Save
12
+
13
+ OBJECT_NAME = "entitlements.feature"
14
+ def self.object_name
15
+ "entitlements.feature"
16
+ end
17
+
18
+ # Creates a feature
19
+ def self.create(params = {}, opts = {})
20
+ request_stripe_object(
21
+ method: :post,
22
+ path: "/v1/entitlements/features",
23
+ params: params,
24
+ opts: opts
25
+ )
26
+ end
27
+
28
+ # Retrieve a list of features
29
+ def self.list(filters = {}, opts = {})
30
+ request_stripe_object(
31
+ method: :get,
32
+ path: "/v1/entitlements/features",
33
+ params: filters,
34
+ opts: opts
35
+ )
36
+ end
37
+
38
+ # Update a feature's metadata or permanently deactivate it.
39
+ def self.update(id, params = {}, opts = {})
40
+ request_stripe_object(
41
+ method: :post,
42
+ path: format("/v1/entitlements/features/%<id>s", { id: CGI.escape(id) }),
43
+ params: params,
44
+ opts: opts
45
+ )
46
+ end
47
+ end
48
+ end
49
+ end
@@ -182,7 +182,7 @@ module Stripe
182
182
  #
183
183
  # Note that when you are viewing an upcoming invoice, you are simply viewing a preview – the invoice has not yet been created. As such, the upcoming invoice will not show up in invoice listing calls, and you cannot use the API to pay or edit the invoice. If you want to change the amount that your customer will be billed, you can add, remove, or update pending invoice items, or update the customer's discount.
184
184
  #
185
- # You can preview the effects of updating a subscription, including a preview of what proration will take place. To ensure that the actual proration is calculated exactly the same as the previewed proration, you should pass a proration_date parameter when doing the actual subscription update. The value passed in should be the same as the subscription_proration_date returned on the upcoming invoice resource. The recommended way to get only the prorations being previewed is to consider only proration line items where period[start] is equal to the subscription_proration_date on the upcoming invoice resource.
185
+ # You can preview the effects of updating a subscription, including a preview of what proration will take place. To ensure that the actual proration is calculated exactly the same as the previewed proration, you should pass the subscription_proration_date parameter when doing the actual subscription update. The recommended way to get only the prorations being previewed is to consider only proration line items where period[start] is equal to the subscription_proration_date value passed in the request.
186
186
  def self.upcoming(params = {}, opts = {})
187
187
  request_stripe_object(method: :get, path: "/v1/invoices/upcoming", params: params, opts: opts)
188
188
  end
@@ -14,6 +14,7 @@ module Stripe
14
14
  extend Stripe::APIOperations::Create
15
15
  include Stripe::APIOperations::Delete
16
16
  extend Stripe::APIOperations::List
17
+ extend Stripe::APIOperations::NestedResource
17
18
  extend Stripe::APIOperations::Search
18
19
  include Stripe::APIOperations::Save
19
20
 
@@ -22,6 +23,8 @@ module Stripe
22
23
  "product"
23
24
  end
24
25
 
26
+ nested_resource_class_methods :feature, operations: %i[create retrieve delete list]
27
+
25
28
  # Creates a new product object.
26
29
  def self.create(params = {}, opts = {})
27
30
  request_stripe_object(method: :post, path: "/v1/products", params: params, opts: opts)
@@ -0,0 +1,13 @@
1
+ # File generated from our OpenAPI spec
2
+ # frozen_string_literal: true
3
+
4
+ module Stripe
5
+ # A product_feature represents an attachment between a feature and a product.
6
+ # When a product is purchased that has a feature attached, Stripe will create an entitlement to the feature for the purchasing customer.
7
+ class ProductFeature < APIResource
8
+ OBJECT_NAME = "product_feature"
9
+ def self.object_name
10
+ "product_feature"
11
+ end
12
+ end
13
+ end
@@ -36,6 +36,8 @@ require "stripe/resources/customer_cash_balance_transaction"
36
36
  require "stripe/resources/customer_session"
37
37
  require "stripe/resources/discount"
38
38
  require "stripe/resources/dispute"
39
+ require "stripe/resources/entitlements/active_entitlement"
40
+ require "stripe/resources/entitlements/feature"
39
41
  require "stripe/resources/ephemeral_key"
40
42
  require "stripe/resources/event"
41
43
  require "stripe/resources/exchange_rate"
@@ -74,6 +76,7 @@ require "stripe/resources/person"
74
76
  require "stripe/resources/plan"
75
77
  require "stripe/resources/price"
76
78
  require "stripe/resources/product"
79
+ require "stripe/resources/product_feature"
77
80
  require "stripe/resources/promotion_code"
78
81
  require "stripe/resources/quote"
79
82
  require "stripe/resources/radar/early_fraud_warning"
@@ -4,6 +4,8 @@ module Stripe
4
4
  class StripeObject
5
5
  include Enumerable
6
6
 
7
+ attr_reader :last_response
8
+
7
9
  @@permanent_attributes = Set.new([:id]) # rubocop:disable Style/ClassVars
8
10
 
9
11
  # The default :id method is deprecated and isn't useful to us
@@ -80,13 +82,14 @@ module Stripe
80
82
  @unsaved_values = Set.new
81
83
  @transient_values = Set.new
82
84
  @values[:id] = id if id
85
+ @last_response = nil
83
86
  end
84
87
 
85
- def self.construct_from(values, opts = {})
88
+ def self.construct_from(values, opts = {}, last_response = nil)
86
89
  values = Stripe::Util.symbolize_names(values)
87
90
 
88
91
  # work around protected #initialize_from for now
89
- new(values[:id]).send(:initialize_from, values, opts)
92
+ new(values[:id]).send(:initialize_from, values, opts, last_response)
90
93
  end
91
94
 
92
95
  # Determines the equality of two Stripe objects. Stripe objects are
@@ -424,7 +427,9 @@ module Stripe
424
427
  # * +:opts:+ Options for StripeObject like an API key.
425
428
  # * +:partial:+ Indicates that the re-initialization should not attempt to
426
429
  # remove accessors.
427
- protected def initialize_from(values, opts)
430
+ protected def initialize_from(values, opts, last_response = nil)
431
+ @last_response = last_response
432
+
428
433
  @opts = Util.normalize_opts(opts)
429
434
 
430
435
  # the `#send` is here so that we can keep this method private
data/lib/stripe/util.rb CHANGED
@@ -90,7 +90,7 @@ module Stripe
90
90
  opts
91
91
  )
92
92
 
93
- Util.convert_to_stripe_object_with_params(resp.data, params, opts)
93
+ Util.convert_to_stripe_object_with_params(resp.data, params, opts, resp)
94
94
  end
95
95
  end
96
96
 
@@ -124,7 +124,7 @@ module Stripe
124
124
  # * +data+ - Hash of fields and values to be converted into a StripeObject.
125
125
  # * +opts+ - Options for +StripeObject+ like an API key that will be reused
126
126
  # on subsequent API calls.
127
- def self.convert_to_stripe_object_with_params(data, params, opts = {})
127
+ def self.convert_to_stripe_object_with_params(data, params, opts = {}, last_response = nil)
128
128
  opts = normalize_opts(opts)
129
129
 
130
130
  case data
@@ -135,7 +135,7 @@ module Stripe
135
135
  # to generic StripeObject
136
136
  object_name = data[:object] || data["object"]
137
137
  obj = object_classes.fetch(object_name, StripeObject)
138
- .construct_from(data, opts)
138
+ .construct_from(data, opts, last_response)
139
139
 
140
140
  # set filters so that we can fetch the same limit, expansions, and
141
141
  # predicates when accessing the next and previous pages
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Stripe
4
- VERSION = "10.14.0"
4
+ VERSION = "10.15.0"
5
5
  end
data/stripe.gemspec CHANGED
@@ -33,13 +33,12 @@ Gem::Specification.new do |s|
33
33
  /\A\.rubocop/,
34
34
  /\A\.travis.yml/,
35
35
  /\A\.vscode/,
36
- %r{\A(bin/tapioca)},
36
+ /\Abin/,
37
37
  /\Asorbet/,
38
38
  /\Atest/
39
39
  )
40
- s.files = `git ls-files`.split("\n").reject { |f| ignored.match(f) }
41
- s.executables = `git ls-files -- bin/*`.split("\n")
42
- .map { |f| File.basename(f) }
43
- .reject { |f| f == "tapioca" }
40
+ s.files = `git ls-files`.split("\n").grep_v(ignored)
41
+ s.bindir = "exe"
42
+ s.executables = `git ls-files -- exe/*`.split("\n").map { |f| File.basename(f) }
44
43
  s.require_paths = ["lib"]
45
44
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stripe
3
3
  version: !ruby/object:Gem::Version
4
- version: 10.14.0
4
+ version: 10.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stripe
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2024-03-28 00:00:00.000000000 Z
11
+ date: 2024-04-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Stripe is the easiest way to accept payments online. See https://stripe.com
14
14
  for details.
@@ -29,7 +29,7 @@ files:
29
29
  - README.md
30
30
  - Rakefile
31
31
  - VERSION
32
- - bin/stripe-console
32
+ - exe/stripe-console
33
33
  - lib/data/ca-certificates.crt
34
34
  - lib/stripe.rb
35
35
  - lib/stripe/api_operations/create.rb
@@ -88,6 +88,8 @@ files:
88
88
  - lib/stripe/resources/customer_session.rb
89
89
  - lib/stripe/resources/discount.rb
90
90
  - lib/stripe/resources/dispute.rb
91
+ - lib/stripe/resources/entitlements/active_entitlement.rb
92
+ - lib/stripe/resources/entitlements/feature.rb
91
93
  - lib/stripe/resources/ephemeral_key.rb
92
94
  - lib/stripe/resources/event.rb
93
95
  - lib/stripe/resources/exchange_rate.rb
@@ -126,6 +128,7 @@ files:
126
128
  - lib/stripe/resources/plan.rb
127
129
  - lib/stripe/resources/price.rb
128
130
  - lib/stripe/resources/product.rb
131
+ - lib/stripe/resources/product_feature.rb
129
132
  - lib/stripe/resources/promotion_code.rb
130
133
  - lib/stripe/resources/quote.rb
131
134
  - lib/stripe/resources/radar/early_fraud_warning.rb
File without changes