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,
sig/orb/resources/customers/credits.rbs,
sig/orb/resources/customers/credits/ledger.rbs,
sig/orb/resources/customers/credits/top_ups.rbs

Overview

The Credit Ledger Entry resource models prepaid credits within Orb.

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:



140
141
142
143
144
# File 'lib/orb/resources/customers/credits.rb', line 140

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)

The Credit Ledger Entry resource models prepaid credits within Orb.



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

def ledger
  @ledger
end

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

The Credit Ledger Entry resource models prepaid credits within Orb.



17
18
19
# File 'lib/orb/resources/customers/credits.rb', line 17

def top_ups
  @top_ups
end

Instance Method Details

#list(customer_id, currency: nil, cursor: nil, effective_date_gt: nil, effective_date_gte: nil, effective_date_lt: nil, effective_date_lte: 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.

Results can be filtered by the block's effective_date using the effective_date[gte], effective_date[gt], effective_date[lt], and effective_date[lte] query parameters. This filters on when the credit block becomes effective, which may differ from creation time for backdated credits.

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

  • effective_date_gt (Time, nil)
  • effective_date_gte (Time, nil)
  • effective_date_lt (Time, nil)
  • effective_date_lte (Time, nil)
  • 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:



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/orb/resources/customers/credits.rb', line 60

def list(customer_id, params = {})
  parsed, options = Orb::Customers::CreditListParams.dump_request(params)
  query = Orb::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["customers/%1$s/credits", customer_id],
    query: query.transform_keys(
      effective_date_gt: "effective_date[gt]",
      effective_date_gte: "effective_date[gte]",
      effective_date_lt: "effective_date[lt]",
      effective_date_lte: "effective_date[lte]"
    ),
    page: Orb::Internal::Page,
    model: Orb::Models::Customers::CreditListResponse,
    options: options
  )
end

#list_by_external_id(external_customer_id, currency: nil, cursor: nil, effective_date_gt: nil, effective_date_gte: nil, effective_date_lt: nil, effective_date_lte: 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.

Results can be filtered by the block's effective_date using the effective_date[gte], effective_date[gt], effective_date[lt], and effective_date[lte] query parameters. This filters on when the credit block becomes effective, which may differ from creation time for backdated credits.

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

  • effective_date_gt (Time, nil)
  • effective_date_gte (Time, nil)
  • effective_date_lt (Time, nil)
  • effective_date_lte (Time, nil)
  • 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:



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/orb/resources/customers/credits.rb', line 119

def list_by_external_id(external_customer_id, params = {})
  parsed, options = Orb::Customers::CreditListByExternalIDParams.dump_request(params)
  query = Orb::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["customers/external_customer_id/%1$s/credits", external_customer_id],
    query: query.transform_keys(
      effective_date_gt: "effective_date[gt]",
      effective_date_gte: "effective_date[gte]",
      effective_date_lt: "effective_date[lt]",
      effective_date_lte: "effective_date[lte]"
    ),
    page: Orb::Internal::Page,
    model: Orb::Models::Customers::CreditListByExternalIDResponse,
    options: options
  )
end