Class: Zernio::UsageApi

Inherits:
Object
  • Object
show all
Defined in:
lib/zernio-sdk/api/usage_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ UsageApi

Returns a new instance of UsageApi.



19
20
21
# File 'lib/zernio-sdk/api/usage_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/zernio-sdk/api/usage_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#get_billing(opts = {}) ⇒ BillingSnapshot

Account billing snapshot (plan, cycle, balance, caps, status) The billing "wallet/statement" view: current plan, billing cycle, accrued balance + remaining credits this period, spend caps, and payment / access status. This is the billing half of the legacy /v1/usage-stats snapshot — the per-product consumption half is metering and lives on GET /v1/usage. Usage-based (Metronome) accounts get a populated balance; legacy Stripe accounts get balance: null plus a deprecated legacy.limits block and, when payment-blocked, status.openInvoiceUrl / status.declineReason.

Parameters:

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

    the optional parameters

Returns:



26
27
28
29
# File 'lib/zernio-sdk/api/usage_api.rb', line 26

def get_billing(opts = {})
  data, _status_code, _headers = get_billing_with_http_info(opts)
  data
end

#get_billing_with_http_info(opts = {}) ⇒ Array<(BillingSnapshot, Integer, Hash)>

Account billing snapshot (plan, cycle, balance, caps, status) The billing &quot;wallet/statement&quot; view: current plan, billing cycle, accrued balance + remaining credits this period, spend caps, and payment / access status. This is the billing half of the legacy `/v1/usage-stats` snapshot — the per-product consumption half is metering and lives on `GET /v1/usage`. Usage-based (Metronome) accounts get a populated `balance`; legacy Stripe accounts get `balance: null` plus a deprecated `legacy.limits` block and, when payment-blocked, `status.openInvoiceUrl` / `status.declineReason`.

Parameters:

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

    the optional parameters

Returns:

  • (Array<(BillingSnapshot, Integer, Hash)>)

    BillingSnapshot data, response status code and response headers



35
36
37
38
39
40
41
42
43
44
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
77
# File 'lib/zernio-sdk/api/usage_api.rb', line 35

def get_billing_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UsageApi.get_billing ...'
  end
  # resource path
  local_var_path = '/v1/billing'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'BillingSnapshot'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"UsageApi.get_billing",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: UsageApi#get_billing\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_calls_usage(opts = {}) ⇒ GetCallsUsage200Response

Calling usage and cost Aggregated calling usage across your numbers, both channels (WhatsApp Business Calling + regular phone/PSTN): call counts, answered counts, minutes, and cost. Use it for cost visibility or to rebill your own customers per number. Costs come from each call's billing snapshot, so this endpoint always agrees with the invoice: billableUSD is what Zernio bills; metaUSD is the WhatsApp per-minute charge Meta bills directly to your WABA (display only, never billed by Zernio). Optional groupBy returns a breakdown by UTC day, by your number, or by channel. Defaults to the last 30 days.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :since (Time)

    Start of the window (inclusive). Default 30 days before `until`.

  • :_until (Time)

    End of the window (exclusive). Default now.

  • :channel (String)
  • :number (String)

    Scope to calls involving this number (typically one of YOUR numbers). E.164, leading + optional.

  • :group_by (String)

Returns:



88
89
90
91
# File 'lib/zernio-sdk/api/usage_api.rb', line 88

def get_calls_usage(opts = {})
  data, _status_code, _headers = get_calls_usage_with_http_info(opts)
  data
end

#get_calls_usage_with_http_info(opts = {}) ⇒ Array<(GetCallsUsage200Response, Integer, Hash)>

Calling usage and cost Aggregated calling usage across your numbers, both channels (WhatsApp Business Calling + regular phone/PSTN): call counts, answered counts, minutes, and cost. Use it for cost visibility or to rebill your own customers per number. Costs come from each call's billing snapshot, so this endpoint always agrees with the invoice: `billableUSD` is what Zernio bills; `metaUSD` is the WhatsApp per-minute charge Meta bills directly to your WABA (display only, never billed by Zernio). Optional `groupBy` returns a breakdown by UTC day, by your number, or by channel. Defaults to the last 30 days.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :since (Time)

    Start of the window (inclusive). Default 30 days before `until`.

  • :_until (Time)

    End of the window (exclusive). Default now.

  • :channel (String)
  • :number (String)

    Scope to calls involving this number (typically one of YOUR numbers). E.164, leading + optional.

  • :group_by (String)

Returns:

  • (Array<(GetCallsUsage200Response, Integer, Hash)>)

    GetCallsUsage200Response data, response status code and response headers



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/zernio-sdk/api/usage_api.rb', line 102

def get_calls_usage_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UsageApi.get_calls_usage ...'
  end
  allowable_values = ["whatsapp", "pstn"]
  if @api_client.config.client_side_validation && opts[:'channel'] && !allowable_values.include?(opts[:'channel'])
    fail ArgumentError, "invalid value for \"channel\", must be one of #{allowable_values}"
  end
  allowable_values = ["day", "number", "channel"]
  if @api_client.config.client_side_validation && opts[:'group_by'] && !allowable_values.include?(opts[:'group_by'])
    fail ArgumentError, "invalid value for \"group_by\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/v1/usage/calls'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'since'] = opts[:'since'] if !opts[:'since'].nil?
  query_params[:'until'] = opts[:'_until'] if !opts[:'_until'].nil?
  query_params[:'channel'] = opts[:'channel'] if !opts[:'channel'].nil?
  query_params[:'number'] = opts[:'number'] if !opts[:'number'].nil?
  query_params[:'groupBy'] = opts[:'group_by'] if !opts[:'group_by'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'GetCallsUsage200Response'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"UsageApi.get_calls_usage",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: UsageApi#get_calls_usage\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_sms_usage(opts = {}) ⇒ GetSmsUsage200Response

SMS usage (volumes) Aggregated SMS/MMS volumes across your numbers: sent, received, and total message counts, with an optional breakdown by UTC day or by number. Defaults to the last 30 days. Volumes only, deliberately: SMS cost is carrier-rated asynchronously and billed to your invoice, so per-message cost is not available here. Calling usage (GET /v1/usage/calls) does include billable cost.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :since (Time)

    Start of the window (inclusive). Default 30 days before `until`.

  • :_until (Time)

    End of the window (exclusive). Default now.

  • :number (String)

    Scope to one of YOUR SMS-enabled numbers (E.164, leading + optional).

  • :group_by (String)

Returns:



167
168
169
170
# File 'lib/zernio-sdk/api/usage_api.rb', line 167

def get_sms_usage(opts = {})
  data, _status_code, _headers = get_sms_usage_with_http_info(opts)
  data
end

#get_sms_usage_with_http_info(opts = {}) ⇒ Array<(GetSmsUsage200Response, Integer, Hash)>

SMS usage (volumes) Aggregated SMS/MMS volumes across your numbers: sent, received, and total message counts, with an optional breakdown by UTC day or by number. Defaults to the last 30 days. Volumes only, deliberately: SMS cost is carrier-rated asynchronously and billed to your invoice, so per-message cost is not available here. Calling usage (GET /v1/usage/calls) does include billable cost.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :since (Time)

    Start of the window (inclusive). Default 30 days before `until`.

  • :_until (Time)

    End of the window (exclusive). Default now.

  • :number (String)

    Scope to one of YOUR SMS-enabled numbers (E.164, leading + optional).

  • :group_by (String)

Returns:

  • (Array<(GetSmsUsage200Response, Integer, Hash)>)

    GetSmsUsage200Response data, response status code and response headers



180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# File 'lib/zernio-sdk/api/usage_api.rb', line 180

def get_sms_usage_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UsageApi.get_sms_usage ...'
  end
  allowable_values = ["day", "number"]
  if @api_client.config.client_side_validation && opts[:'group_by'] && !allowable_values.include?(opts[:'group_by'])
    fail ArgumentError, "invalid value for \"group_by\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/v1/usage/sms'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'since'] = opts[:'since'] if !opts[:'since'].nil?
  query_params[:'until'] = opts[:'_until'] if !opts[:'_until'].nil?
  query_params[:'number'] = opts[:'number'] if !opts[:'number'].nil?
  query_params[:'groupBy'] = opts[:'group_by'] if !opts[:'group_by'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'GetSmsUsage200Response'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"UsageApi.get_sms_usage",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: UsageApi#get_sms_usage\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_usage(opts = {}) ⇒ GetUsage200Response

Usage snapshot (default) or billed-spend metering (with params) Dual-mode endpoint, selected by query params — fully backward compatible: Without metering params (the default): the plan / quota / usage snapshot — plan name, billing period, limits, usage counts, access state. Identical to GET /v1/usage-stats. Existing integrations keep working unchanged. With range, granularity, from, or to: usage METERING — billed spend (USD) by product family (accounts, numbers, calls, sms, dlc, xApi, credits, other) over the window, at day / month / total granularity, from Metronome's invoice breakdown (the CHARGE view — always reconciles with what gets billed). Also served at GET /v1/usage/daily. Usage-based accounts only — legacy Stripe accounts get { \"supported\": false, \"days\": [] }. For per-domain consumption volumes use GET /v1/usage/calls and GET /v1/usage/sms. For the billing statement (balance, credits, caps, payment status) use GET /v1/billing.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :reconcile (Boolean)

    Snapshot mode only. For Stripe subscription users, `true` forces a subscription reconciliation pass even when cached plan data looks complete.

  • :range (String)

    Window to report. `cycle` / `prev-cycle` resolve to the customer's real billing-period bounds (falling back to a trailing 30 days when no invoice exists yet); `7d`…`12mo` are trailing windows; `custom` uses `from` / `to`. (default to 'cycle')

  • :from (Date)

    Inclusive start (UTC date). Required when `range=custom`.

  • :to (Date)

    Inclusive end (UTC date). Required when `range=custom`. Max span 366 days.

  • :granularity (String)

    Bucketing of the `days` series: `day` (one row per UTC day), `month` (one row per calendar month, dated to the 1st), or `total` (no series — read `totals`). Does not affect `totals`. (default to 'day')

Returns:



241
242
243
244
# File 'lib/zernio-sdk/api/usage_api.rb', line 241

def get_usage(opts = {})
  data, _status_code, _headers = get_usage_with_http_info(opts)
  data
end

#get_usage_stats(opts = {}) ⇒ UsageStats

Get plan and usage snapshot (plan, limits, payment status) The plan / quota / payment-status snapshot: current plan name, billing period, plan limits, usage counts, and access state. Identical to a bare GET /v1/usage call (this path is its deprecated alias). For billed spend by product, call GET /v1/usage with range / granularity params. The statement view (balance, credits, caps, payment status) lives at GET /v1/billing. The response shape depends on the account's billingSystem: * Stripe users: per-period usage.uploads / usage.profiles counters. * Metronome (usage-based) users: usage.connectedAccounts, usage.xApiCallsByOperation (per-operation X API call counts — resolve keys via GET /v1/billing/x-pricing), plus a spend block with currentPeriodCents, xSpendCents, and xSpendLimitCents. The legacy usage.xApiCalls 3-tier aggregate is still emitted for back-compat but excludes the $0.200 URL tier and any future tiers — new clients should consume xApiCallsByOperation only.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :reconcile (Boolean)

    For Stripe subscription users, `true` forces a subscription reconciliation pass even when cached plan data looks complete. Omit the parameter, or pass `false`, to use the default first-time-only reconciliation behavior. Invalid boolean values are rejected.

Returns:



317
318
319
320
# File 'lib/zernio-sdk/api/usage_api.rb', line 317

def get_usage_stats(opts = {})
  data, _status_code, _headers = get_usage_stats_with_http_info(opts)
  data
end

#get_usage_stats_with_http_info(opts = {}) ⇒ Array<(UsageStats, Integer, Hash)>

Get plan and usage snapshot (plan, limits, payment status) The plan / quota / payment-status snapshot: current plan name, billing period, plan limits, usage counts, and access state. Identical to a bare `GET /v1/usage` call (this path is its deprecated alias). For billed spend by product, call `GET /v1/usage` with `range` / `granularity` params. The statement view (balance, credits, caps, payment status) lives at `GET /v1/billing`. The response shape depends on the account's `billingSystem`: * Stripe users: per-period `usage.uploads` / `usage.profiles` counters. * Metronome (usage-based) users: `usage.connectedAccounts`, `usage.xApiCallsByOperation` (per-operation X API call counts — resolve keys via `GET /v1/billing/x-pricing`), plus a `spend` block with `currentPeriodCents`, `xSpendCents`, and `xSpendLimitCents`. The legacy `usage.xApiCalls` 3-tier aggregate is still emitted for back-compat but excludes the $0.200 URL tier and any future tiers — new clients should consume `xApiCallsByOperation` only.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :reconcile (Boolean)

    For Stripe subscription users, `true` forces a subscription reconciliation pass even when cached plan data looks complete. Omit the parameter, or pass `false`, to use the default first-time-only reconciliation behavior. Invalid boolean values are rejected.

Returns:

  • (Array<(UsageStats, Integer, Hash)>)

    UsageStats data, response status code and response headers



327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
# File 'lib/zernio-sdk/api/usage_api.rb', line 327

def get_usage_stats_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UsageApi.get_usage_stats ...'
  end
  # resource path
  local_var_path = '/v1/usage-stats'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'reconcile'] = opts[:'reconcile'] if !opts[:'reconcile'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'UsageStats'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"UsageApi.get_usage_stats",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: UsageApi#get_usage_stats\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_usage_with_http_info(opts = {}) ⇒ Array<(GetUsage200Response, Integer, Hash)>

Usage snapshot (default) or billed-spend metering (with params) Dual-mode endpoint, selected by query params — fully backward compatible: Without metering params (the default): the plan / quota / usage snapshot — plan name, billing period, limits, usage counts, access state. Identical to `GET /v1/usage-stats`. Existing integrations keep working unchanged. With `range`, `granularity`, `from`, or `to`: usage METERING — billed spend (USD) by product family (`accounts`, `numbers`, `calls`, `sms`, `dlc`, `xApi`, `credits`, `other`) over the window, at `day` / `month` / `total` granularity, from Metronome's invoice breakdown (the CHARGE view — always reconciles with what gets billed). Also served at `GET /v1/usage/daily`. Usage-based accounts only — legacy Stripe accounts get `{ &quot;supported&quot;: false, &quot;days&quot;: [] }`. For per-domain consumption volumes use `GET /v1/usage/calls` and `GET /v1/usage/sms`. For the billing statement (balance, credits, caps, payment status) use `GET /v1/billing`.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :reconcile (Boolean)

    Snapshot mode only. For Stripe subscription users, `true` forces a subscription reconciliation pass even when cached plan data looks complete.

  • :range (String)

    Window to report. `cycle` / `prev-cycle` resolve to the customer's real billing-period bounds (falling back to a trailing 30 days when no invoice exists yet); `7d`…`12mo` are trailing windows; `custom` uses `from` / `to`. (default to 'cycle')

  • :from (Date)

    Inclusive start (UTC date). Required when `range=custom`.

  • :to (Date)

    Inclusive end (UTC date). Required when `range=custom`. Max span 366 days.

  • :granularity (String)

    Bucketing of the `days` series: `day` (one row per UTC day), `month` (one row per calendar month, dated to the 1st), or `total` (no series — read `totals`). Does not affect `totals`. (default to 'day')

Returns:

  • (Array<(GetUsage200Response, Integer, Hash)>)

    GetUsage200Response data, response status code and response headers



255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
# File 'lib/zernio-sdk/api/usage_api.rb', line 255

def get_usage_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UsageApi.get_usage ...'
  end
  allowable_values = ["cycle", "prev-cycle", "7d", "14d", "30d", "3mo", "12mo", "custom"]
  if @api_client.config.client_side_validation && opts[:'range'] && !allowable_values.include?(opts[:'range'])
    fail ArgumentError, "invalid value for \"range\", must be one of #{allowable_values}"
  end
  allowable_values = ["day", "month", "total"]
  if @api_client.config.client_side_validation && opts[:'granularity'] && !allowable_values.include?(opts[:'granularity'])
    fail ArgumentError, "invalid value for \"granularity\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/v1/usage'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'reconcile'] = opts[:'reconcile'] if !opts[:'reconcile'].nil?
  query_params[:'range'] = opts[:'range'] if !opts[:'range'].nil?
  query_params[:'from'] = opts[:'from'] if !opts[:'from'].nil?
  query_params[:'to'] = opts[:'to'] if !opts[:'to'].nil?
  query_params[:'granularity'] = opts[:'granularity'] if !opts[:'granularity'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'GetUsage200Response'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"UsageApi.get_usage",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: UsageApi#get_usage\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_x_api_pricing(opts = {}) ⇒ XApiPricing

Get X/Twitter API pricing table Returns Zernio's canonical X/Twitter API pricing table. Each X action has its own Metronome product and its own rate, and Zernio passes X API costs through at exact rates with zero markup. The response is identical for every authenticated user (pricing is universal), so it is safe to cache on the client for the duration of a billing period. To compute your own per-operation spend, pair this endpoint with GET /v1/usage-stats — that endpoint returns usage.xApiCallsByOperation keyed by the same operation field you get here.

Parameters:

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

    the optional parameters

Returns:



376
377
378
379
# File 'lib/zernio-sdk/api/usage_api.rb', line 376

def get_x_api_pricing(opts = {})
  data, _status_code, _headers = get_x_api_pricing_with_http_info(opts)
  data
end

#get_x_api_pricing_with_http_info(opts = {}) ⇒ Array<(XApiPricing, Integer, Hash)>

Get X/Twitter API pricing table Returns Zernio's canonical X/Twitter API pricing table. Each X action has its own Metronome product and its own rate, and Zernio passes X API costs through at exact rates with zero markup. The response is identical for every authenticated user (pricing is universal), so it is safe to cache on the client for the duration of a billing period. To compute your own per-operation spend, pair this endpoint with `GET /v1/usage-stats` — that endpoint returns `usage.xApiCallsByOperation` keyed by the same `operation` field you get here.

Parameters:

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

    the optional parameters

Returns:

  • (Array<(XApiPricing, Integer, Hash)>)

    XApiPricing data, response status code and response headers



385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
# File 'lib/zernio-sdk/api/usage_api.rb', line 385

def get_x_api_pricing_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UsageApi.get_x_api_pricing ...'
  end
  # resource path
  local_var_path = '/v1/billing/x-pricing'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'XApiPricing'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"UsageApi.get_x_api_pricing",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: UsageApi#get_x_api_pricing\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end