Class: Dinie::Resources::Customers::CreditOffers

Inherits:
Object
  • Object
show all
Defined in:
lib/dinie/generated/resources/customers.rb

Overview

Operations on the credit offers resource.

Instance Method Summary collapse

Constructor Details

#initialize(http) ⇒ CreditOffers

Returns a new instance of CreditOffers.



138
139
140
# File 'lib/dinie/generated/resources/customers.rb', line 138

def initialize(http)
  @http = http
end

Instance Method Details

#list(customer_id, limit: Internal::OMIT, starting_after: Internal::OMIT, request_options: {}, **filters) ⇒ Object

List credit offers for a customer

List credit offers for a specific customer, filterable by ‘status`

Parameters:

  • customer_id (String)

    Identificador único do cliente

  • fields (Hash)

    Request body fields.

  • request_options (Hash) (defaults to: {})

    Request options.

Returns:

  • (Object)


150
151
152
153
154
155
156
157
158
159
# File 'lib/dinie/generated/resources/customers.rb', line 150

def list(customer_id, limit: Internal::OMIT, starting_after: Internal::OMIT, request_options: {}, **filters)
  path = "/customers/#{customer_id}/credit-offers"
  fetch_page = lambda do |cursor|
    query = { limit:, starting_after: cursor || starting_after, **filters }
            .reject { |_key, value| Internal.omitted?(value) }
    body = @http.request(method: :get, path:, query:, request_options:)
    { data: body[:data].map { |raw| CreditOffer.deserialize(raw) }, has_more: body[:has_more] }
  end
  Dinie::Page.from_fetch(fetch_page)
end