stripe-ruby/lib/stripe/singleton_api_resource.rb
helenye-stripe 41f5d0a594
Merge and codegen from master stripe-ruby v13.0.0 (#1465)
* Support for APIs in the new API version 2024-09-30.acacia (#1458)

* remove parseSnapshotEvent (#1463)

* Bump version to 13.0.0

* Fixed API Version

---------

Co-authored-by: Ramya Rao <100975018+ramya-stripe@users.noreply.github.com>
Co-authored-by: Ramya Rao <ramya@stripe.com>
Co-authored-by: Prathmesh Ranaut <prathmesh@stripe.com>
2024-10-03 16:31:59 -04:00

27 lines
763 B
Ruby

# frozen_string_literal: true
module Stripe
class SingletonAPIResource < APIResource
def self.resource_url
if self == SingletonAPIResource
raise NotImplementedError,
"SingletonAPIResource is an abstract class. You should " \
"perform actions on its subclasses (Balance, etc.)"
end
# Namespaces are separated in object names with periods (.) and in URLs
# with forward slashes (/), so replace the former with the latter.
"/v1/#{object_name.downcase.tr('.', '/')}"
end
def resource_url
self.class.resource_url
end
def self.retrieve(params = {}, opts = {})
instance = new(params, Util.normalize_opts(opts))
instance.refresh
instance
end
end
end