zernio-sdk 0.0.782 → 0.0.783
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +6 -0
- data/docs/UsageApi.md +8 -2
- data/docs/UsageAttributionGroup.md +22 -0
- data/docs/UsageAttributionSlice.md +20 -0
- data/docs/UsageAttributionSliceByProduct.md +34 -0
- data/docs/UsageMetering.md +5 -1
- data/docs/UsageMeteringAttribution.md +26 -0
- data/docs/UsageMeteringScope.md +49 -0
- data/docs/UsageMeteringScopeOneOf.md +18 -0
- data/lib/zernio-sdk/api/usage_api.rb +15 -2
- data/lib/zernio-sdk/models/usage_attribution_group.rb +190 -0
- data/lib/zernio-sdk/models/usage_attribution_slice.rb +156 -0
- data/lib/zernio-sdk/models/usage_attribution_slice_by_product.rb +220 -0
- data/lib/zernio-sdk/models/usage_metering.rb +22 -4
- data/lib/zernio-sdk/models/usage_metering_attribution.rb +223 -0
- data/lib/zernio-sdk/models/usage_metering_call_usage.rb +1 -1
- data/lib/zernio-sdk/models/usage_metering_peaks.rb +1 -1
- data/lib/zernio-sdk/models/usage_metering_scope.rb +105 -0
- data/lib/zernio-sdk/models/usage_metering_scope_one_of.rb +164 -0
- data/lib/zernio-sdk/version.rb +1 -1
- data/lib/zernio-sdk.rb +6 -0
- data/openapi.yaml +90 -4
- data/spec/api/usage_api_spec.rb +4 -1
- data/spec/models/usage_attribution_group_spec.rb +48 -0
- data/spec/models/usage_attribution_slice_by_product_spec.rb +84 -0
- data/spec/models/usage_attribution_slice_spec.rb +42 -0
- data/spec/models/usage_metering_attribution_spec.rb +64 -0
- data/spec/models/usage_metering_scope_one_of_spec.rb +36 -0
- data/spec/models/usage_metering_scope_spec.rb +32 -0
- data/spec/models/usage_metering_spec.rb +12 -0
- metadata +25 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9a0bc51395c10adcf6db858d0db9fed18d74534f47650cd085fb2a3dde269bf4
|
|
4
|
+
data.tar.gz: 681dbd28bd5cfe96bcca836e86415b2c14e62d24fb9acc1c4484bd42b2eb17b0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 411d260d794a379815491cfbec765b65cb8988fdf6542988c3d742bc3594e0b727d2a84474a6103ed48a8165c8a639f384ea43eed4ddf0cc85acc7cd4af23fb5
|
|
7
|
+
data.tar.gz: d4802dd9779762d3d62ff5f74d4144be9be0dced53587fbbd679d5db2152189d326f55217255aca105abe9cf51145d8fe52326defae438fdcf736609e2a81cbb
|
data/README.md
CHANGED
|
@@ -2208,13 +2208,19 @@ Class | Method | HTTP request | Description
|
|
|
2208
2208
|
- [Zernio::UploadedOrDerivedAudience](docs/UploadedOrDerivedAudience.md)
|
|
2209
2209
|
- [Zernio::UploadedOrDerivedAudienceCompaniesInner](docs/UploadedOrDerivedAudienceCompaniesInner.md)
|
|
2210
2210
|
- [Zernio::UploadedOrDerivedAudienceMatchRulesInner](docs/UploadedOrDerivedAudienceMatchRulesInner.md)
|
|
2211
|
+
- [Zernio::UsageAttributionGroup](docs/UsageAttributionGroup.md)
|
|
2212
|
+
- [Zernio::UsageAttributionSlice](docs/UsageAttributionSlice.md)
|
|
2213
|
+
- [Zernio::UsageAttributionSliceByProduct](docs/UsageAttributionSliceByProduct.md)
|
|
2211
2214
|
- [Zernio::UsageMetering](docs/UsageMetering.md)
|
|
2215
|
+
- [Zernio::UsageMeteringAttribution](docs/UsageMeteringAttribution.md)
|
|
2212
2216
|
- [Zernio::UsageMeteringCallUsage](docs/UsageMeteringCallUsage.md)
|
|
2213
2217
|
- [Zernio::UsageMeteringCallUsageWhatsapp](docs/UsageMeteringCallUsageWhatsapp.md)
|
|
2214
2218
|
- [Zernio::UsageMeteringDaysInner](docs/UsageMeteringDaysInner.md)
|
|
2215
2219
|
- [Zernio::UsageMeteringLineItemsInner](docs/UsageMeteringLineItemsInner.md)
|
|
2216
2220
|
- [Zernio::UsageMeteringPeaks](docs/UsageMeteringPeaks.md)
|
|
2217
2221
|
- [Zernio::UsageMeteringPeriod](docs/UsageMeteringPeriod.md)
|
|
2222
|
+
- [Zernio::UsageMeteringScope](docs/UsageMeteringScope.md)
|
|
2223
|
+
- [Zernio::UsageMeteringScopeOneOf](docs/UsageMeteringScopeOneOf.md)
|
|
2218
2224
|
- [Zernio::UsageMeteringTax](docs/UsageMeteringTax.md)
|
|
2219
2225
|
- [Zernio::UsageMeteringTotals](docs/UsageMeteringTotals.md)
|
|
2220
2226
|
- [Zernio::UsageStats](docs/UsageStats.md)
|
data/docs/UsageApi.md
CHANGED
|
@@ -240,7 +240,7 @@ end
|
|
|
240
240
|
|
|
241
241
|
Usage snapshot (default) or billed-spend metering (with params)
|
|
242
242
|
|
|
243
|
-
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`.
|
|
243
|
+
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\": [] }`. **Attribution (metering mode):** `groupBy=profile|account` adds an `attribution` breakdown of the window's spend per profile or account, assembled from your own records and pro-rated against the invoice so `sum(groups) + unattributed` equals `totals` exactly. `profileId` / `accountId` instead project the whole payload (`days`, `totals`, `lineItems`) onto that one group; `peaks`, `callUsage` and `tax` are then `null` (workspace-level facts). Projected `days` spread the group's period share over each day (usage is attributed per period, not per day). Profile-scoped API keys and members only see their profiles' groups (`attribution.restricted: true`, with `totals` summing the visible groups). Credits, 10DLC fees and Verify are always unattributed. `profileId` / `accountId` on their own do not select metering mode: pair them with `range`. 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`.
|
|
244
244
|
|
|
245
245
|
### Examples
|
|
246
246
|
|
|
@@ -259,7 +259,10 @@ opts = {
|
|
|
259
259
|
range: 'cycle', # 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`.
|
|
260
260
|
from: Date.parse('2013-10-20'), # Date | Inclusive start (UTC date). Required when `range=custom`.
|
|
261
261
|
to: Date.parse('2013-10-20'), # Date | Inclusive end (UTC date). Required when `range=custom`. Max span 366 days.
|
|
262
|
-
granularity: 'day' # 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`.
|
|
262
|
+
granularity: 'day', # 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`.
|
|
263
|
+
group_by: 'profile', # String | Metering mode. Adds `attribution`: the window's spend split per profile or per account (keys are ids; resolve names via `GET /v1/profiles` / `GET /v1/accounts`).
|
|
264
|
+
profile_id: 'profile_id_example', # String | Metering mode (pair with `range`). Project the payload onto this profile's attributed share. Mutually exclusive with `accountId`, and `groupBy` (if given) must be `profile`; 404 when the profile is not in your workspace (or outside a scoped key's profiles).
|
|
265
|
+
account_id: 'account_id_example' # String | Metering mode (pair with `range`). Project the payload onto this account's attributed share. Mutually exclusive with `profileId`, and `groupBy` (if given) must be `account`; 404 when the account is not visible to the caller.
|
|
263
266
|
}
|
|
264
267
|
|
|
265
268
|
begin
|
|
@@ -298,6 +301,9 @@ end
|
|
|
298
301
|
| **from** | **Date** | Inclusive start (UTC date). Required when `range=custom`. | [optional] |
|
|
299
302
|
| **to** | **Date** | Inclusive end (UTC date). Required when `range=custom`. Max span 366 days. | [optional] |
|
|
300
303
|
| **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`. | [optional][default to 'day'] |
|
|
304
|
+
| **group_by** | **String** | Metering mode. Adds `attribution`: the window's spend split per profile or per account (keys are ids; resolve names via `GET /v1/profiles` / `GET /v1/accounts`). | [optional] |
|
|
305
|
+
| **profile_id** | **String** | Metering mode (pair with `range`). Project the payload onto this profile's attributed share. Mutually exclusive with `accountId`, and `groupBy` (if given) must be `profile`; 404 when the profile is not in your workspace (or outside a scoped key's profiles). | [optional] |
|
|
306
|
+
| **account_id** | **String** | Metering mode (pair with `range`). Project the payload onto this account's attributed share. Mutually exclusive with `profileId`, and `groupBy` (if given) must be `account`; 404 when the account is not visible to the caller. | [optional] |
|
|
301
307
|
|
|
302
308
|
### Return type
|
|
303
309
|
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Zernio::UsageAttributionGroup
|
|
2
|
+
|
|
3
|
+
## Properties
|
|
4
|
+
|
|
5
|
+
| Name | Type | Description | Notes |
|
|
6
|
+
| ---- | ---- | ----------- | ----- |
|
|
7
|
+
| **by_product** | [**UsageAttributionSliceByProduct**](UsageAttributionSliceByProduct.md) | | [optional] |
|
|
8
|
+
| **total_usd** | **Float** | | [optional] |
|
|
9
|
+
| **key** | **String** | Profile id or account id, per `groupBy`. | |
|
|
10
|
+
|
|
11
|
+
## Example
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
14
|
+
require 'zernio-sdk'
|
|
15
|
+
|
|
16
|
+
instance = Zernio::UsageAttributionGroup.new(
|
|
17
|
+
by_product: null,
|
|
18
|
+
total_usd: null,
|
|
19
|
+
key: null
|
|
20
|
+
)
|
|
21
|
+
```
|
|
22
|
+
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Zernio::UsageAttributionSlice
|
|
2
|
+
|
|
3
|
+
## Properties
|
|
4
|
+
|
|
5
|
+
| Name | Type | Description | Notes |
|
|
6
|
+
| ---- | ---- | ----------- | ----- |
|
|
7
|
+
| **by_product** | [**UsageAttributionSliceByProduct**](UsageAttributionSliceByProduct.md) | | [optional] |
|
|
8
|
+
| **total_usd** | **Float** | | [optional] |
|
|
9
|
+
|
|
10
|
+
## Example
|
|
11
|
+
|
|
12
|
+
```ruby
|
|
13
|
+
require 'zernio-sdk'
|
|
14
|
+
|
|
15
|
+
instance = Zernio::UsageAttributionSlice.new(
|
|
16
|
+
by_product: null,
|
|
17
|
+
total_usd: null
|
|
18
|
+
)
|
|
19
|
+
```
|
|
20
|
+
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Zernio::UsageAttributionSliceByProduct
|
|
2
|
+
|
|
3
|
+
## Properties
|
|
4
|
+
|
|
5
|
+
| Name | Type | Description | Notes |
|
|
6
|
+
| ---- | ---- | ----------- | ----- |
|
|
7
|
+
| **accounts** | **Float** | | [optional] |
|
|
8
|
+
| **numbers** | **Float** | | [optional] |
|
|
9
|
+
| **calls** | **Float** | | [optional] |
|
|
10
|
+
| **sms** | **Float** | | [optional] |
|
|
11
|
+
| **verify** | **Float** | | [optional] |
|
|
12
|
+
| **dlc** | **Float** | | [optional] |
|
|
13
|
+
| **x_api** | **Float** | | [optional] |
|
|
14
|
+
| **credits** | **Float** | | [optional] |
|
|
15
|
+
| **other** | **Float** | | [optional] |
|
|
16
|
+
|
|
17
|
+
## Example
|
|
18
|
+
|
|
19
|
+
```ruby
|
|
20
|
+
require 'zernio-sdk'
|
|
21
|
+
|
|
22
|
+
instance = Zernio::UsageAttributionSliceByProduct.new(
|
|
23
|
+
accounts: null,
|
|
24
|
+
numbers: null,
|
|
25
|
+
calls: null,
|
|
26
|
+
sms: null,
|
|
27
|
+
verify: null,
|
|
28
|
+
dlc: null,
|
|
29
|
+
x_api: null,
|
|
30
|
+
credits: null,
|
|
31
|
+
other: null
|
|
32
|
+
)
|
|
33
|
+
```
|
|
34
|
+
|
data/docs/UsageMetering.md
CHANGED
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
| **call_usage** | [**UsageMeteringCallUsage**](UsageMeteringCallUsage.md) | | [optional] |
|
|
14
14
|
| **period** | [**UsageMeteringPeriod**](UsageMeteringPeriod.md) | | [optional] |
|
|
15
15
|
| **tax** | [**UsageMeteringTax**](UsageMeteringTax.md) | | [optional] |
|
|
16
|
+
| **attribution** | [**UsageMeteringAttribution**](UsageMeteringAttribution.md) | | [optional] |
|
|
17
|
+
| **scope** | [**UsageMeteringScope**](UsageMeteringScope.md) | | [optional] |
|
|
16
18
|
|
|
17
19
|
## Example
|
|
18
20
|
|
|
@@ -28,7 +30,9 @@ instance = Zernio::UsageMetering.new(
|
|
|
28
30
|
peaks: null,
|
|
29
31
|
call_usage: null,
|
|
30
32
|
period: null,
|
|
31
|
-
tax: null
|
|
33
|
+
tax: null,
|
|
34
|
+
attribution: null,
|
|
35
|
+
scope: null
|
|
32
36
|
)
|
|
33
37
|
```
|
|
34
38
|
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Zernio::UsageMeteringAttribution
|
|
2
|
+
|
|
3
|
+
## Properties
|
|
4
|
+
|
|
5
|
+
| Name | Type | Description | Notes |
|
|
6
|
+
| ---- | ---- | ----------- | ----- |
|
|
7
|
+
| **group_by** | **String** | | [optional] |
|
|
8
|
+
| **groups** | [**Array<UsageAttributionGroup>**](UsageAttributionGroup.md) | | [optional] |
|
|
9
|
+
| **unattributed** | [**UsageAttributionSlice**](UsageAttributionSlice.md) | Spend no profile/account can claim: credits, 10DLC fees, Verify, and usage whose record no longer resolves to an account. Zero for a restricted principal. | [optional] |
|
|
10
|
+
| **totals** | [**UsageAttributionSlice**](UsageAttributionSlice.md) | The window totals; for a restricted principal, the sum of the visible groups. | [optional] |
|
|
11
|
+
| **restricted** | **Boolean** | True when the caller (profile-scoped API key or member) cannot see every profile: `groups` are filtered, `totals` sum them, `unattributed` is zero, and the top-level `days` / `totals` / `lineItems` are projected onto the visible groups with `peaks`, `callUsage` and `tax` null. | [optional] |
|
|
12
|
+
|
|
13
|
+
## Example
|
|
14
|
+
|
|
15
|
+
```ruby
|
|
16
|
+
require 'zernio-sdk'
|
|
17
|
+
|
|
18
|
+
instance = Zernio::UsageMeteringAttribution.new(
|
|
19
|
+
group_by: null,
|
|
20
|
+
groups: null,
|
|
21
|
+
unattributed: null,
|
|
22
|
+
totals: null,
|
|
23
|
+
restricted: null
|
|
24
|
+
)
|
|
25
|
+
```
|
|
26
|
+
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Zernio::UsageMeteringScope
|
|
2
|
+
|
|
3
|
+
## Class instance methods
|
|
4
|
+
|
|
5
|
+
### `openapi_one_of`
|
|
6
|
+
|
|
7
|
+
Returns the list of classes defined in oneOf.
|
|
8
|
+
|
|
9
|
+
#### Example
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
require 'zernio-sdk'
|
|
13
|
+
|
|
14
|
+
Zernio::UsageMeteringScope.openapi_one_of
|
|
15
|
+
# =>
|
|
16
|
+
# [
|
|
17
|
+
# :'DeleteInboxReviewReplyRequest',
|
|
18
|
+
# :'UsageMeteringScopeOneOf'
|
|
19
|
+
# ]
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### build
|
|
23
|
+
|
|
24
|
+
Find the appropriate object from the `openapi_one_of` list and casts the data into it.
|
|
25
|
+
|
|
26
|
+
#### Example
|
|
27
|
+
|
|
28
|
+
```ruby
|
|
29
|
+
require 'zernio-sdk'
|
|
30
|
+
|
|
31
|
+
Zernio::UsageMeteringScope.build(data)
|
|
32
|
+
# => #<DeleteInboxReviewReplyRequest:0x00007fdd4aab02a0>
|
|
33
|
+
|
|
34
|
+
Zernio::UsageMeteringScope.build(data_that_doesnt_match)
|
|
35
|
+
# => nil
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
#### Parameters
|
|
39
|
+
|
|
40
|
+
| Name | Type | Description |
|
|
41
|
+
| ---- | ---- | ----------- |
|
|
42
|
+
| **data** | **Mixed** | data to be matched against the list of oneOf items |
|
|
43
|
+
|
|
44
|
+
#### Return type
|
|
45
|
+
|
|
46
|
+
- `DeleteInboxReviewReplyRequest`
|
|
47
|
+
- `UsageMeteringScopeOneOf`
|
|
48
|
+
- `nil` (if no type matches)
|
|
49
|
+
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Zernio::UsageMeteringScopeOneOf
|
|
2
|
+
|
|
3
|
+
## Properties
|
|
4
|
+
|
|
5
|
+
| Name | Type | Description | Notes |
|
|
6
|
+
| ---- | ---- | ----------- | ----- |
|
|
7
|
+
| **profile_id** | **String** | | |
|
|
8
|
+
|
|
9
|
+
## Example
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
require 'zernio-sdk'
|
|
13
|
+
|
|
14
|
+
instance = Zernio::UsageMeteringScopeOneOf.new(
|
|
15
|
+
profile_id: null
|
|
16
|
+
)
|
|
17
|
+
```
|
|
18
|
+
|
|
@@ -230,13 +230,16 @@ module Zernio
|
|
|
230
230
|
end
|
|
231
231
|
|
|
232
232
|
# Usage snapshot (default) or billed-spend metering (with params)
|
|
233
|
-
# 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`.
|
|
233
|
+
# 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\": [] }`. **Attribution (metering mode):** `groupBy=profile|account` adds an `attribution` breakdown of the window's spend per profile or account, assembled from your own records and pro-rated against the invoice so `sum(groups) + unattributed` equals `totals` exactly. `profileId` / `accountId` instead project the whole payload (`days`, `totals`, `lineItems`) onto that one group; `peaks`, `callUsage` and `tax` are then `null` (workspace-level facts). Projected `days` spread the group's period share over each day (usage is attributed per period, not per day). Profile-scoped API keys and members only see their profiles' groups (`attribution.restricted: true`, with `totals` summing the visible groups). Credits, 10DLC fees and Verify are always unattributed. `profileId` / `accountId` on their own do not select metering mode: pair them with `range`. 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`.
|
|
234
234
|
# @param [Hash] opts the optional parameters
|
|
235
235
|
# @option opts [Boolean] :reconcile Snapshot mode only. For Stripe subscription users, `true` forces a subscription reconciliation pass even when cached plan data looks complete.
|
|
236
236
|
# @option opts [String] :range 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')
|
|
237
237
|
# @option opts [Date] :from Inclusive start (UTC date). Required when `range=custom`.
|
|
238
238
|
# @option opts [Date] :to Inclusive end (UTC date). Required when `range=custom`. Max span 366 days.
|
|
239
239
|
# @option opts [String] :granularity 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')
|
|
240
|
+
# @option opts [String] :group_by Metering mode. Adds `attribution`: the window's spend split per profile or per account (keys are ids; resolve names via `GET /v1/profiles` / `GET /v1/accounts`).
|
|
241
|
+
# @option opts [String] :profile_id Metering mode (pair with `range`). Project the payload onto this profile's attributed share. Mutually exclusive with `accountId`, and `groupBy` (if given) must be `profile`; 404 when the profile is not in your workspace (or outside a scoped key's profiles).
|
|
242
|
+
# @option opts [String] :account_id Metering mode (pair with `range`). Project the payload onto this account's attributed share. Mutually exclusive with `profileId`, and `groupBy` (if given) must be `account`; 404 when the account is not visible to the caller.
|
|
240
243
|
# @return [GetUsage200Response]
|
|
241
244
|
def get_usage(opts = {})
|
|
242
245
|
data, _status_code, _headers = get_usage_with_http_info(opts)
|
|
@@ -244,13 +247,16 @@ module Zernio
|
|
|
244
247
|
end
|
|
245
248
|
|
|
246
249
|
# Usage snapshot (default) or billed-spend metering (with params)
|
|
247
|
-
# 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`.
|
|
250
|
+
# 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\": [] }`. **Attribution (metering mode):** `groupBy=profile|account` adds an `attribution` breakdown of the window's spend per profile or account, assembled from your own records and pro-rated against the invoice so `sum(groups) + unattributed` equals `totals` exactly. `profileId` / `accountId` instead project the whole payload (`days`, `totals`, `lineItems`) onto that one group; `peaks`, `callUsage` and `tax` are then `null` (workspace-level facts). Projected `days` spread the group's period share over each day (usage is attributed per period, not per day). Profile-scoped API keys and members only see their profiles' groups (`attribution.restricted: true`, with `totals` summing the visible groups). Credits, 10DLC fees and Verify are always unattributed. `profileId` / `accountId` on their own do not select metering mode: pair them with `range`. 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`.
|
|
248
251
|
# @param [Hash] opts the optional parameters
|
|
249
252
|
# @option opts [Boolean] :reconcile Snapshot mode only. For Stripe subscription users, `true` forces a subscription reconciliation pass even when cached plan data looks complete.
|
|
250
253
|
# @option opts [String] :range 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')
|
|
251
254
|
# @option opts [Date] :from Inclusive start (UTC date). Required when `range=custom`.
|
|
252
255
|
# @option opts [Date] :to Inclusive end (UTC date). Required when `range=custom`. Max span 366 days.
|
|
253
256
|
# @option opts [String] :granularity 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')
|
|
257
|
+
# @option opts [String] :group_by Metering mode. Adds `attribution`: the window's spend split per profile or per account (keys are ids; resolve names via `GET /v1/profiles` / `GET /v1/accounts`).
|
|
258
|
+
# @option opts [String] :profile_id Metering mode (pair with `range`). Project the payload onto this profile's attributed share. Mutually exclusive with `accountId`, and `groupBy` (if given) must be `profile`; 404 when the profile is not in your workspace (or outside a scoped key's profiles).
|
|
259
|
+
# @option opts [String] :account_id Metering mode (pair with `range`). Project the payload onto this account's attributed share. Mutually exclusive with `profileId`, and `groupBy` (if given) must be `account`; 404 when the account is not visible to the caller.
|
|
254
260
|
# @return [Array<(GetUsage200Response, Integer, Hash)>] GetUsage200Response data, response status code and response headers
|
|
255
261
|
def get_usage_with_http_info(opts = {})
|
|
256
262
|
if @api_client.config.debugging
|
|
@@ -264,6 +270,10 @@ module Zernio
|
|
|
264
270
|
if @api_client.config.client_side_validation && opts[:'granularity'] && !allowable_values.include?(opts[:'granularity'])
|
|
265
271
|
fail ArgumentError, "invalid value for \"granularity\", must be one of #{allowable_values}"
|
|
266
272
|
end
|
|
273
|
+
allowable_values = ["profile", "account"]
|
|
274
|
+
if @api_client.config.client_side_validation && opts[:'group_by'] && !allowable_values.include?(opts[:'group_by'])
|
|
275
|
+
fail ArgumentError, "invalid value for \"group_by\", must be one of #{allowable_values}"
|
|
276
|
+
end
|
|
267
277
|
# resource path
|
|
268
278
|
local_var_path = '/v1/usage'
|
|
269
279
|
|
|
@@ -274,6 +284,9 @@ module Zernio
|
|
|
274
284
|
query_params[:'from'] = opts[:'from'] if !opts[:'from'].nil?
|
|
275
285
|
query_params[:'to'] = opts[:'to'] if !opts[:'to'].nil?
|
|
276
286
|
query_params[:'granularity'] = opts[:'granularity'] if !opts[:'granularity'].nil?
|
|
287
|
+
query_params[:'groupBy'] = opts[:'group_by'] if !opts[:'group_by'].nil?
|
|
288
|
+
query_params[:'profileId'] = opts[:'profile_id'] if !opts[:'profile_id'].nil?
|
|
289
|
+
query_params[:'accountId'] = opts[:'account_id'] if !opts[:'account_id'].nil?
|
|
277
290
|
|
|
278
291
|
# header parameters
|
|
279
292
|
header_params = opts[:header_params] || {}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#Zernio API
|
|
3
|
+
|
|
4
|
+
#API reference for Zernio. Authenticate with a Bearer API key. Base URL: https://zernio.com/api Versioning and deprecation: all endpoints are versioned in the URL path (current version: /v1). Breaking changes only ship in a new path version; existing versions keep working. Deprecated operations are marked 'deprecated: true' in this spec and announced in the changelog (https://zernio.com/changelog) before removal. Errors: every 4xx/5xx response is application/json with a machine-readable 'code' and a human-readable 'error' message (see the ErrorResponse schema).
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: 1.0.4
|
|
7
|
+
Contact: support@zernio.com
|
|
8
|
+
Generated by: https://openapi-generator.tech
|
|
9
|
+
Generator version: 7.19.0
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
require 'date'
|
|
14
|
+
require 'time'
|
|
15
|
+
|
|
16
|
+
module Zernio
|
|
17
|
+
class UsageAttributionGroup < ApiModelBase
|
|
18
|
+
attr_accessor :by_product
|
|
19
|
+
|
|
20
|
+
attr_accessor :total_usd
|
|
21
|
+
|
|
22
|
+
# Profile id or account id, per `groupBy`.
|
|
23
|
+
attr_accessor :key
|
|
24
|
+
|
|
25
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
26
|
+
def self.attribute_map
|
|
27
|
+
{
|
|
28
|
+
:'by_product' => :'byProduct',
|
|
29
|
+
:'total_usd' => :'totalUsd',
|
|
30
|
+
:'key' => :'key'
|
|
31
|
+
}
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Returns attribute mapping this model knows about
|
|
35
|
+
def self.acceptable_attribute_map
|
|
36
|
+
attribute_map
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Returns all the JSON keys this model knows about
|
|
40
|
+
def self.acceptable_attributes
|
|
41
|
+
acceptable_attribute_map.values
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Attribute type mapping.
|
|
45
|
+
def self.openapi_types
|
|
46
|
+
{
|
|
47
|
+
:'by_product' => :'UsageAttributionSliceByProduct',
|
|
48
|
+
:'total_usd' => :'Float',
|
|
49
|
+
:'key' => :'String'
|
|
50
|
+
}
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# List of attributes with nullable: true
|
|
54
|
+
def self.openapi_nullable
|
|
55
|
+
Set.new([
|
|
56
|
+
])
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# List of class defined in allOf (OpenAPI v3)
|
|
60
|
+
def self.openapi_all_of
|
|
61
|
+
[
|
|
62
|
+
:'UsageAttributionSlice'
|
|
63
|
+
]
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# Initializes the object
|
|
67
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
68
|
+
def initialize(attributes = {})
|
|
69
|
+
if (!attributes.is_a?(Hash))
|
|
70
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Zernio::UsageAttributionGroup` initialize method"
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
74
|
+
acceptable_attribute_map = self.class.acceptable_attribute_map
|
|
75
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
76
|
+
if (!acceptable_attribute_map.key?(k.to_sym))
|
|
77
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Zernio::UsageAttributionGroup`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
|
|
78
|
+
end
|
|
79
|
+
h[k.to_sym] = v
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if attributes.key?(:'by_product')
|
|
83
|
+
self.by_product = attributes[:'by_product']
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
if attributes.key?(:'total_usd')
|
|
87
|
+
self.total_usd = attributes[:'total_usd']
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
if attributes.key?(:'key')
|
|
91
|
+
self.key = attributes[:'key']
|
|
92
|
+
else
|
|
93
|
+
self.key = nil
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
98
|
+
# @return Array for valid properties with the reasons
|
|
99
|
+
def list_invalid_properties
|
|
100
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
|
101
|
+
invalid_properties = Array.new
|
|
102
|
+
if @key.nil?
|
|
103
|
+
invalid_properties.push('invalid value for "key", key cannot be nil.')
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
invalid_properties
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# Check to see if the all the properties in the model are valid
|
|
110
|
+
# @return true if the model is valid
|
|
111
|
+
def valid?
|
|
112
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
|
113
|
+
return false if @key.nil?
|
|
114
|
+
true
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
# Custom attribute writer method with validation
|
|
118
|
+
# @param [Object] key Value to be assigned
|
|
119
|
+
def key=(key)
|
|
120
|
+
if key.nil?
|
|
121
|
+
fail ArgumentError, 'key cannot be nil'
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
@key = key
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
# Checks equality by comparing each attribute.
|
|
128
|
+
# @param [Object] Object to be compared
|
|
129
|
+
def ==(o)
|
|
130
|
+
return true if self.equal?(o)
|
|
131
|
+
self.class == o.class &&
|
|
132
|
+
by_product == o.by_product &&
|
|
133
|
+
total_usd == o.total_usd &&
|
|
134
|
+
key == o.key
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
# @see the `==` method
|
|
138
|
+
# @param [Object] Object to be compared
|
|
139
|
+
def eql?(o)
|
|
140
|
+
self == o
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
# Calculates hash code according to all attributes.
|
|
144
|
+
# @return [Integer] Hash code
|
|
145
|
+
def hash
|
|
146
|
+
[by_product, total_usd, key].hash
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
# Builds the object from hash
|
|
150
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
151
|
+
# @return [Object] Returns the model itself
|
|
152
|
+
def self.build_from_hash(attributes)
|
|
153
|
+
return nil unless attributes.is_a?(Hash)
|
|
154
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
155
|
+
transformed_hash = {}
|
|
156
|
+
openapi_types.each_pair do |key, type|
|
|
157
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
|
158
|
+
transformed_hash["#{key}"] = nil
|
|
159
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
160
|
+
# check to ensure the input is an array given that the attribute
|
|
161
|
+
# is documented as an array but the input is not
|
|
162
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
|
163
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
|
164
|
+
end
|
|
165
|
+
elsif !attributes[attribute_map[key]].nil?
|
|
166
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
|
167
|
+
end
|
|
168
|
+
end
|
|
169
|
+
new(transformed_hash)
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
# Returns the object in the form of hash
|
|
173
|
+
# @return [Hash] Returns the object in the form of hash
|
|
174
|
+
def to_hash
|
|
175
|
+
hash = {}
|
|
176
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
177
|
+
value = self.send(attr)
|
|
178
|
+
if value.nil?
|
|
179
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
180
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
hash[param] = _to_hash(value)
|
|
184
|
+
end
|
|
185
|
+
hash
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
end
|