Class: Telnyx::Resources::UsageReports

Inherits:
Object
  • Object
show all
Defined in:
lib/telnyx/resources/usage_reports.rb

Overview

Usage data reporting across Telnyx products

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ UsageReports

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

Parameters:



112
113
114
# File 'lib/telnyx/resources/usage_reports.rb', line 112

def initialize(client:)
  @client = client
end

Instance Method Details

#get_options(product: nil, authorization_bearer: nil, request_options: {}) ⇒ Telnyx::Models::UsageReportGetOptionsResponse

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

Get the Usage Reports options for querying usage, including the products available and their respective metrics and dimensions

Parameters:

  • product (String)

    Query param: Options (dimensions and metrics) for a given product. If none speci

  • authorization_bearer (String)

    Header param: Authenticates the request with your Telnyx API V2 KEY

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

Returns:

See Also:



95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/telnyx/resources/usage_reports.rb', line 95

def get_options(params = {})
  query_params = [:product]
  parsed, options = Telnyx::UsageReportGetOptionsParams.dump_request(params)
  query = Telnyx::Internal::Util.encode_query_params(parsed.slice(*query_params))
  @client.request(
    method: :get,
    path: "usage_reports/options",
    query: query,
    headers: parsed.except(*query_params),
    model: Telnyx::Models::UsageReportGetOptionsResponse,
    options: options
  )
end

#list(dimensions:, metrics:, product:, date_range: nil, end_date: nil, filter: nil, format_: nil, managed_accounts: nil, page_number: nil, page_size: nil, sort: nil, start_date: nil, authorization_bearer: nil, request_options: {}) ⇒ Telnyx::Internal::DefaultFlatPagination<Hash{Symbol=>Object}>

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

Get Telnyx usage data by product, broken out by the specified dimensions

Parameters:

  • dimensions (Array<String>)

    Query param: Breakout by specified product dimensions

  • metrics (Array<String>)

    Query param: Specified product usage values

  • product (String)

    Query param: Telnyx product

  • date_range (String)

    Query param: A more user-friendly way to specify the timespan you want to filter

  • end_date (String)

    Query param: The end date for the time range you are interested in. The maximum

  • filter (String)

    Query param: Filter records on dimensions

  • format_ (Symbol, Telnyx::Models::UsageReportListParams::Format)

    Query param: Specify the response format (csv or json). JSON is returned by defa

  • managed_accounts (Boolean)

    Query param: Return the aggregations for all Managed Accounts under the user mak

  • page_number (Integer)

    Query param

  • page_size (Integer)

    Query param

  • sort (Array<String>)

    Query param: Specifies the sort order for results

  • start_date (String)

    Query param: The start date for the time range you are interested in. The maximu

  • authorization_bearer (String)

    Header param: Authenticates the request with your Telnyx API V2 KEY

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

Returns:

See Also:



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/telnyx/resources/usage_reports.rb', line 45

def list(params)
  query_params =
    [
      :dimensions,
      :metrics,
      :product,
      :date_range,
      :end_date,
      :filter,
      :format_,
      :managed_accounts,
      :page_number,
      :page_size,
      :sort,
      :start_date
    ]
  parsed, options = Telnyx::UsageReportListParams.dump_request(params)
  query = Telnyx::Internal::Util.encode_query_params(parsed.slice(*query_params))
  @client.request(
    method: :get,
    path: "usage_reports",
    query: query.transform_keys(
      format_: "format",
      page_number: "page[number]",
      page_size: "page[size]"
    ),
    headers: parsed.except(*query_params),
    page: Telnyx::Internal::DefaultFlatPagination,
    model: Telnyx::Internal::Type::HashOf[Telnyx::Internal::Type::Unknown],
    options: options
  )
end