Preview Events
Preview events
client.V1.Customers.PreviewEvents(ctx, params) (*DataInvoiceV1CustomerPreviewEventsResponse, error)
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
paramsCustomerIDfieldEventsfieldModefieldSkipZeroQtyLineItemsfieldV1CustomerPreviewEventsParams
Returns
V1CustomerPreviewEventsResponsestruct
package main
import (
"context"
"fmt"
"github.com/Metronome-Industries/metronome-go"
"github.com/Metronome-Industries/metronome-go/option"
)
func main() {
client := metronome.NewClient(
option.WithBearerToken("My Bearer Token"),
)
response, err := client.V1.Customers.PreviewEvents(context.TODO(), metronome.V1CustomerPreviewEventsParams{
CustomerID: metronome.F("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc"),
Events: metronome.F([]metronome.V1CustomerPreviewEventsParamsEvent{metronome.V1CustomerPreviewEventsParamsEvent{
EventType: metronome.F("heartbeat"),
Timestamp: metronome.F("2021-01-01T00:00:00Z"),
Properties: metronome.F(map[string]interface{}{
"cpu_hours": 100,
"memory_gb_hours": 200,
}),
}}),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Data)
}
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
}
}