Skip to content

Commit

Permalink
feat(api): api update (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Nov 5, 2024
1 parent a049cc7 commit 4f67b04
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 65 deletions.
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 91
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/metronome%2Fmetronome-ebf6ec71381ac4de43a238b439ff137f915f48cdb2533b8422d069cebece35c2.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/metronome%2Fmetronome-d04cc2dc5a1f1bd278783a02c8bbf246f850ce53fe63d7d43cb9df69fae02429.yml
15 changes: 13 additions & 2 deletions billablemetric.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"fmt"
"net/http"
"net/url"
"time"

"github.com/Metronome-Industries/metronome-go/internal/apijson"
"github.com/Metronome-Industries/metronome-go/internal/apiquery"
Expand Down Expand Up @@ -141,7 +142,10 @@ type BillableMetricGetResponseData struct {
AggregationKey string `json:"aggregation_key"`
// Specifies the type of aggregation performed on matching events.
AggregationType BillableMetricGetResponseDataAggregationType `json:"aggregation_type"`
CustomFields map[string]string `json:"custom_fields"`
// RFC 3339 timestamp indicating when the billable metric was archived. If not
// provided, the billable metric is not archived.
ArchivedAt time.Time `json:"archived_at" format:"date-time"`
CustomFields map[string]string `json:"custom_fields"`
// An optional filtering rule to match the 'event_type' property of an event.
EventTypeFilter shared.EventTypeFilter `json:"event_type_filter"`
// Property names that are used to group usage costs on an invoice. Each entry
Expand All @@ -163,6 +167,7 @@ type billableMetricGetResponseDataJSON struct {
Name apijson.Field
AggregationKey apijson.Field
AggregationType apijson.Field
ArchivedAt apijson.Field
CustomFields apijson.Field
EventTypeFilter apijson.Field
GroupKeys apijson.Field
Expand Down Expand Up @@ -210,7 +215,10 @@ type BillableMetricListResponse struct {
AggregationKey string `json:"aggregation_key"`
// Specifies the type of aggregation performed on matching events.
AggregationType BillableMetricListResponseAggregationType `json:"aggregation_type"`
CustomFields map[string]string `json:"custom_fields"`
// RFC 3339 timestamp indicating when the billable metric was archived. If not
// provided, the billable metric is not archived.
ArchivedAt time.Time `json:"archived_at" format:"date-time"`
CustomFields map[string]string `json:"custom_fields"`
// An optional filtering rule to match the 'event_type' property of an event.
EventTypeFilter shared.EventTypeFilter `json:"event_type_filter"`
// Property names that are used to group usage costs on an invoice. Each entry
Expand All @@ -232,6 +240,7 @@ type billableMetricListResponseJSON struct {
Name apijson.Field
AggregationKey apijson.Field
AggregationType apijson.Field
ArchivedAt apijson.Field
CustomFields apijson.Field
EventTypeFilter apijson.Field
GroupKeys apijson.Field
Expand Down Expand Up @@ -343,6 +352,8 @@ type BillableMetricGetParams struct {
}

type BillableMetricListParams struct {
// If true, the list of returned metrics will include archived metrics
IncludeArchived param.Field[bool] `query:"include_archived"`
// Max number of results that should be returned
Limit param.Field[int64] `query:"limit"`
// Cursor that indicates where the next page of results should start.
Expand Down
5 changes: 3 additions & 2 deletions billablemetric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,9 @@ func TestBillableMetricListWithOptionalParams(t *testing.T) {
option.WithBearerToken("My Bearer Token"),
)
_, err := client.BillableMetrics.List(context.TODO(), metronome.BillableMetricListParams{
Limit: metronome.F(int64(1)),
NextPage: metronome.F("next_page"),
IncludeArchived: metronome.F(true),
Limit: metronome.F(int64(1)),
NextPage: metronome.F("next_page"),
})
if err != nil {
var apierr *metronome.Error
Expand Down
86 changes: 43 additions & 43 deletions contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -713,72 +713,72 @@ func (r contractListBalancesResponseJSON) RawJSON() string {

type ContractListBalancesResponseData struct {
ID string `json:"id,required" format:"uuid"`
// This field can have the runtime type of [[]string].
ApplicableContractIDs interface{} `json:"applicable_contract_ids,required"`
// This field can have the runtime type of [[]string].
ApplicableProductIDs interface{} `json:"applicable_product_ids,required"`
// This field can have the runtime type of [[]string].
ApplicableProductTags interface{} `json:"applicable_product_tags,required"`
// This field can have the runtime type of [shared.CommitContract],
// [shared.CreditContract].
Contract interface{} `json:"contract,required"`
Type ContractListBalancesResponseDataType `json:"type,required"`
Name string `json:"name"`
// If multiple credits or commits are applicable, the one with the lower priority
// will apply first.
Priority float64 `json:"priority"`
// This field can have the runtime type of [shared.CommitProduct],
// [shared.CreditProduct].
Product interface{} `json:"product"`
Contract interface{} `json:"contract,required"`
// This field can have the runtime type of [map[string]string].
CustomFields interface{} `json:"custom_fields,required"`
// This field can have the runtime type of [shared.CommitInvoiceContract].
InvoiceContract interface{} `json:"invoice_contract,required"`
// This field can have the runtime type of [[]shared.CommitLedger],
// [[]shared.CreditLedger].
Ledger interface{} `json:"ledger,required"`
// This field can have the runtime type of [shared.CommitRolledOverFrom].
RolledOverFrom interface{} `json:"rolled_over_from,required"`
Type ContractListBalancesResponseDataType `json:"type,required"`
// The schedule that the customer will gain access to the credits purposed with
// this commit.
AccessSchedule shared.ScheduleDuration `json:"access_schedule"`
// (DEPRECATED) Use access_schedule + invoice_schedule instead.
Amount float64 `json:"amount"`
Description string `json:"description"`
// The schedule that the customer will be invoiced for this commit.
InvoiceSchedule shared.SchedulePointInTime `json:"invoice_schedule"`
// This field can have the runtime type of [shared.CommitInvoiceContract].
InvoiceContract interface{} `json:"invoice_contract,required"`
// This field can have the runtime type of [shared.CommitRolledOverFrom].
RolledOverFrom interface{} `json:"rolled_over_from,required"`
Description string `json:"description"`
RolloverFraction float64 `json:"rollover_fraction"`
// This field can have the runtime type of [[]string].
ApplicableProductIDs interface{} `json:"applicable_product_ids,required"`
// This field can have the runtime type of [[]string].
ApplicableProductTags interface{} `json:"applicable_product_tags,required"`
// This field can have the runtime type of [[]string].
ApplicableContractIDs interface{} `json:"applicable_contract_ids,required"`
Name string `json:"name"`
// This field's availability is dependent on your client's configuration.
NetsuiteSalesOrderID string `json:"netsuite_sales_order_id"`
// (DEPRECATED) Use access_schedule + invoice_schedule instead.
Amount float64 `json:"amount"`
// If multiple credits or commits are applicable, the one with the lower priority
// will apply first.
Priority float64 `json:"priority"`
// This field can have the runtime type of [shared.CommitProduct],
// [shared.CreditProduct].
Product interface{} `json:"product"`
RolloverFraction float64 `json:"rollover_fraction"`
// This field's availability is dependent on your client's configuration.
SalesforceOpportunityID string `json:"salesforce_opportunity_id"`
// This field can have the runtime type of [[]shared.CommitLedger],
// [[]shared.CreditLedger].
Ledger interface{} `json:"ledger,required"`
// This field can have the runtime type of [map[string]string].
CustomFields interface{} `json:"custom_fields,required"`
JSON contractListBalancesResponseDataJSON `json:"-"`
union ContractListBalancesResponseDataUnion
SalesforceOpportunityID string `json:"salesforce_opportunity_id"`
JSON contractListBalancesResponseDataJSON `json:"-"`
union ContractListBalancesResponseDataUnion
}

// contractListBalancesResponseDataJSON contains the JSON metadata for the struct
// [ContractListBalancesResponseData]
type contractListBalancesResponseDataJSON struct {
ID apijson.Field
ApplicableContractIDs apijson.Field
ApplicableProductIDs apijson.Field
ApplicableProductTags apijson.Field
Contract apijson.Field
CustomFields apijson.Field
InvoiceContract apijson.Field
Ledger apijson.Field
RolledOverFrom apijson.Field
Type apijson.Field
AccessSchedule apijson.Field
Amount apijson.Field
Description apijson.Field
InvoiceSchedule apijson.Field
Name apijson.Field
NetsuiteSalesOrderID apijson.Field
Priority apijson.Field
Product apijson.Field
AccessSchedule apijson.Field
InvoiceSchedule apijson.Field
InvoiceContract apijson.Field
RolledOverFrom apijson.Field
Description apijson.Field
RolloverFraction apijson.Field
ApplicableProductIDs apijson.Field
ApplicableProductTags apijson.Field
ApplicableContractIDs apijson.Field
NetsuiteSalesOrderID apijson.Field
Amount apijson.Field
SalesforceOpportunityID apijson.Field
Ledger apijson.Field
CustomFields apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
Expand Down
8 changes: 7 additions & 1 deletion customer.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,10 @@ type CustomerListBillableMetricsResponse struct {
AggregationKey string `json:"aggregation_key"`
// Specifies the type of aggregation performed on matching events.
AggregationType CustomerListBillableMetricsResponseAggregationType `json:"aggregation_type"`
CustomFields map[string]string `json:"custom_fields"`
// RFC 3339 timestamp indicating when the billable metric was archived. If not
// provided, the billable metric is not archived.
ArchivedAt time.Time `json:"archived_at" format:"date-time"`
CustomFields map[string]string `json:"custom_fields"`
// An optional filtering rule to match the 'event_type' property of an event.
EventTypeFilter shared.EventTypeFilter `json:"event_type_filter"`
// (DEPRECATED) use property_filters & event_type_filter instead
Expand Down Expand Up @@ -437,6 +440,7 @@ type customerListBillableMetricsResponseJSON struct {
AggregateKeys apijson.Field
AggregationKey apijson.Field
AggregationType apijson.Field
ArchivedAt apijson.Field
CustomFields apijson.Field
EventTypeFilter apijson.Field
Filter apijson.Field
Expand Down Expand Up @@ -713,6 +717,8 @@ func (r CustomerArchiveParams) MarshalJSON() (data []byte, err error) {

type CustomerListBillableMetricsParams struct {
CustomerID param.Field[string] `path:"customer_id,required" format:"uuid"`
// If true, the list of returned metrics will include archived metrics
IncludeArchived param.Field[bool] `query:"include_archived"`
// Max number of results that should be returned
Limit param.Field[int64] `query:"limit"`
// Cursor that indicates where the next page of results should start.
Expand Down
9 changes: 5 additions & 4 deletions customer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,11 @@ func TestCustomerListBillableMetricsWithOptionalParams(t *testing.T) {
option.WithBearerToken("My Bearer Token"),
)
_, err := client.Customers.ListBillableMetrics(context.TODO(), metronome.CustomerListBillableMetricsParams{
CustomerID: metronome.F("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc"),
Limit: metronome.F(int64(1)),
NextPage: metronome.F("next_page"),
OnCurrentPlan: metronome.F(true),
CustomerID: metronome.F("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc"),
IncludeArchived: metronome.F(true),
Limit: metronome.F(int64(1)),
NextPage: metronome.F("next_page"),
OnCurrentPlan: metronome.F(true),
})
if err != nil {
var apierr *metronome.Error
Expand Down
24 changes: 12 additions & 12 deletions shared/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,26 +196,26 @@ func (r commitInvoiceContractJSON) RawJSON() string {
}

type CommitLedger struct {
Type CommitLedgerType `json:"type,required"`
Timestamp time.Time `json:"timestamp,required" format:"date-time"`
Amount float64 `json:"amount,required"`
SegmentID string `json:"segment_id" format:"uuid"`
Timestamp time.Time `json:"timestamp,required" format:"date-time"`
Type CommitLedgerType `json:"type,required"`
InvoiceID string `json:"invoice_id" format:"uuid"`
NewContractID string `json:"new_contract_id" format:"uuid"`
Reason string `json:"reason"`
SegmentID string `json:"segment_id" format:"uuid"`
JSON commitLedgerJSON `json:"-"`
union CommitLedgerUnion
}

// commitLedgerJSON contains the JSON metadata for the struct [CommitLedger]
type commitLedgerJSON struct {
Type apijson.Field
Timestamp apijson.Field
Amount apijson.Field
SegmentID apijson.Field
Timestamp apijson.Field
Type apijson.Field
InvoiceID apijson.Field
NewContractID apijson.Field
Reason apijson.Field
SegmentID apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
Expand Down Expand Up @@ -1321,24 +1321,24 @@ func (r creditContractJSON) RawJSON() string {
}

type CreditLedger struct {
Type CreditLedgerType `json:"type,required"`
Timestamp time.Time `json:"timestamp,required" format:"date-time"`
Amount float64 `json:"amount,required"`
SegmentID string `json:"segment_id" format:"uuid"`
Timestamp time.Time `json:"timestamp,required" format:"date-time"`
Type CreditLedgerType `json:"type,required"`
InvoiceID string `json:"invoice_id" format:"uuid"`
Reason string `json:"reason"`
SegmentID string `json:"segment_id" format:"uuid"`
JSON creditLedgerJSON `json:"-"`
union CreditLedgerUnion
}

// creditLedgerJSON contains the JSON metadata for the struct [CreditLedger]
type creditLedgerJSON struct {
Type apijson.Field
Timestamp apijson.Field
Amount apijson.Field
SegmentID apijson.Field
Timestamp apijson.Field
Type apijson.Field
InvoiceID apijson.Field
Reason apijson.Field
SegmentID apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
Expand Down

0 comments on commit 4f67b04

Please sign in to comment.