eventsBasedBillingSegmentsController := client.EventsBasedBillingSegmentsController()
EventsBasedBillingSegmentsController
- Create Segment
- List Segments for Price Point
- Update Segment
- Delete Segment
- Bulk Create Segments
- Bulk Update Segments
This endpoint creates a new Segment for a Component with segmented Metric. It allows you to specify properties to bill upon and prices for each Segment. You can only pass as many "property_values" as the related Metric has segmenting properties defined.
You may specify component and/or price point by using either the numeric ID or the handle:gold
syntax.
CreateSegment(
ctx context.Context,
componentId string,
pricePointId string,
body *models.CreateSegmentRequest) (
models.ApiResponse[models.SegmentResponse],
error)
Parameter | Type | Tags | Description |
---|---|---|---|
componentId |
string |
Template, Required | ID or Handle for the Component |
pricePointId |
string |
Template, Required | ID or Handle for the Price Point belonging to the Component |
body |
*models.CreateSegmentRequest |
Body, Optional | - |
ctx := context.Background()
componentId := "component_id8"
pricePointId := "price_point_id8"
body := models.CreateSegmentRequest{
Segment: models.CreateSegment{
SegmentProperty1Value: models.ToPointer(models.CreateSegmentSegmentProperty1ValueContainer.FromString("France")),
SegmentProperty2Value: models.ToPointer(models.CreateSegmentSegmentProperty2ValueContainer.FromString("Spain")),
PricingScheme: models.PricingScheme("volume"),
Prices: []models.CreateOrUpdateSegmentPrice{
models.CreateOrUpdateSegmentPrice{
StartingQuantity: models.ToPointer(1),
EndingQuantity: models.ToPointer(10000),
UnitPrice: models.CreateOrUpdateSegmentPriceUnitPriceContainer.FromPrecision(float64(0.19)),
},
models.CreateOrUpdateSegmentPrice{
StartingQuantity: models.ToPointer(10001),
UnitPrice: models.CreateOrUpdateSegmentPriceUnitPriceContainer.FromPrecision(float64(0.09)),
},
},
},
}
apiResponse, err := eventsBasedBillingSegmentsController.CreateSegment(ctx, componentId, pricePointId, &body)
if err != nil {
log.Fatalln(err)
} else {
// Printing the result and response
fmt.Println(apiResponse.Data)
fmt.Println(apiResponse.Response.StatusCode)
}
HTTP Status Code | Error Description | Exception Class |
---|---|---|
404 | Not Found | ApiError |
422 | Unprocessable Entity (WebDAV) | EventBasedBillingSegmentErrorsException |
This endpoint allows you to fetch Segments created for a given Price Point. They will be returned in the order of creation.
You can pass page
and per_page
parameters in order to access all of the segments. By default it will return 30
records. You can set per_page
to 200
at most.
You may specify component and/or price point by using either the numeric ID or the handle:gold
syntax.
ListSegmentsForPricePoint(
ctx context.Context,
input ListSegmentsForPricePointInput) (
models.ApiResponse[models.ListSegmentsResponse],
error)
Parameter | Type | Tags | Description |
---|---|---|---|
componentId |
string |
Template, Required | ID or Handle for the Component |
pricePointId |
string |
Template, Required | ID or Handle for the Price Point belonging to the Component |
page |
*int |
Query, Optional | Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned. Use in query page=1 . |
perPage |
*int |
Query, Optional | This parameter indicates how many records to fetch in each request. Default value is 30. The maximum allowed values is 200; any per_page value over 200 will be changed to 200. Use in query per_page=200 . |
filter |
*models.ListSegmentsFilter |
Query, Optional | Filter to use for List Segments for a Price Point operation |
ctx := context.Background()
collectedInput := advancedbilling.ListSegmentsForPricePointInput{
ComponentId: "component_id8",
PricePointId: "price_point_id8",
Page: models.ToPointer(2),
PerPage: models.ToPointer(50),
Filter: models.ToPointer(models.ListSegmentsFilter{
SegmentProperty1Value: models.ToPointer("EU"),
}),
}
apiResponse, err := eventsBasedBillingSegmentsController.ListSegmentsForPricePoint(ctx, collectedInput)
if err != nil {
log.Fatalln(err)
} else {
// Printing the result and response
fmt.Println(apiResponse.Data)
fmt.Println(apiResponse.Response.StatusCode)
}
HTTP Status Code | Error Description | Exception Class |
---|---|---|
404 | Not Found | ApiError |
422 | Unprocessable Entity (WebDAV) | EventBasedBillingListSegmentsErrorsException |
This endpoint updates a single Segment for a Component with a segmented Metric. It allows you to update the pricing for the segment.
You may specify component and/or price point by using either the numeric ID or the handle:gold
syntax.
UpdateSegment(
ctx context.Context,
componentId string,
pricePointId string,
id float64,
body *models.UpdateSegmentRequest) (
models.ApiResponse[models.SegmentResponse],
error)
Parameter | Type | Tags | Description |
---|---|---|---|
componentId |
string |
Template, Required | ID or Handle of the Component |
pricePointId |
string |
Template, Required | ID or Handle of the Price Point belonging to the Component |
id |
float64 |
Template, Required | The ID of the Segment |
body |
*models.UpdateSegmentRequest |
Body, Optional | - |
ctx := context.Background()
componentId := "component_id8"
pricePointId := "price_point_id8"
id := float64(60)
apiResponse, err := eventsBasedBillingSegmentsController.UpdateSegment(ctx, componentId, pricePointId, id, nil)
if err != nil {
log.Fatalln(err)
} else {
// Printing the result and response
fmt.Println(apiResponse.Data)
fmt.Println(apiResponse.Response.StatusCode)
}
HTTP Status Code | Error Description | Exception Class |
---|---|---|
404 | Not Found | ApiError |
422 | Unprocessable Entity (WebDAV) | EventBasedBillingSegmentErrorsException |
This endpoint allows you to delete a Segment with specified ID.
You may specify component and/or price point by using either the numeric ID or the handle:gold
syntax.
DeleteSegment(
ctx context.Context,
componentId string,
pricePointId string,
id float64) (
http.Response,
error)
Parameter | Type | Tags | Description |
---|---|---|---|
componentId |
string |
Template, Required | ID or Handle of the Component |
pricePointId |
string |
Template, Required | ID or Handle of the Price Point belonging to the Component |
id |
float64 |
Template, Required | The ID of the Segment |
``
ctx := context.Background()
componentId := "component_id8"
pricePointId := "price_point_id8"
id := float64(60)
resp, err := eventsBasedBillingSegmentsController.DeleteSegment(ctx, componentId, pricePointId, id)
if err != nil {
log.Fatalln(err)
} else {
fmt.Println(resp.StatusCode)
}
HTTP Status Code | Error Description | Exception Class |
---|---|---|
404 | Not Found | ApiError |
422 | Unprocessable Entity (WebDAV) | ApiError |
This endpoint allows you to create multiple segments in one request. The array of segments can contain up to 2000
records.
If any of the records contain an error the whole request would fail and none of the requested segments get created. The error response contains a message for only the one segment that failed validation, with the corresponding index in the array.
You may specify component and/or price point by using either the numeric ID or the handle:gold
syntax.
BulkCreateSegments(
ctx context.Context,
componentId string,
pricePointId string,
body *models.BulkCreateSegments) (
models.ApiResponse[models.ListSegmentsResponse],
error)
Parameter | Type | Tags | Description |
---|---|---|---|
componentId |
string |
Template, Required | ID or Handle for the Component |
pricePointId |
string |
Template, Required | ID or Handle for the Price Point belonging to the Component |
body |
*models.BulkCreateSegments |
Body, Optional | - |
ctx := context.Background()
componentId := "component_id8"
pricePointId := "price_point_id8"
apiResponse, err := eventsBasedBillingSegmentsController.BulkCreateSegments(ctx, componentId, pricePointId, nil)
if err != nil {
log.Fatalln(err)
} else {
// Printing the result and response
fmt.Println(apiResponse.Data)
fmt.Println(apiResponse.Response.StatusCode)
}
HTTP Status Code | Error Description | Exception Class |
---|---|---|
404 | Not Found | ApiError |
422 | Unprocessable Entity (WebDAV) | EventBasedBillingSegmentException |
This endpoint allows you to update multiple segments in one request. The array of segments can contain up to 1000
records.
If any of the records contain an error the whole request would fail and none of the requested segments get updated. The error response contains a message for only the one segment that failed validation, with the corresponding index in the array.
You may specify component and/or price point by using either the numeric ID or the handle:gold
syntax.
BulkUpdateSegments(
ctx context.Context,
componentId string,
pricePointId string,
body *models.BulkUpdateSegments) (
models.ApiResponse[models.ListSegmentsResponse],
error)
Parameter | Type | Tags | Description |
---|---|---|---|
componentId |
string |
Template, Required | ID or Handle for the Component |
pricePointId |
string |
Template, Required | ID or Handle for the Price Point belonging to the Component |
body |
*models.BulkUpdateSegments |
Body, Optional | - |
ctx := context.Background()
componentId := "component_id8"
pricePointId := "price_point_id8"
apiResponse, err := eventsBasedBillingSegmentsController.BulkUpdateSegments(ctx, componentId, pricePointId, nil)
if err != nil {
log.Fatalln(err)
} else {
// Printing the result and response
fmt.Println(apiResponse.Data)
fmt.Println(apiResponse.Response.StatusCode)
}
HTTP Status Code | Error Description | Exception Class |
---|---|---|
404 | Not Found | ApiError |
422 | Unprocessable Entity (WebDAV) | EventBasedBillingSegmentException |