Class: Lithic::Resources::Holds

Inherits:
Object
  • Object
show all
Defined in:
lib/lithic/resources/holds.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Holds

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Holds.

Parameters:



127
128
129
# File 'lib/lithic/resources/holds.rb', line 127

def initialize(client:)
  @client = client
end

Instance Method Details

#create(financial_account_token, amount:, token: nil, expiration_datetime: nil, memo: nil, user_defined_id: nil, request_options: {}) ⇒ Lithic::Models::Hold

Create a hold on a financial account. Holds reserve funds by moving them from available to pending balance. They can be resolved via settlement (linked to a payment or book transfer), voiding, or expiration.

Parameters:

  • financial_account_token (String)

    Globally unique identifier for the financial account.

  • amount (Integer)

    Amount to hold in cents

  • token (String)

    Customer-provided token for idempotency. Becomes the hold token.

  • expiration_datetime (Time)

    When the hold should auto-expire

  • memo (String, nil)

    Reason for the hold

  • user_defined_id (String)

    User-provided identifier for the hold

  • request_options (Lithic::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



29
30
31
32
33
34
35
36
37
38
# File 'lib/lithic/resources/holds.rb', line 29

def create(, params)
  parsed, options = Lithic::HoldCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["v1/financial_accounts/%1$s/holds", ],
    body: parsed,
    model: Lithic::Hold,
    options: options
  )
end

#list(financial_account_token, begin_: nil, end_: nil, ending_before: nil, page_size: nil, starting_after: nil, status: nil, request_options: {}) ⇒ Lithic::Internal::CursorPage<Lithic::Models::Hold>

Some parameter documentations has been truncated, see Models::HoldListParams for more details.

List holds for a financial account.

Parameters:

  • financial_account_token (String)

    Globally unique identifier for the financial account.

  • begin_ (Time)

    Date string in RFC 3339 format. Only entries created after the specified time wi

  • end_ (Time)

    Date string in RFC 3339 format. Only entries created before the specified time w

  • ending_before (String)

    A cursor representing an item’s token before which a page of results should end.

  • page_size (Integer)

    Page size (for pagination).

  • starting_after (String)

    A cursor representing an item’s token after which a page of results should begin

  • status (Symbol, Lithic::Models::HoldListParams::Status)

    Hold status to filter by.

  • request_options (Lithic::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/lithic/resources/holds.rb', line 86

def list(, params = {})
  parsed, options = Lithic::HoldListParams.dump_request(params)
  query = Lithic::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["v1/financial_accounts/%1$s/holds", ],
    query: query.transform_keys(begin_: "begin", end_: "end"),
    page: Lithic::Internal::CursorPage,
    model: Lithic::Hold,
    options: options
  )
end

#retrieve(hold_token, request_options: {}) ⇒ Lithic::Models::Hold

Get hold by token.

Parameters:

  • hold_token (String)

    Globally unique identifier for the hold.

  • request_options (Lithic::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



51
52
53
54
55
56
57
58
# File 'lib/lithic/resources/holds.rb', line 51

def retrieve(hold_token, params = {})
  @client.request(
    method: :get,
    path: ["v1/holds/%1$s", hold_token],
    model: Lithic::Hold,
    options: params[:request_options]
  )
end

#void(hold_token, memo: nil, request_options: {}) ⇒ Lithic::Models::Hold

Void an active hold. This returns the held funds from pending back to available balance. Only holds in PENDING status can be voided.

Parameters:

  • hold_token (String)

    Globally unique identifier for the hold.

  • memo (String, nil)

    Reason for voiding the hold

  • request_options (Lithic::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



113
114
115
116
117
118
119
120
121
122
# File 'lib/lithic/resources/holds.rb', line 113

def void(hold_token, params = {})
  parsed, options = Lithic::HoldVoidParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["v1/holds/%1$s/void", hold_token],
    body: parsed,
    model: Lithic::Hold,
    options: options
  )
end