diff --git a/lib/stripe/object_types.rb b/lib/stripe/object_types.rb index e8f2795a0..287b5f9ff 100644 --- a/lib/stripe/object_types.rb +++ b/lib/stripe/object_types.rb @@ -27,6 +27,7 @@ def self.object_names_to_classes BitcoinTransaction::OBJECT_NAME => BitcoinTransaction, Capability::OBJECT_NAME => Capability, Card::OBJECT_NAME => Card, + CashBalance::OBJECT_NAME => CashBalance, Charge::OBJECT_NAME => Charge, Checkout::Session::OBJECT_NAME => Checkout::Session, CountrySpec::OBJECT_NAME => CountrySpec, diff --git a/lib/stripe/resources.rb b/lib/stripe/resources.rb index 51e260aea..9281200cc 100644 --- a/lib/stripe/resources.rb +++ b/lib/stripe/resources.rb @@ -16,6 +16,7 @@ require "stripe/resources/bitcoin_transaction" require "stripe/resources/capability" require "stripe/resources/card" +require "stripe/resources/cash_balance" require "stripe/resources/charge" require "stripe/resources/checkout/session" require "stripe/resources/country_spec" diff --git a/lib/stripe/resources/cash_balance.rb b/lib/stripe/resources/cash_balance.rb new file mode 100644 index 000000000..6671a9f1e --- /dev/null +++ b/lib/stripe/resources/cash_balance.rb @@ -0,0 +1,22 @@ +# File generated from our OpenAPI spec +# frozen_string_literal: true + +module Stripe + class CashBalance < APIResource + OBJECT_NAME = "cash_balance" + + def resource_url + if !respond_to?(:customer) || customer.nil? + raise NotImplementedError, + "Customer Cash Balance cannot be accessed without a customer ID." + end + "#{Customer.resource_url}/#{CGI.escape(customer)}/cash_balance" + end + + def self.retrieve(_id, _opts = {}) + raise NotImplementedError, + "Customer Cash Balance cannot be retrieved without a customer ID. " \ + "Retrieve a Customer Cash Balance using `Customer.retrieve_cash_balance('cus_123')`" + end + end +end diff --git a/lib/stripe/resources/customer.rb b/lib/stripe/resources/customer.rb index f273abcdd..376db0219 100644 --- a/lib/stripe/resources/customer.rb +++ b/lib/stripe/resources/customer.rb @@ -15,6 +15,9 @@ class Customer < APIResource custom_method :create_funding_instructions, http_verb: :post, http_path: "funding_instructions" custom_method :list_payment_methods, http_verb: :get, http_path: "payment_methods" + nested_resource_class_methods :cash_balance, + operations: %i[retrieve update], + resource_plural: "cash_balance" nested_resource_class_methods :balance_transaction, operations: %i[create retrieve update list] nested_resource_class_methods :tax_id,