Skip to content
This repository was archived by the owner on Jan 2, 2024. It is now read-only.
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
8 changes: 5 additions & 3 deletions api/materialize/views.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,11 @@ func ToPricingJSON(fs []control.Feature) ([]byte, error) {
}

p.Features[f.FeaturePlan.Name()] = apitypes.Feature{
Title: values.ZeroIf(f.Title, f.FeaturePlan.String()),
Base: f.Base,
Tiers: tiers,
Title: values.ZeroIf(f.Title, f.FeaturePlan.String()),
Base: f.Base,
Mode: values.ZeroIf(f.Mode, "graduated"),
Aggregate: values.ZeroIf(f.Aggregate, "sum"),
Tiers: tiers,
}
m.Plans[f.Plan()] = p
}
Expand Down
17 changes: 10 additions & 7 deletions api/materialize/views_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ func TestPricingHuJSON(t *testing.T) {
"plan:example@1": {
"title": "Just an example plan to show off features",
"features": {
"feature:graduated": {
"mode": "graduated",
"feature:volume": {
"mode": "volume",
"aggregate": "perpetual",
"tiers": [
{ "upto": 10 },
{ "upto": 20, "price": 100 },
Expand Down Expand Up @@ -61,12 +62,12 @@ func TestPricingHuJSON(t *testing.T) {
},
{
PlanTitle: "Just an example plan to show off features",
Title: "feature:graduated@plan:example@1",
FeaturePlan: refs.MustParseFeaturePlan("feature:graduated@plan:example@1"),
Title: "feature:volume@plan:example@1",
FeaturePlan: refs.MustParseFeaturePlan("feature:volume@plan:example@1"),
Currency: "usd",
Interval: "@monthly",
Mode: "graduated",
Aggregate: "sum",
Mode: "volume",
Aggregate: "perpetual",
Tiers: []control.Tier{
{Upto: 10, Price: 0, Base: 0},
{Upto: 20, Price: 100, Base: 0},
Expand All @@ -87,7 +88,9 @@ func TestPricingHuJSON(t *testing.T) {
"plan:example@1": {
"title": "Just an example plan to show off features",
"features": {
"feature:graduated": {
"feature:volume": {
"mode": "volume",
"aggregate": "perpetual",
"tiers": [
{ "upto": 10 },
{ "upto": 20, "price": 100 },
Expand Down