Preview Events
Preview events
v1.customers.preview_events(**kwargs) -> dataInvoiceCustomerPreviewEventsResponse
post/v1/customers/{customer_id}/previewEvents
Preview how a set of events will affect a customer's invoice. Generates a draft invoice for a customer using their current contract configuration and the provided events. This is useful for testing how new events will affect the customer's invoice before they are actually processed.
Parameters
customer_idString
formatuuid
eventsarray
Array[{ event_type, customer_id, properties, 2 more}]
modeunion
optional
:replace | :merge
If set to "replace", the preview will be generated as if those were the only events for the specified customer. If set to "merge", the events will be merged with any existing events for the specified customer. Defaults to "replace".
skip_zero_qty_line_itemsbool
optional
If set, all zero quantity line items will be filtered out of the response.
Returns
CustomerPreviewEventsResponseclass
require "metronome_sdk"
metronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")
response = metronome.v1.customers.preview_events(
customer_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",
events: [{event_type: "heartbeat"}]
)
puts(response)
200 Example
{
"data": {
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"credit_type": {
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"name": "name"
},
"customer_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"line_items": [
{
"credit_type": {
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"name": "name"
},
"name": "name",
"total": 0,
"applied_commit_or_credit": {
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"type": "PREPAID"
},
"commit_custom_fields": {
"foo": "string"
},
"commit_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"commit_netsuite_item_id": "commit_netsuite_item_id",
"commit_netsuite_sales_order_id": "commit_netsuite_sales_order_id",
"commit_segment_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"commit_type": "commit_type",
"custom_fields": {
"foo": "string"
},
"discount_custom_fields": {
"foo": "string"
},
"discount_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"ending_before": "2019-12-27T18:11:19.117Z",
"group_key": "group_key",
"group_value": "group_value",
"is_prorated": true,
"list_price": {
"rate_type": "FLAT",
"credit_type": {
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"name": "name"
},
"custom_rate": {
"foo": "bar"
},
"is_prorated": true,
"price": 0,
"pricing_group_values": {
"foo": "string"
},
"quantity": 0,
"tiers": [
{
"price": 0,
"size": 0
}
],
"use_list_prices": true
},
"metadata": "metadata",
"netsuite_invoice_billing_end": "2019-12-27T18:11:19.117Z",
"netsuite_invoice_billing_start": "2019-12-27T18:11:19.117Z",
"netsuite_item_id": "netsuite_item_id",
"postpaid_commit": {
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
},
"presentation_group_values": {
"foo": "string"
},
"pricing_group_values": {
"foo": "string"
},
"product_custom_fields": {
"foo": "string"
},
"product_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"product_tags": [
"string"
],
"product_type": "product_type",
"professional_service_custom_fields": {
"foo": "string"
},
"professional_service_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"quantity": 0,
"reseller_type": "AWS",
"scheduled_charge_custom_fields": {
"foo": "string"
},
"scheduled_charge_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"starting_at": "2019-12-27T18:11:19.117Z",
"sub_line_items": [
{
"custom_fields": {
"foo": "string"
},
"name": "name",
"quantity": 0,
"subtotal": 0,
"charge_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"credit_grant_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"end_date": "2019-12-27T18:11:19.117Z",
"price": 0,
"start_date": "2019-12-27T18:11:19.117Z",
"tier_period": {
"starting_at": "2019-12-27T18:11:19.117Z",
"ending_before": "2019-12-27T18:11:19.117Z"
},
"tiers": [
{
"price": 0,
"quantity": 0,
"starting_at": 0,
"subtotal": 0
}
]
}
],
"subscription_custom_fields": {
"foo": "string"
},
"tier": {
"level": 0,
"starting_at": "starting_at",
"size": "size"
},
"unit_price": 0
}
],
"status": "DRAFT, VOID, or FINALIZED",
"total": 0,
"type": "PLAN_ARREARS, SCHEDULED, USAGE, CORRECTION, CREDIT_PURCHASE, or SEAT_PURCHASE",
"amendment_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"billable_status": "billable",
"contract_custom_fields": {
"foo": "string"
},
"contract_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"correction_record": {
"corrected_invoice_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"memo": "memo",
"reason": "reason",
"corrected_external_invoice": {
"billing_provider_type": "aws_marketplace",
"external_status": "DRAFT",
"invoice_id": "invoice_id",
"issued_at_timestamp": "2019-12-27T18:11:19.117Z"
}
},
"created_at": "2019-12-27T18:11:19.117Z",
"custom_fields": {
"foo": "bar"
},
"customer_custom_fields": {
"foo": "string"
},
"end_timestamp": "2019-12-27T18:11:19.117Z",
"external_invoice": {
"billing_provider_type": "aws_marketplace",
"external_status": "DRAFT",
"invoice_id": "invoice_id",
"issued_at_timestamp": "2019-12-27T18:11:19.117Z"
},
"invoice_adjustments": [
{
"credit_type": {
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"name": "name"
},
"name": "Monthly minimum ($1,000)",
"total": 0,
"credit_grant_custom_fields": {
"foo": "string"
},
"credit_grant_id": "credit_grant_id"
}
],
"issued_at": "2019-12-27T18:11:19.117Z",
"net_payment_terms_days": 0,
"netsuite_sales_order_id": "netsuite_sales_order_id",
"plan_custom_fields": {
"foo": "string"
},
"plan_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"plan_name": "plan_name",
"reseller_royalty": {
"fraction": "fraction",
"netsuite_reseller_id": "netsuite_reseller_id",
"reseller_type": "AWS",
"aws_options": {
"aws_account_number": "aws_account_number",
"aws_offer_id": "aws_offer_id",
"aws_payer_reference_id": "aws_payer_reference_id"
},
"gcp_options": {
"gcp_account_id": "gcp_account_id",
"gcp_offer_id": "gcp_offer_id"
}
},
"salesforce_opportunity_id": "salesforce_opportunity_id",
"start_timestamp": "2019-12-27T18:11:19.117Z",
"subtotal": 0
}
}