Skip to content

Commit

Permalink
Merge upstream and update generated code for v1415
Browse files Browse the repository at this point in the history
  • Loading branch information
stripe-openapi[bot] committed Dec 18, 2024
2 parents f492781 + 8aec85f commit f544b0d
Show file tree
Hide file tree
Showing 17 changed files with 48 additions and 11 deletions.
2 changes: 1 addition & 1 deletion OPENAPI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1414
v1415
2 changes: 1 addition & 1 deletion lib/stripe/resources/invoice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class Issuer < Stripe::StripeObject
end

class LastFinalizationError < Stripe::StripeObject
attr_reader :charge, :code, :decline_code, :doc_url, :message, :network_advice_code, :network_decline_code, :param, :payment_intent, :payment_method, :payment_method_type, :request_log_url, :setup_intent, :source, :type
attr_reader :advice_code, :charge, :code, :decline_code, :doc_url, :message, :network_advice_code, :network_decline_code, :param, :payment_intent, :payment_method, :payment_method_type, :request_log_url, :setup_intent, :source, :type
end

class PaymentSettings < Stripe::StripeObject
Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/resources/payment_intent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class AutomaticPaymentMethods < Stripe::StripeObject
end

class LastPaymentError < Stripe::StripeObject
attr_reader :charge, :code, :decline_code, :doc_url, :message, :network_advice_code, :network_decline_code, :param, :payment_intent, :payment_method, :payment_method_type, :request_log_url, :setup_intent, :source, :type
attr_reader :advice_code, :charge, :code, :decline_code, :doc_url, :message, :network_advice_code, :network_decline_code, :param, :payment_intent, :payment_method, :payment_method_type, :request_log_url, :setup_intent, :source, :type
end

class NextAction < Stripe::StripeObject
Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/resources/quote_preview_invoice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class Issuer < Stripe::StripeObject
end

class LastFinalizationError < Stripe::StripeObject
attr_reader :charge, :code, :decline_code, :doc_url, :message, :network_advice_code, :network_decline_code, :param, :payment_intent, :payment_method, :payment_method_type, :request_log_url, :setup_intent, :source, :type
attr_reader :advice_code, :charge, :code, :decline_code, :doc_url, :message, :network_advice_code, :network_decline_code, :param, :payment_intent, :payment_method, :payment_method_type, :request_log_url, :setup_intent, :source, :type
end

class PaymentSettings < Stripe::StripeObject
Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/resources/setup_attempt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class UsBankAccount < Stripe::StripeObject; end
end

class SetupError < Stripe::StripeObject
attr_reader :charge, :code, :decline_code, :doc_url, :message, :network_advice_code, :network_decline_code, :param, :payment_intent, :payment_method, :payment_method_type, :request_log_url, :setup_intent, :source, :type
attr_reader :advice_code, :charge, :code, :decline_code, :doc_url, :message, :network_advice_code, :network_decline_code, :param, :payment_intent, :payment_method, :payment_method_type, :request_log_url, :setup_intent, :source, :type
end
# The value of [application](https://stripe.com/docs/api/setup_intents/object#setup_intent_object-application) on the SetupIntent at the time of this confirmation.
attr_reader :application
Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/resources/setup_intent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class AutomaticPaymentMethods < Stripe::StripeObject
end

class LastSetupError < Stripe::StripeObject
attr_reader :charge, :code, :decline_code, :doc_url, :message, :network_advice_code, :network_decline_code, :param, :payment_intent, :payment_method, :payment_method_type, :request_log_url, :setup_intent, :source, :type
attr_reader :advice_code, :charge, :code, :decline_code, :doc_url, :message, :network_advice_code, :network_decline_code, :param, :payment_intent, :payment_method, :payment_method_type, :request_log_url, :setup_intent, :source, :type
end

class NextAction < Stripe::StripeObject
Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/stripe_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def raw_request(method, url, base_address: :api, params: {}, opts: {})

def deserialize(data, api_mode: :v1)
data = JSON.parse(data) if data.is_a?(String)
Util.convert_to_stripe_object(data, {}, api_mode: api_mode)
Util.convert_to_stripe_object(data, {}, api_mode: api_mode, requestor: @requestor)
end
end
end
6 changes: 3 additions & 3 deletions lib/stripe/stripe_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def inspect
def update_attributes(values, opts = {}, dirty: true)
values.each do |k, v|
add_accessors([k], values) unless metaclass.method_defined?(k.to_sym)
@values[k] = Util.convert_to_stripe_object(v, opts, api_mode: @api_mode)
@values[k] = Util.convert_to_stripe_object(v, opts, api_mode: @api_mode, requestor: @requestor)
dirty_value!(@values[k]) if dirty
@unsaved_values.add(k)
end
Expand Down Expand Up @@ -362,7 +362,7 @@ class << self; self; end
"We interpret empty strings as nil in requests. " \
"You may set (object).#{k} = nil to delete the property."
end
@values[k] = Util.convert_to_stripe_object(v, @opts, api_mode: @api_mode)
@values[k] = Util.convert_to_stripe_object(v, @opts, api_mode: @api_mode, requestor: @requestor)
dirty_value!(@values[k])
@unsaved_values.add(k)
end
Expand Down Expand Up @@ -539,7 +539,7 @@ class << self; self; end
# example by appending a new hash onto `additional_owners` for an
# account.
elsif value.is_a?(Hash)
Util.convert_to_stripe_object(value, @opts).serialize_params
Util.convert_to_stripe_object(value, @opts, api_mode: @api_mode, requestor: @requestor).serialize_params

elsif value.is_a?(StripeObject)
update = value.serialize_params(force: force)
Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def self.convert_to_stripe_object_with_params(

case data
when Array
data.map { |i| convert_to_stripe_object(i, opts, api_mode: api_mode) }
data.map { |i| convert_to_stripe_object(i, opts, api_mode: api_mode, requestor: requestor) }
when Hash
# TODO: This is a terrible hack.
# Waiting on https://jira.corp.stripe.com/browse/API_SERVICES-3167 to add
Expand Down
2 changes: 2 additions & 0 deletions rbi/stripe/resources/invoice.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ module Stripe
attr_reader :type
end
class LastFinalizationError < Stripe::StripeObject
sig { returns(String) }
attr_reader :advice_code
sig { returns(String) }
attr_reader :charge
sig { returns(String) }
Expand Down
2 changes: 2 additions & 0 deletions rbi/stripe/resources/payment_intent.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ module Stripe
attr_reader :enabled
end
class LastPaymentError < Stripe::StripeObject
sig { returns(String) }
attr_reader :advice_code
sig { returns(String) }
attr_reader :charge
sig { returns(String) }
Expand Down
2 changes: 2 additions & 0 deletions rbi/stripe/resources/quote_preview_invoice.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ module Stripe
attr_reader :type
end
class LastFinalizationError < Stripe::StripeObject
sig { returns(String) }
attr_reader :advice_code
sig { returns(String) }
attr_reader :charge
sig { returns(String) }
Expand Down
2 changes: 2 additions & 0 deletions rbi/stripe/resources/setup_attempt.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ module Stripe
attr_reader :us_bank_account
end
class SetupError < Stripe::StripeObject
sig { returns(String) }
attr_reader :advice_code
sig { returns(String) }
attr_reader :charge
sig { returns(String) }
Expand Down
2 changes: 2 additions & 0 deletions rbi/stripe/resources/setup_intent.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ module Stripe
attr_reader :enabled
end
class LastSetupError < Stripe::StripeObject
sig { returns(String) }
attr_reader :advice_code
sig { returns(String) }
attr_reader :charge
sig { returns(String) }
Expand Down
7 changes: 7 additions & 0 deletions test/stripe/list_object_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ class ListObjectTest < Test::Unit::TestCase
assert_equal 1, list.count
end

should "be able to refresh objects in list" do
list = Stripe::Customer.list
assert_not_nil list.first.instance_variable_get(:@requestor)
cus = list.first.refresh
assert cus.is_a?(Stripe::Customer)
end

should "provide #each" do
arr = [
{ id: 1 },
Expand Down
7 changes: 7 additions & 0 deletions test/stripe/search_result_object_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ class SearchResultObjectTest < Test::Unit::TestCase
assert_equal 1, list.count
end

should "be able to refresh objects in search" do
list = Stripe::Customer.search({ query: "name:'fakename'" })
assert_not_nil list.first.instance_variable_get(:@requestor)
cus = list.first.refresh
assert cus.is_a?(Stripe::Customer)
end

should "provide #each" do
arr = [
{ id: 1 },
Expand Down
13 changes: 13 additions & 0 deletions test/stripe/stripe_client_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,19 @@ class StripeClientTest < Test::Unit::TestCase
assert_equal obj.id, "acc_123"
end

should "allow refresh on deserialized object" do
expected_body = "{\"id\": \"acc_123\", \"object\": \"account\"}"

stub_request(:get, "#{Stripe::DEFAULT_API_BASE}/v1/accounts/acc_123")
.to_return(status: 200, body: expected_body)

obj = @client.deserialize(expected_body)
obj = obj.refresh

assert_equal obj.class, Stripe::Account
assert_equal obj.id, "acc_123"
end

should "deserializes hash into unknown object" do
expected_body = { "id" => "acc_123", "object" => "unknown" }

Expand Down

0 comments on commit f544b0d

Please sign in to comment.