stripe-ruby/lib/stripe/resources/credit_note.rb
Brandur 3433130c5d
Rename API resource's request method (#936)
As seen in #928, the `refresh` method doesn't work for an event class.
This is because event has a field called `request`, and it ends up
replacing the `request` method that it inherited from being an API
resource, so when `refresh` tries to make a request, it fails because it
tries to invoke it on the accessor added for the event's property.

Here we give `request` a much more unique name so that it will never
conflict with a property field again, and update all internal references
to use the new name. We use `alias` to make the old name available for
backwards compatibility reasons because its been around for so long that
people are probably calling it.

Fixes #928.
2020-08-05 16:00:37 -07:00

34 lines
961 B
Ruby

# File generated from our OpenAPI spec
# frozen_string_literal: true
module Stripe
class CreditNote < APIResource
extend Stripe::APIOperations::Create
extend Stripe::APIOperations::List
include Stripe::APIOperations::Save
OBJECT_NAME = "credit_note"
custom_method :void_credit_note, http_verb: :post, http_path: "void"
def void_credit_note(params = {}, opts = {})
request_stripe_object(
method: :post,
path: resource_url + "/void",
params: params,
opts: opts
)
end
def self.preview(params, opts = {})
resp, opts = execute_resource_request(:get, resource_url + "/preview", params, opts)
Util.convert_to_stripe_object(resp.data, opts)
end
def self.list_preview_line_items(params, opts = {})
resp, opts = execute_resource_request(:get, resource_url + "/preview/lines", params, opts)
Util.convert_to_stripe_object(resp.data, opts)
end
end
end