Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions github/billing.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,11 @@ type PremiumRequestUsageItem struct {
Model string `json:"model"`
UnitType string `json:"unitType"`
PricePerUnit float64 `json:"pricePerUnit"`
GrossQuantity int `json:"grossQuantity"`
GrossQuantity float64 `json:"grossQuantity"`
GrossAmount float64 `json:"grossAmount"`
DiscountQuantity int `json:"discountQuantity"`
DiscountQuantity float64 `json:"discountQuantity"`
DiscountAmount float64 `json:"discountAmount"`
NetQuantity int `json:"netQuantity"`
NetQuantity float64 `json:"netQuantity"`
NetAmount float64 `json:"netAmount"`
}

Expand Down
72 changes: 66 additions & 6 deletions github/billing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,11 +588,11 @@ func TestBillingService_GetOrganizationPremiumRequestUsageReport(t *testing.T) {
Model: "GPT-5",
UnitType: "requests",
PricePerUnit: 0.04,
GrossQuantity: 100,
GrossQuantity: 100.0,
GrossAmount: 4.0,
DiscountQuantity: 0,
DiscountQuantity: 0.0,
DiscountAmount: 0.0,
NetQuantity: 100,
NetQuantity: 100.0,
NetAmount: 4.0,
},
},
Expand Down Expand Up @@ -681,11 +681,11 @@ func TestBillingService_GetPremiumRequestUsageReport(t *testing.T) {
Model: "GPT-4",
UnitType: "requests",
PricePerUnit: 0.02,
GrossQuantity: 50,
GrossQuantity: 50.0,
GrossAmount: 1.0,
DiscountQuantity: 5,
DiscountQuantity: 5.0,
DiscountAmount: 0.1,
NetQuantity: 45,
NetQuantity: 45.0,
NetAmount: 0.9,
},
},
Expand Down Expand Up @@ -717,3 +717,63 @@ func TestBillingService_GetPremiumRequestUsageReport_invalidUser(t *testing.T) {
_, _, err := client.Billing.GetPremiumRequestUsageReport(ctx, "%", nil)
testURLParseError(t, err)
}

func TestBillingService_PremiumRequestUsageItem_FloatQuantities(t *testing.T) {
t.Parallel()
client, mux, _ := setup(t)
mux.HandleFunc("/organizations/o/settings/billing/premium_request/usage", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
fmt.Fprint(w, `{
"timePeriod": {
"year": 2026,
"month": 2
},
"organization": "testorg",
"usageItems": [
{
"product": "Copilot",
"sku": "Copilot Premium Request",
"model": "GPT-5.2",
"unitType": "requests",
"pricePerUnit": 0.04,
"grossQuantity": 5054.0,
"grossAmount": 202.16,
"discountQuantity": 4974.0,
"discountAmount": 198.96,
"netQuantity": 80.0,
"netAmount": 3.2
}
]
}`)
})
ctx := t.Context()
report, _, err := client.Billing.GetOrganizationPremiumRequestUsageReport(ctx, "o", nil)
if err != nil {
t.Fatalf("Billing.GetOrganizationPremiumRequestUsageReport returned error: %v", err)
}
want := &PremiumRequestUsageReport{
TimePeriod: PremiumRequestUsageTimePeriod{
Year: 2026,
Month: Ptr(2),
},
Organization: Ptr("testorg"),
UsageItems: []*PremiumRequestUsageItem{
{
Product: "Copilot",
SKU: "Copilot Premium Request",
Model: "GPT-5.2",
UnitType: "requests",
PricePerUnit: 0.04,
GrossQuantity: 5054.0,
GrossAmount: 202.16,
DiscountQuantity: 4974.0,
DiscountAmount: 198.96,
NetQuantity: 80.0,
NetAmount: 3.2,
},
},
}
if !cmp.Equal(report, want) {
t.Errorf("Billing.GetOrganizationPremiumRequestUsageReport returned %+v, want %+v", report, want)
}
}
Loading