stripe-ruby/lib/stripe/resources/treasury/inbound_transfer.rb
2024-08-22 18:46:07 +00:00

131 lines
5.0 KiB
Ruby

# File generated from our OpenAPI spec
# frozen_string_literal: true
module Stripe
module Treasury
# Use [InboundTransfers](https://docs.stripe.com/docs/treasury/moving-money/financial-accounts/into/inbound-transfers) to add funds to your [FinancialAccount](https://stripe.com/docs/api#financial_accounts) via a PaymentMethod that is owned by you. The funds will be transferred via an ACH debit.
#
# Related guide: [Moving money with Treasury using InboundTransfer objects](https://docs.stripe.com/docs/treasury/moving-money/financial-accounts/into/inbound-transfers)
class InboundTransfer < APIResource
extend Stripe::APIOperations::Create
extend Stripe::APIOperations::List
OBJECT_NAME = "treasury.inbound_transfer"
def self.object_name
"treasury.inbound_transfer"
end
# Cancels an InboundTransfer.
def cancel(params = {}, opts = {})
request_stripe_object(
method: :post,
path: format("/v1/treasury/inbound_transfers/%<inbound_transfer>s/cancel", { inbound_transfer: CGI.escape(self["id"]) }),
params: params,
opts: opts
)
end
# Cancels an InboundTransfer.
def self.cancel(inbound_transfer, params = {}, opts = {})
request_stripe_object(
method: :post,
path: format("/v1/treasury/inbound_transfers/%<inbound_transfer>s/cancel", { inbound_transfer: CGI.escape(inbound_transfer) }),
params: params,
opts: opts
)
end
# Creates an InboundTransfer.
def self.create(params = {}, opts = {})
request_stripe_object(
method: :post,
path: "/v1/treasury/inbound_transfers",
params: params,
opts: opts
)
end
# Returns a list of InboundTransfers sent from the specified FinancialAccount.
def self.list(filters = {}, opts = {})
request_stripe_object(
method: :get,
path: "/v1/treasury/inbound_transfers",
params: filters,
opts: opts
)
end
def test_helpers
TestHelpers.new(self)
end
class TestHelpers < APIResourceTestHelpers
RESOURCE_CLASS = InboundTransfer
def self.resource_class
"InboundTransfer"
end
# Transitions a test mode created InboundTransfer to the failed status. The InboundTransfer must already be in the processing state.
def self.fail(id, params = {}, opts = {})
request_stripe_object(
method: :post,
path: format("/v1/test_helpers/treasury/inbound_transfers/%<id>s/fail", { id: CGI.escape(id) }),
params: params,
opts: opts
)
end
# Transitions a test mode created InboundTransfer to the failed status. The InboundTransfer must already be in the processing state.
def fail(params = {}, opts = {})
@resource.request_stripe_object(
method: :post,
path: format("/v1/test_helpers/treasury/inbound_transfers/%<id>s/fail", { id: CGI.escape(@resource["id"]) }),
params: params,
opts: opts
)
end
# Marks the test mode InboundTransfer object as returned and links the InboundTransfer to a ReceivedDebit. The InboundTransfer must already be in the succeeded state.
def self.return_inbound_transfer(id, params = {}, opts = {})
request_stripe_object(
method: :post,
path: format("/v1/test_helpers/treasury/inbound_transfers/%<id>s/return", { id: CGI.escape(id) }),
params: params,
opts: opts
)
end
# Marks the test mode InboundTransfer object as returned and links the InboundTransfer to a ReceivedDebit. The InboundTransfer must already be in the succeeded state.
def return_inbound_transfer(params = {}, opts = {})
@resource.request_stripe_object(
method: :post,
path: format("/v1/test_helpers/treasury/inbound_transfers/%<id>s/return", { id: CGI.escape(@resource["id"]) }),
params: params,
opts: opts
)
end
# Transitions a test mode created InboundTransfer to the succeeded status. The InboundTransfer must already be in the processing state.
def self.succeed(id, params = {}, opts = {})
request_stripe_object(
method: :post,
path: format("/v1/test_helpers/treasury/inbound_transfers/%<id>s/succeed", { id: CGI.escape(id) }),
params: params,
opts: opts
)
end
# Transitions a test mode created InboundTransfer to the succeeded status. The InboundTransfer must already be in the processing state.
def succeed(params = {}, opts = {})
@resource.request_stripe_object(
method: :post,
path: format("/v1/test_helpers/treasury/inbound_transfers/%<id>s/succeed", { id: CGI.escape(@resource["id"]) }),
params: params,
opts: opts
)
end
end
end
end
end