stripe-ruby/lib/stripe/services/transfer_reversal_service.rb
2024-12-20 19:41:09 +00:00

123 lines
6.0 KiB
Ruby

# File generated from our OpenAPI spec
# frozen_string_literal: true
module Stripe
class TransferReversalService < StripeService
class ListParams < Stripe::RequestParams
# A cursor for use in pagination. `ending_before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list.
attr_accessor :ending_before
# Specifies which fields in the response should be expanded.
attr_accessor :expand
# A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10.
attr_accessor :limit
# A cursor for use in pagination. `starting_after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list.
attr_accessor :starting_after
def initialize(ending_before: nil, expand: nil, limit: nil, starting_after: nil)
@ending_before = ending_before
@expand = expand
@limit = limit
@starting_after = starting_after
end
end
class CreateParams < Stripe::RequestParams
# A positive integer in cents (or local equivalent) representing how much of this transfer to reverse. Can only reverse up to the unreversed amount remaining of the transfer. Partial transfer reversals are only allowed for transfers to Stripe Accounts. Defaults to the entire transfer amount.
attr_accessor :amount
# An arbitrary string which you can attach to a reversal object. This will be unset if you POST an empty value.
attr_accessor :description
# Specifies which fields in the response should be expanded.
attr_accessor :expand
# Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to `metadata`.
attr_accessor :metadata
# Boolean indicating whether the application fee should be refunded when reversing this transfer. If a full transfer reversal is given, the full application fee will be refunded. Otherwise, the application fee will be refunded with an amount proportional to the amount of the transfer reversed.
attr_accessor :refund_application_fee
def initialize(
amount: nil,
description: nil,
expand: nil,
metadata: nil,
refund_application_fee: nil
)
@amount = amount
@description = description
@expand = expand
@metadata = metadata
@refund_application_fee = refund_application_fee
end
end
class RetrieveParams < Stripe::RequestParams
# Specifies which fields in the response should be expanded.
attr_accessor :expand
def initialize(expand: nil)
@expand = expand
end
end
class UpdateParams < Stripe::RequestParams
# Specifies which fields in the response should be expanded.
attr_accessor :expand
# Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to `metadata`.
attr_accessor :metadata
def initialize(expand: nil, metadata: nil)
@expand = expand
@metadata = metadata
end
end
# When you create a new reversal, you must specify a transfer to create it on.
#
# When reversing transfers, you can optionally reverse part of the transfer. You can do so as many times as you wish until the entire transfer has been reversed.
#
# Once entirely reversed, a transfer can't be reversed again. This method will return an error when called on an already-reversed transfer, or when trying to reverse more money than is left on a transfer.
def create(id, params = {}, opts = {})
request(
method: :post,
path: format("/v1/transfers/%<id>s/reversals", { id: CGI.escape(id) }),
params: params,
opts: opts,
base_address: :api
)
end
# You can see a list of the reversals belonging to a specific transfer. Note that the 10 most recent reversals are always available by default on the transfer object. If you need more than those 10, you can use this API method and the limit and starting_after parameters to page through additional reversals.
def list(id, params = {}, opts = {})
request(
method: :get,
path: format("/v1/transfers/%<id>s/reversals", { id: CGI.escape(id) }),
params: params,
opts: opts,
base_address: :api
)
end
# By default, you can see the 10 most recent reversals stored directly on the transfer object, but you can also retrieve details about a specific reversal stored on the transfer.
def retrieve(transfer, id, params = {}, opts = {})
request(
method: :get,
path: format("/v1/transfers/%<transfer>s/reversals/%<id>s", { transfer: CGI.escape(transfer), id: CGI.escape(id) }),
params: params,
opts: opts,
base_address: :api
)
end
# Updates the specified reversal by setting the values of the parameters passed. Any parameters not provided will be left unchanged.
#
# This request only accepts metadata and description as arguments.
def update(transfer, id, params = {}, opts = {})
request(
method: :post,
path: format("/v1/transfers/%<transfer>s/reversals/%<id>s", { transfer: CGI.escape(transfer), id: CGI.escape(id) }),
params: params,
opts: opts,
base_address: :api
)
end
end
end