late-sdk 0.0.782 → 0.0.784

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.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +15 -0
  3. data/docs/CreatePhoneNumberStockWatchRequest.md +18 -0
  4. data/docs/ListPhoneNumberStockWatches200Response.md +18 -0
  5. data/docs/PhoneNumberStockWatch.md +24 -0
  6. data/docs/PhoneNumbersApi.md +203 -0
  7. data/docs/UsageApi.md +8 -2
  8. data/docs/UsageAttributionGroup.md +22 -0
  9. data/docs/UsageAttributionSlice.md +20 -0
  10. data/docs/UsageAttributionSliceByProduct.md +34 -0
  11. data/docs/UsageMetering.md +5 -1
  12. data/docs/UsageMeteringAttribution.md +26 -0
  13. data/docs/UsageMeteringScope.md +49 -0
  14. data/docs/UsageMeteringScopeOneOf.md +18 -0
  15. data/docs/WebhookEventsApi.md +69 -0
  16. data/docs/WebhookPayloadPhoneNumberStockAvailable.md +24 -0
  17. data/docs/WebhookPayloadPhoneNumberStockAvailableStock.md +20 -0
  18. data/docs/WebhookPayloadPhoneNumberStockAvailableStockTypesInner.md +20 -0
  19. data/lib/zernio-sdk/api/phone_numbers_api.rb +184 -0
  20. data/lib/zernio-sdk/api/usage_api.rb +15 -2
  21. data/lib/zernio-sdk/api/webhook_events_api.rb +66 -0
  22. data/lib/zernio-sdk/models/create_phone_number_stock_watch_request.rb +183 -0
  23. data/lib/zernio-sdk/models/list_phone_number_stock_watches200_response.rb +149 -0
  24. data/lib/zernio-sdk/models/phone_number_stock_watch.rb +243 -0
  25. data/lib/zernio-sdk/models/usage_attribution_group.rb +190 -0
  26. data/lib/zernio-sdk/models/usage_attribution_slice.rb +156 -0
  27. data/lib/zernio-sdk/models/usage_attribution_slice_by_product.rb +220 -0
  28. data/lib/zernio-sdk/models/usage_metering.rb +22 -4
  29. data/lib/zernio-sdk/models/usage_metering_attribution.rb +223 -0
  30. data/lib/zernio-sdk/models/usage_metering_call_usage.rb +1 -1
  31. data/lib/zernio-sdk/models/usage_metering_peaks.rb +1 -1
  32. data/lib/zernio-sdk/models/usage_metering_scope.rb +105 -0
  33. data/lib/zernio-sdk/models/usage_metering_scope_one_of.rb +164 -0
  34. data/lib/zernio-sdk/models/webhook_payload_phone_number_stock_available.rb +269 -0
  35. data/lib/zernio-sdk/models/webhook_payload_phone_number_stock_available_stock.rb +194 -0
  36. data/lib/zernio-sdk/models/webhook_payload_phone_number_stock_available_stock_types_inner.rb +192 -0
  37. data/lib/zernio-sdk/version.rb +1 -1
  38. data/lib/zernio-sdk.rb +12 -0
  39. data/openapi.yaml +236 -8
  40. data/spec/api/phone_numbers_api_spec.rb +33 -0
  41. data/spec/api/usage_api_spec.rb +4 -1
  42. data/spec/models/create_phone_number_stock_watch_request_spec.rb +36 -0
  43. data/spec/models/create_webhook_settings_request_spec.rb +1 -1
  44. data/spec/models/list_phone_number_stock_watches200_response_spec.rb +36 -0
  45. data/spec/models/phone_number_stock_watch_spec.rb +54 -0
  46. data/spec/models/update_webhook_settings_request_spec.rb +1 -1
  47. data/spec/models/usage_attribution_group_spec.rb +48 -0
  48. data/spec/models/usage_attribution_slice_by_product_spec.rb +84 -0
  49. data/spec/models/usage_attribution_slice_spec.rb +42 -0
  50. data/spec/models/usage_metering_attribution_spec.rb +64 -0
  51. data/spec/models/usage_metering_scope_one_of_spec.rb +36 -0
  52. data/spec/models/usage_metering_scope_spec.rb +32 -0
  53. data/spec/models/usage_metering_spec.rb +12 -0
  54. data/spec/models/webhook_payload_phone_number_stock_available_spec.rb +58 -0
  55. data/spec/models/webhook_payload_phone_number_stock_available_stock_spec.rb +42 -0
  56. data/spec/models/webhook_payload_phone_number_stock_available_stock_types_inner_spec.rb +42 -0
  57. data/spec/models/webhook_spec.rb +1 -1
  58. data/zernio-sdk-0.0.784.gem +0 -0
  59. metadata +50 -2
  60. data/zernio-sdk-0.0.782.gem +0 -0
@@ -22,6 +22,7 @@ All URIs are relative to *https://zernio.com/api*
22
22
  | [**on_message_read**](WebhookEventsApi.md#on_message_read) | **POST** /message.read | Message read event |
23
23
  | [**on_message_received**](WebhookEventsApi.md#on_message_received) | **POST** /message.received | Message received event |
24
24
  | [**on_message_sent**](WebhookEventsApi.md#on_message_sent) | **POST** /message.sent | Message sent event |
25
+ | [**on_phone_number_stock_available**](WebhookEventsApi.md#on_phone_number_stock_available) | **POST** /phone_number.stock_available | Phone-number stock available event |
25
26
  | [**on_post_cancelled**](WebhookEventsApi.md#on_post_cancelled) | **POST** /post.cancelled | Post cancelled event |
26
27
  | [**on_post_external_created**](WebhookEventsApi.md#on_post_external_created) | **POST** /post.external.created | External post created event |
27
28
  | [**on_post_external_deleted**](WebhookEventsApi.md#on_post_external_deleted) | **POST** /post.external.deleted | External post deleted event |
@@ -1280,6 +1281,74 @@ nil (empty response body)
1280
1281
  - **Accept**: Not defined
1281
1282
 
1282
1283
 
1284
+ ## on_phone_number_stock_available
1285
+
1286
+ > on_phone_number_stock_available(webhook_payload_phone_number_stock_available)
1287
+
1288
+ Phone-number stock available event
1289
+
1290
+ Fired by the stock sweep (every 6h) the first time a country you watch via POST /v1/phone-numbers/stock-watches has deliverable numbers again. The watch is consumed, so the event fires once per watch; the stock counts are a snapshot and numbers are sold first come, first served. Buy with POST /v1/phone-numbers/purchase.
1291
+
1292
+ ### Examples
1293
+
1294
+ ```ruby
1295
+ require 'time'
1296
+ require 'zernio-sdk'
1297
+ # setup authorization
1298
+ Zernio.configure do |config|
1299
+ # Configure Bearer authorization (JWT): bearerAuth
1300
+ config.access_token = 'YOUR_BEARER_TOKEN'
1301
+ end
1302
+
1303
+ api_instance = Zernio::WebhookEventsApi.new
1304
+ webhook_payload_phone_number_stock_available = # WebhookPayloadPhoneNumberStockAvailable |
1305
+
1306
+ begin
1307
+ # Phone-number stock available event
1308
+ api_instance.on_phone_number_stock_available(webhook_payload_phone_number_stock_available)
1309
+ rescue Zernio::ApiError => e
1310
+ puts "Error when calling WebhookEventsApi->on_phone_number_stock_available: #{e}"
1311
+ end
1312
+ ```
1313
+
1314
+ #### Using the on_phone_number_stock_available_with_http_info variant
1315
+
1316
+ This returns an Array which contains the response data (`nil` in this case), status code and headers.
1317
+
1318
+ > <Array(nil, Integer, Hash)> on_phone_number_stock_available_with_http_info(webhook_payload_phone_number_stock_available)
1319
+
1320
+ ```ruby
1321
+ begin
1322
+ # Phone-number stock available event
1323
+ data, status_code, headers = api_instance.on_phone_number_stock_available_with_http_info(webhook_payload_phone_number_stock_available)
1324
+ p status_code # => 2xx
1325
+ p headers # => { ... }
1326
+ p data # => nil
1327
+ rescue Zernio::ApiError => e
1328
+ puts "Error when calling WebhookEventsApi->on_phone_number_stock_available_with_http_info: #{e}"
1329
+ end
1330
+ ```
1331
+
1332
+ ### Parameters
1333
+
1334
+ | Name | Type | Description | Notes |
1335
+ | ---- | ---- | ----------- | ----- |
1336
+ | **webhook_payload_phone_number_stock_available** | [**WebhookPayloadPhoneNumberStockAvailable**](WebhookPayloadPhoneNumberStockAvailable.md) | | |
1337
+
1338
+ ### Return type
1339
+
1340
+ nil (empty response body)
1341
+
1342
+ ### Authorization
1343
+
1344
+ [bearerAuth](../README.md#bearerAuth)
1345
+
1346
+ ### HTTP request headers
1347
+
1348
+ - **Content-Type**: application/json
1349
+ - **Accept**: Not defined
1350
+
1351
+
1283
1352
  ## on_post_cancelled
1284
1353
 
1285
1354
  > on_post_cancelled(webhook_payload_post)
@@ -0,0 +1,24 @@
1
+ # Zernio::WebhookPayloadPhoneNumberStockAvailable
2
+
3
+ ## Properties
4
+
5
+ | Name | Type | Description | Notes |
6
+ | ---- | ---- | ----------- | ----- |
7
+ | **id** | **String** | Stable webhook event ID | |
8
+ | **event** | **String** | | |
9
+ | **stock** | [**WebhookPayloadPhoneNumberStockAvailableStock**](WebhookPayloadPhoneNumberStockAvailableStock.md) | | |
10
+ | **timestamp** | **Time** | UTC time at which Zernio generated this event (set once when the event payload is built, before delivery is queued). Retries and redeliveries keep the original value, so it reflects the event, not the delivery attempt. | |
11
+
12
+ ## Example
13
+
14
+ ```ruby
15
+ require 'zernio-sdk'
16
+
17
+ instance = Zernio::WebhookPayloadPhoneNumberStockAvailable.new(
18
+ id: null,
19
+ event: null,
20
+ stock: null,
21
+ timestamp: null
22
+ )
23
+ ```
24
+
@@ -0,0 +1,20 @@
1
+ # Zernio::WebhookPayloadPhoneNumberStockAvailableStock
2
+
3
+ ## Properties
4
+
5
+ | Name | Type | Description | Notes |
6
+ | ---- | ---- | ----------- | ----- |
7
+ | **country** | **String** | ISO 3166-1 alpha-2 country code of the watched country. | |
8
+ | **types** | [**Array&lt;WebhookPayloadPhoneNumberStockAvailableStockTypesInner&gt;**](WebhookPayloadPhoneNumberStockAvailableStockTypesInner.md) | Number types deliverable at sweep time. Only types with stock are listed. | |
9
+
10
+ ## Example
11
+
12
+ ```ruby
13
+ require 'zernio-sdk'
14
+
15
+ instance = Zernio::WebhookPayloadPhoneNumberStockAvailableStock.new(
16
+ country: null,
17
+ types: null
18
+ )
19
+ ```
20
+
@@ -0,0 +1,20 @@
1
+ # Zernio::WebhookPayloadPhoneNumberStockAvailableStockTypesInner
2
+
3
+ ## Properties
4
+
5
+ | Name | Type | Description | Notes |
6
+ | ---- | ---- | ----------- | ----- |
7
+ | **number_type** | **String** | local, mobile, national or toll_free. | |
8
+ | **available_count** | **Integer** | Deliverable numbers at sweep time; first come, first served. | |
9
+
10
+ ## Example
11
+
12
+ ```ruby
13
+ require 'zernio-sdk'
14
+
15
+ instance = Zernio::WebhookPayloadPhoneNumberStockAvailableStockTypesInner.new(
16
+ number_type: null,
17
+ available_count: null
18
+ )
19
+ ```
20
+
@@ -360,6 +360,135 @@ module Zernio
360
360
  return data, status_code, headers
361
361
  end
362
362
 
363
+ # Watch an out-of-stock country
364
+ # Get notified the first time an out-of-stock country has deliverable numbers again: an email to the account holder plus the `phone_number.stock_available` webhook. Stock is re-checked every 6h. One watch per country; a repeat request returns the existing watch (200). The watch is consumed when it fires, so re-create it if you miss the stock. Up to 20 countries can be watched at once.
365
+ # @param create_phone_number_stock_watch_request [CreatePhoneNumberStockWatchRequest]
366
+ # @param [Hash] opts the optional parameters
367
+ # @return [PhoneNumberStockWatch]
368
+ def create_phone_number_stock_watch(create_phone_number_stock_watch_request, opts = {})
369
+ data, _status_code, _headers = create_phone_number_stock_watch_with_http_info(create_phone_number_stock_watch_request, opts)
370
+ data
371
+ end
372
+
373
+ # Watch an out-of-stock country
374
+ # Get notified the first time an out-of-stock country has deliverable numbers again: an email to the account holder plus the &#x60;phone_number.stock_available&#x60; webhook. Stock is re-checked every 6h. One watch per country; a repeat request returns the existing watch (200). The watch is consumed when it fires, so re-create it if you miss the stock. Up to 20 countries can be watched at once.
375
+ # @param create_phone_number_stock_watch_request [CreatePhoneNumberStockWatchRequest]
376
+ # @param [Hash] opts the optional parameters
377
+ # @return [Array<(PhoneNumberStockWatch, Integer, Hash)>] PhoneNumberStockWatch data, response status code and response headers
378
+ def create_phone_number_stock_watch_with_http_info(create_phone_number_stock_watch_request, opts = {})
379
+ if @api_client.config.debugging
380
+ @api_client.config.logger.debug 'Calling API: PhoneNumbersApi.create_phone_number_stock_watch ...'
381
+ end
382
+ # verify the required parameter 'create_phone_number_stock_watch_request' is set
383
+ if @api_client.config.client_side_validation && create_phone_number_stock_watch_request.nil?
384
+ fail ArgumentError, "Missing the required parameter 'create_phone_number_stock_watch_request' when calling PhoneNumbersApi.create_phone_number_stock_watch"
385
+ end
386
+ # resource path
387
+ local_var_path = '/v1/phone-numbers/stock-watches'
388
+
389
+ # query parameters
390
+ query_params = opts[:query_params] || {}
391
+
392
+ # header parameters
393
+ header_params = opts[:header_params] || {}
394
+ # HTTP header 'Accept' (if needed)
395
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
396
+ # HTTP header 'Content-Type'
397
+ content_type = @api_client.select_header_content_type(['application/json'])
398
+ if !content_type.nil?
399
+ header_params['Content-Type'] = content_type
400
+ end
401
+
402
+ # form parameters
403
+ form_params = opts[:form_params] || {}
404
+
405
+ # http body (model)
406
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(create_phone_number_stock_watch_request)
407
+
408
+ # return_type
409
+ return_type = opts[:debug_return_type] || 'PhoneNumberStockWatch'
410
+
411
+ # auth_names
412
+ auth_names = opts[:debug_auth_names] || ['bearerAuth']
413
+
414
+ new_options = opts.merge(
415
+ :operation => :"PhoneNumbersApi.create_phone_number_stock_watch",
416
+ :header_params => header_params,
417
+ :query_params => query_params,
418
+ :form_params => form_params,
419
+ :body => post_body,
420
+ :auth_names => auth_names,
421
+ :return_type => return_type
422
+ )
423
+
424
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
425
+ if @api_client.config.debugging
426
+ @api_client.config.logger.debug "API called: PhoneNumbersApi#create_phone_number_stock_watch\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
427
+ end
428
+ return data, status_code, headers
429
+ end
430
+
431
+ # Stop watching a country
432
+ # @param id [String]
433
+ # @param [Hash] opts the optional parameters
434
+ # @return [DeleteSmsSenderId200Response]
435
+ def delete_phone_number_stock_watch(id, opts = {})
436
+ data, _status_code, _headers = delete_phone_number_stock_watch_with_http_info(id, opts)
437
+ data
438
+ end
439
+
440
+ # Stop watching a country
441
+ # @param id [String]
442
+ # @param [Hash] opts the optional parameters
443
+ # @return [Array<(DeleteSmsSenderId200Response, Integer, Hash)>] DeleteSmsSenderId200Response data, response status code and response headers
444
+ def delete_phone_number_stock_watch_with_http_info(id, opts = {})
445
+ if @api_client.config.debugging
446
+ @api_client.config.logger.debug 'Calling API: PhoneNumbersApi.delete_phone_number_stock_watch ...'
447
+ end
448
+ # verify the required parameter 'id' is set
449
+ if @api_client.config.client_side_validation && id.nil?
450
+ fail ArgumentError, "Missing the required parameter 'id' when calling PhoneNumbersApi.delete_phone_number_stock_watch"
451
+ end
452
+ # resource path
453
+ local_var_path = '/v1/phone-numbers/stock-watches/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))
454
+
455
+ # query parameters
456
+ query_params = opts[:query_params] || {}
457
+
458
+ # header parameters
459
+ header_params = opts[:header_params] || {}
460
+ # HTTP header 'Accept' (if needed)
461
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
462
+
463
+ # form parameters
464
+ form_params = opts[:form_params] || {}
465
+
466
+ # http body (model)
467
+ post_body = opts[:debug_body]
468
+
469
+ # return_type
470
+ return_type = opts[:debug_return_type] || 'DeleteSmsSenderId200Response'
471
+
472
+ # auth_names
473
+ auth_names = opts[:debug_auth_names] || ['bearerAuth']
474
+
475
+ new_options = opts.merge(
476
+ :operation => :"PhoneNumbersApi.delete_phone_number_stock_watch",
477
+ :header_params => header_params,
478
+ :query_params => query_params,
479
+ :form_params => form_params,
480
+ :body => post_body,
481
+ :auth_names => auth_names,
482
+ :return_type => return_type
483
+ )
484
+
485
+ data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
486
+ if @api_client.config.debugging
487
+ @api_client.config.logger.debug "API called: PhoneNumbersApi#delete_phone_number_stock_watch\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
488
+ end
489
+ return data, status_code, headers
490
+ end
491
+
363
492
  # Get phone number
364
493
  # Retrieve the current status of a purchased phone number. Poll this to track Meta pre-verification (US sync path) and, for regulated (Tier 3/4) numbers, the async lifecycle: pending_regulatory → active (or regulatory_declined). When a regulated number has an Onfido ID step, `onfidoVerificationUrl` appears here once the order is placed — forward it to the end user. (Or subscribe to the whatsapp.number.* webhooks instead of polling.)
365
494
  # @param id [String] Phone number record ID
@@ -813,6 +942,61 @@ module Zernio
813
942
  return data, status_code, headers
814
943
  end
815
944
 
945
+ # List stock watches
946
+ # @param [Hash] opts the optional parameters
947
+ # @return [ListPhoneNumberStockWatches200Response]
948
+ def list_phone_number_stock_watches(opts = {})
949
+ data, _status_code, _headers = list_phone_number_stock_watches_with_http_info(opts)
950
+ data
951
+ end
952
+
953
+ # List stock watches
954
+ # @param [Hash] opts the optional parameters
955
+ # @return [Array<(ListPhoneNumberStockWatches200Response, Integer, Hash)>] ListPhoneNumberStockWatches200Response data, response status code and response headers
956
+ def list_phone_number_stock_watches_with_http_info(opts = {})
957
+ if @api_client.config.debugging
958
+ @api_client.config.logger.debug 'Calling API: PhoneNumbersApi.list_phone_number_stock_watches ...'
959
+ end
960
+ # resource path
961
+ local_var_path = '/v1/phone-numbers/stock-watches'
962
+
963
+ # query parameters
964
+ query_params = opts[:query_params] || {}
965
+
966
+ # header parameters
967
+ header_params = opts[:header_params] || {}
968
+ # HTTP header 'Accept' (if needed)
969
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
970
+
971
+ # form parameters
972
+ form_params = opts[:form_params] || {}
973
+
974
+ # http body (model)
975
+ post_body = opts[:debug_body]
976
+
977
+ # return_type
978
+ return_type = opts[:debug_return_type] || 'ListPhoneNumberStockWatches200Response'
979
+
980
+ # auth_names
981
+ auth_names = opts[:debug_auth_names] || ['bearerAuth']
982
+
983
+ new_options = opts.merge(
984
+ :operation => :"PhoneNumbersApi.list_phone_number_stock_watches",
985
+ :header_params => header_params,
986
+ :query_params => query_params,
987
+ :form_params => form_params,
988
+ :body => post_body,
989
+ :auth_names => auth_names,
990
+ :return_type => return_type
991
+ )
992
+
993
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
994
+ if @api_client.config.debugging
995
+ @api_client.config.logger.debug "API called: PhoneNumbersApi#list_phone_number_stock_watches\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
996
+ end
997
+ return data, status_code, headers
998
+ end
999
+
816
1000
  # List phone numbers
817
1001
  # List all phone numbers purchased by the authenticated user. By default, released numbers are excluded. Connected (bring-your-own) WhatsApp numbers are returned in the separate `connected` array; they are not billed and have no provisioning lifecycle.
818
1002
  # @param [Hash] opts the optional parameters
@@ -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, &#x60;true&#x60; forces a subscription reconciliation pass even when cached plan data looks complete.
236
236
  # @option opts [String] :range Window to report. &#x60;cycle&#x60; / &#x60;prev-cycle&#x60; resolve to the customer&#39;s real billing-period bounds (falling back to a trailing 30 days when no invoice exists yet); &#x60;7d&#x60;…&#x60;12mo&#x60; are trailing windows; &#x60;custom&#x60; uses &#x60;from&#x60; / &#x60;to&#x60;. (default to 'cycle')
237
237
  # @option opts [Date] :from Inclusive start (UTC date). Required when &#x60;range&#x3D;custom&#x60;.
238
238
  # @option opts [Date] :to Inclusive end (UTC date). Required when &#x60;range&#x3D;custom&#x60;. Max span 366 days.
239
239
  # @option opts [String] :granularity Bucketing of the &#x60;days&#x60; series: &#x60;day&#x60; (one row per UTC day), &#x60;month&#x60; (one row per calendar month, dated to the 1st), or &#x60;total&#x60; (no series — read &#x60;totals&#x60;). Does not affect &#x60;totals&#x60;. (default to 'day')
240
+ # @option opts [String] :group_by Metering mode. Adds &#x60;attribution&#x60;: the window&#39;s spend split per profile or per account (keys are ids; resolve names via &#x60;GET /v1/profiles&#x60; / &#x60;GET /v1/accounts&#x60;).
241
+ # @option opts [String] :profile_id Metering mode (pair with &#x60;range&#x60;). Project the payload onto this profile&#39;s attributed share. Mutually exclusive with &#x60;accountId&#x60;, and &#x60;groupBy&#x60; (if given) must be &#x60;profile&#x60;; 404 when the profile is not in your workspace (or outside a scoped key&#39;s profiles).
242
+ # @option opts [String] :account_id Metering mode (pair with &#x60;range&#x60;). Project the payload onto this account&#39;s attributed share. Mutually exclusive with &#x60;profileId&#x60;, and &#x60;groupBy&#x60; (if given) must be &#x60;account&#x60;; 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 &#x60;GET /v1/usage-stats&#x60;. Existing integrations keep working unchanged. **With &#x60;range&#x60;, &#x60;granularity&#x60;, &#x60;from&#x60;, or &#x60;to&#x60;:** usage METERING — billed spend (USD) by product family (&#x60;accounts&#x60;, &#x60;numbers&#x60;, &#x60;calls&#x60;, &#x60;sms&#x60;, &#x60;dlc&#x60;, &#x60;xApi&#x60;, &#x60;credits&#x60;, &#x60;other&#x60;) over the window, at &#x60;day&#x60; / &#x60;month&#x60; / &#x60;total&#x60; granularity, from Metronome&#39;s invoice breakdown (the CHARGE view — always reconciles with what gets billed). Also served at &#x60;GET /v1/usage/daily&#x60;. Usage-based accounts only — legacy Stripe accounts get &#x60;{ \&quot;supported\&quot;: false, \&quot;days\&quot;: [] }&#x60;. For per-domain consumption *volumes* use &#x60;GET /v1/usage/calls&#x60; and &#x60;GET /v1/usage/sms&#x60;. For the billing statement (balance, credits, caps, payment status) use &#x60;GET /v1/billing&#x60;.
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 &#x60;GET /v1/usage-stats&#x60;. Existing integrations keep working unchanged. **With &#x60;range&#x60;, &#x60;granularity&#x60;, &#x60;from&#x60;, or &#x60;to&#x60;:** usage METERING — billed spend (USD) by product family (&#x60;accounts&#x60;, &#x60;numbers&#x60;, &#x60;calls&#x60;, &#x60;sms&#x60;, &#x60;dlc&#x60;, &#x60;xApi&#x60;, &#x60;credits&#x60;, &#x60;other&#x60;) over the window, at &#x60;day&#x60; / &#x60;month&#x60; / &#x60;total&#x60; granularity, from Metronome&#39;s invoice breakdown (the CHARGE view — always reconciles with what gets billed). Also served at &#x60;GET /v1/usage/daily&#x60;. Usage-based accounts only — legacy Stripe accounts get &#x60;{ \&quot;supported\&quot;: false, \&quot;days\&quot;: [] }&#x60;. **Attribution (metering mode):** &#x60;groupBy&#x3D;profile|account&#x60; adds an &#x60;attribution&#x60; breakdown of the window&#39;s spend per profile or account, assembled from your own records and pro-rated against the invoice so &#x60;sum(groups) + unattributed&#x60; equals &#x60;totals&#x60; exactly. &#x60;profileId&#x60; / &#x60;accountId&#x60; instead project the whole payload (&#x60;days&#x60;, &#x60;totals&#x60;, &#x60;lineItems&#x60;) onto that one group; &#x60;peaks&#x60;, &#x60;callUsage&#x60; and &#x60;tax&#x60; are then &#x60;null&#x60; (workspace-level facts). Projected &#x60;days&#x60; spread the group&#39;s period share over each day (usage is attributed per period, not per day). Profile-scoped API keys and members only see their profiles&#39; groups (&#x60;attribution.restricted: true&#x60;, with &#x60;totals&#x60; summing the visible groups). Credits, 10DLC fees and Verify are always unattributed. &#x60;profileId&#x60; / &#x60;accountId&#x60; on their own do not select metering mode: pair them with &#x60;range&#x60;. For per-domain consumption *volumes* use &#x60;GET /v1/usage/calls&#x60; and &#x60;GET /v1/usage/sms&#x60;. For the billing statement (balance, credits, caps, payment status) use &#x60;GET /v1/billing&#x60;.
248
251
  # @param [Hash] opts the optional parameters
249
252
  # @option opts [Boolean] :reconcile Snapshot mode only. For Stripe subscription users, &#x60;true&#x60; forces a subscription reconciliation pass even when cached plan data looks complete.
250
253
  # @option opts [String] :range Window to report. &#x60;cycle&#x60; / &#x60;prev-cycle&#x60; resolve to the customer&#39;s real billing-period bounds (falling back to a trailing 30 days when no invoice exists yet); &#x60;7d&#x60;…&#x60;12mo&#x60; are trailing windows; &#x60;custom&#x60; uses &#x60;from&#x60; / &#x60;to&#x60;. (default to 'cycle')
251
254
  # @option opts [Date] :from Inclusive start (UTC date). Required when &#x60;range&#x3D;custom&#x60;.
252
255
  # @option opts [Date] :to Inclusive end (UTC date). Required when &#x60;range&#x3D;custom&#x60;. Max span 366 days.
253
256
  # @option opts [String] :granularity Bucketing of the &#x60;days&#x60; series: &#x60;day&#x60; (one row per UTC day), &#x60;month&#x60; (one row per calendar month, dated to the 1st), or &#x60;total&#x60; (no series — read &#x60;totals&#x60;). Does not affect &#x60;totals&#x60;. (default to 'day')
257
+ # @option opts [String] :group_by Metering mode. Adds &#x60;attribution&#x60;: the window&#39;s spend split per profile or per account (keys are ids; resolve names via &#x60;GET /v1/profiles&#x60; / &#x60;GET /v1/accounts&#x60;).
258
+ # @option opts [String] :profile_id Metering mode (pair with &#x60;range&#x60;). Project the payload onto this profile&#39;s attributed share. Mutually exclusive with &#x60;accountId&#x60;, and &#x60;groupBy&#x60; (if given) must be &#x60;profile&#x60;; 404 when the profile is not in your workspace (or outside a scoped key&#39;s profiles).
259
+ # @option opts [String] :account_id Metering mode (pair with &#x60;range&#x60;). Project the payload onto this account&#39;s attributed share. Mutually exclusive with &#x60;profileId&#x60;, and &#x60;groupBy&#x60; (if given) must be &#x60;account&#x60;; 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] || {}
@@ -1207,6 +1207,72 @@ module Zernio
1207
1207
  return data, status_code, headers
1208
1208
  end
1209
1209
 
1210
+ # Phone-number stock available event
1211
+ # Fired by the stock sweep (every 6h) the first time a country you watch via POST /v1/phone-numbers/stock-watches has deliverable numbers again. The watch is consumed, so the event fires once per watch; the stock counts are a snapshot and numbers are sold first come, first served. Buy with POST /v1/phone-numbers/purchase.
1212
+ # @param webhook_payload_phone_number_stock_available [WebhookPayloadPhoneNumberStockAvailable]
1213
+ # @param [Hash] opts the optional parameters
1214
+ # @return [nil]
1215
+ def on_phone_number_stock_available(webhook_payload_phone_number_stock_available, opts = {})
1216
+ on_phone_number_stock_available_with_http_info(webhook_payload_phone_number_stock_available, opts)
1217
+ nil
1218
+ end
1219
+
1220
+ # Phone-number stock available event
1221
+ # Fired by the stock sweep (every 6h) the first time a country you watch via POST /v1/phone-numbers/stock-watches has deliverable numbers again. The watch is consumed, so the event fires once per watch; the stock counts are a snapshot and numbers are sold first come, first served. Buy with POST /v1/phone-numbers/purchase.
1222
+ # @param webhook_payload_phone_number_stock_available [WebhookPayloadPhoneNumberStockAvailable]
1223
+ # @param [Hash] opts the optional parameters
1224
+ # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
1225
+ def on_phone_number_stock_available_with_http_info(webhook_payload_phone_number_stock_available, opts = {})
1226
+ if @api_client.config.debugging
1227
+ @api_client.config.logger.debug 'Calling API: WebhookEventsApi.on_phone_number_stock_available ...'
1228
+ end
1229
+ # verify the required parameter 'webhook_payload_phone_number_stock_available' is set
1230
+ if @api_client.config.client_side_validation && webhook_payload_phone_number_stock_available.nil?
1231
+ fail ArgumentError, "Missing the required parameter 'webhook_payload_phone_number_stock_available' when calling WebhookEventsApi.on_phone_number_stock_available"
1232
+ end
1233
+ # resource path
1234
+ local_var_path = '/phone_number.stock_available'
1235
+
1236
+ # query parameters
1237
+ query_params = opts[:query_params] || {}
1238
+
1239
+ # header parameters
1240
+ header_params = opts[:header_params] || {}
1241
+ # HTTP header 'Content-Type'
1242
+ content_type = @api_client.select_header_content_type(['application/json'])
1243
+ if !content_type.nil?
1244
+ header_params['Content-Type'] = content_type
1245
+ end
1246
+
1247
+ # form parameters
1248
+ form_params = opts[:form_params] || {}
1249
+
1250
+ # http body (model)
1251
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(webhook_payload_phone_number_stock_available)
1252
+
1253
+ # return_type
1254
+ return_type = opts[:debug_return_type]
1255
+
1256
+ # auth_names
1257
+ auth_names = opts[:debug_auth_names] || ['bearerAuth']
1258
+
1259
+ new_options = opts.merge(
1260
+ :operation => :"WebhookEventsApi.on_phone_number_stock_available",
1261
+ :header_params => header_params,
1262
+ :query_params => query_params,
1263
+ :form_params => form_params,
1264
+ :body => post_body,
1265
+ :auth_names => auth_names,
1266
+ :return_type => return_type
1267
+ )
1268
+
1269
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
1270
+ if @api_client.config.debugging
1271
+ @api_client.config.logger.debug "API called: WebhookEventsApi#on_phone_number_stock_available\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
1272
+ end
1273
+ return data, status_code, headers
1274
+ end
1275
+
1210
1276
  # Post cancelled event
1211
1277
  # Fired when a post publishing job is cancelled.
1212
1278
  # @param webhook_payload_post [WebhookPayloadPost]