Skip to content

Commit

Permalink
feat(weighted-sum): Add weighted sum fields to billable metric (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent-pochet authored Sep 21, 2023
1 parent 7aade97 commit 6bc48ff
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
23 changes: 16 additions & 7 deletions billable_metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,28 @@ const (
MaxAggregation AggregationType = "max_agg"
UniqueCountAggregation AggregationType = "unique_count_agg"
RecurringCountAggregation AggregationType = "recurring_count_agg"
WeightedSumAggregation AggregationType = "weighted_sum_agg"
)

type WeightedInterval string

const (
SecondsInterval WeightedInterval = "seconds"
)

type BillableMetricParams struct {
BillableMetricInput *BillableMetricInput `json:"billable_metric,omitempty"`
}

type BillableMetricInput struct {
Name string `json:"name,omitempty"`
Code string `json:"code,omitempty"`
Description string `json:"description,omitempty"`
AggregationType AggregationType `json:"aggregation_type,omitempty"`
Recurring bool `json:"recurring,omitempty"`
FieldName string `json:"field_name"`
Group map[string]interface{} `json:"group,omitempty"`
Name string `json:"name,omitempty"`
Code string `json:"code,omitempty"`
Description string `json:"description,omitempty"`
AggregationType AggregationType `json:"aggregation_type,omitempty"`
Recurring bool `json:"recurring,omitempty"`
FieldName string `json:"field_name"`
WeightedInterval WeightedInterval `json:"weighted_interval,omitempty"`
Group map[string]interface{} `json:"group,omitempty"`
}

type BillableMetricListInput struct {
Expand All @@ -57,6 +65,7 @@ type BillableMetric struct {
AggregationType AggregationType `json:"aggregation_type,omitempty"`
FieldName string `json:"field_name"`
CreatedAt time.Time `json:"created_at,omitempty"`
WeightedInterval *WeightedInterval `json:"weighted_interval,omitempty"`
Group map[string]interface{} `json:"group,omitempty"`
ActiveSubscriptionsCount int `json:"active_subscriptions_count,omitempty"`
DraftInvoicesCount int `json:"draft_invoices_count,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion event.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type EventInput struct {
ExternalCustomerID string `json:"external_customer_id,omitempty"`
ExternalSubscriptionID string `json:"external_subscription_id,omitempty"`
Code string `json:"code,omitempty"`
Timestamp int64 `json:"timestamp,omitempty"`
Timestamp string `json:"timestamp,omitempty"`
Properties map[string]interface{} `json:"properties,omitempty"`
}

Expand Down

0 comments on commit 6bc48ff

Please sign in to comment.