Class: Orb::Resources::Customers::Credits

Inherits:
Object
  • Object
show all
Defined in:
lib/orb/resources/customers/credits.rb,
lib/orb/resources/customers/credits/ledger.rb,
lib/orb/resources/customers/credits/top_ups.rb

Defined Under Namespace

Classes: Ledger, TopUps

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Credits

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 Credits.

Parameters:



96
97
98
99
100
# File 'lib/orb/resources/customers/credits.rb', line 96

def initialize(client:)
  @client = client
  @ledger = Orb::Resources::Customers::Credits::Ledger.new(client: client)
  @top_ups = Orb::Resources::Customers::Credits::TopUps.new(client: client)
end

Instance Attribute Details

#ledgerOrb::Resources::Customers::Credits::Ledger (readonly)



8
9
10
# File 'lib/orb/resources/customers/credits.rb', line 8

def ledger
  @ledger
end

#top_upsOrb::Resources::Customers::Credits::TopUps (readonly)



11
12
13
# File 'lib/orb/resources/customers/credits.rb', line 11

def top_ups
  @top_ups
end

Instance Method Details

#list(customer_id, currency: nil, cursor: nil, include_all_blocks: nil, limit: nil, request_options: {}) ⇒ Orb::Internal::Page<Orb::Models::Customers::CreditListResponse>

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

Returns a paginated list of unexpired, non-zero credit blocks for a customer.

If ‘include_all_blocks` is set to `true`, all credit blocks (including expired and depleted blocks) will be included in the response.

Note that ‘currency` defaults to credits if not specified. To use a real world currency, set `currency` to an ISO 4217 string.

Parameters:

  • customer_id (String)
  • currency (String, nil)

    The ledger currency or custom pricing unit to use.

  • cursor (String, nil)

    Cursor for pagination. This can be populated by the ‘next_cursor` value returned

  • include_all_blocks (Boolean)

    If set to True, all expired and depleted blocks, as well as active block will be

  • limit (Integer)

    The number of items to fetch. Defaults to 20.

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

Returns:

See Also:



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/orb/resources/customers/credits.rb', line 41

def list(customer_id, params = {})
  parsed, options = Orb::Customers::CreditListParams.dump_request(params)
  @client.request(
    method: :get,
    path: ["customers/%1$s/credits", customer_id],
    query: parsed,
    page: Orb::Internal::Page,
    model: Orb::Models::Customers::CreditListResponse,
    options: options
  )
end

#list_by_external_id(external_customer_id, currency: nil, cursor: nil, include_all_blocks: nil, limit: nil, request_options: {}) ⇒ Orb::Internal::Page<Orb::Models::Customers::CreditListByExternalIDResponse>

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

Returns a paginated list of unexpired, non-zero credit blocks for a customer.

If ‘include_all_blocks` is set to `true`, all credit blocks (including expired and depleted blocks) will be included in the response.

Note that ‘currency` defaults to credits if not specified. To use a real world currency, set `currency` to an ISO 4217 string.

Parameters:

  • external_customer_id (String)
  • currency (String, nil)

    The ledger currency or custom pricing unit to use.

  • cursor (String, nil)

    Cursor for pagination. This can be populated by the ‘next_cursor` value returned

  • include_all_blocks (Boolean)

    If set to True, all expired and depleted blocks, as well as active block will be

  • limit (Integer)

    The number of items to fetch. Defaults to 20.

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

Returns:

See Also:



81
82
83
84
85
86
87
88
89
90
91
# File 'lib/orb/resources/customers/credits.rb', line 81

def list_by_external_id(external_customer_id, params = {})
  parsed, options = Orb::Customers::CreditListByExternalIDParams.dump_request(params)
  @client.request(
    method: :get,
    path: ["customers/external_customer_id/%1$s/credits", external_customer_id],
    query: parsed,
    page: Orb::Internal::Page,
    model: Orb::Models::Customers::CreditListByExternalIDResponse,
    options: options
  )
end