Class: Telnyx::Resources::Pricing::Products

Inherits:
Object
  • Object
show all
Defined in:
lib/telnyx/resources/pricing/products.rb,
sig/telnyx/resources/pricing/products.rbs

Overview

Public pricing operations

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Products

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

Parameters:



70
71
72
# File 'lib/telnyx/resources/pricing/products.rb', line 70

def initialize(client:)
  @client = client
end

Instance Method Details

#list(page_number: nil, page_size: nil, request_options: {}) ⇒ Telnyx::Internal::DefaultFlatPaginationForInexplicitNumberOrders<Telnyx::Models::Pricing::ProductListResponse>

Returns the full product catalog with pagination. Each entry contains a slug, display name, and description. Use the slug to fetch per-product pricing via GET /pricing/products/slug.

Parameters:

  • page_number (Integer)

    Page number (1-based).

  • page_size (Integer)

    Number of items per page (max 100).

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

Returns:

See Also:



54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/telnyx/resources/pricing/products.rb', line 54

def list(params = {})
  parsed, options = Telnyx::Pricing::ProductListParams.dump_request(params)
  query = Telnyx::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "pricing/products",
    query: query,
    page: Telnyx::Internal::DefaultFlatPaginationForInexplicitNumberOrders,
    model: Telnyx::Models::Pricing::ProductListResponse,
    options: options
  )
end

#retrieve(slug, page_number: nil, page_size: nil, request_options: {}) ⇒ Telnyx::Models::Pricing::ProductRetrieveResponse

Returns pricing entries for a single product. Most products return standard rate entries with fields like rate, unit, country_iso, direction, and tiers. Inference products return model-specific fields (model, input_rate, output_rate, cached_input_rate) with tiered pricing. Some products use rate decks (pricing_type: rate_deck) where rates are determined dynamically.

Parameters:

  • slug (String)

    Product slug from the catalog listing.

  • page_number (Integer)

    Page number (1-based).

  • page_size (Integer)

    Number of items per page (max 100).

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

Returns:

See Also:



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/telnyx/resources/pricing/products.rb', line 27

def retrieve(slug, params = {})
  parsed, options = Telnyx::Pricing::ProductRetrieveParams.dump_request(params)
  query = Telnyx::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["pricing/products/%1$s", slug],
    query: query,
    model: Telnyx::Models::Pricing::ProductRetrieveResponse,
    options: options
  )
end