Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(minimum-commitment): Add minimum commitment #164

Merged
merged 1 commit into from
Mar 19, 2024
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
71 changes: 46 additions & 25 deletions plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"time"

"github.com/google/uuid"
)
Expand Down Expand Up @@ -46,40 +47,60 @@ type PlanChargeInput struct {
TaxCodes []string `json:"tax_codes,omitempty"`
}

type MinimumCommitmentInput struct {
AmountCents int `json:"amount_cents,omitempty"`
InvoiceDisplayName string `json:"invoice_display_name,omitempty"`
TaxCodes []string `json:"tax_codes,omitempty"`
}

type PlanInput struct {
Name string `json:"name,omitempty"`
InvoiceDisplayName string `json:"invoice_display_name,omitempty"`
Code string `json:"code,omitempty"`
Interval PlanInterval `json:"interval,omitempty"`
Description string `json:"description,omitempty"`
AmountCents int `json:"amount_cents"`
AmountCurrency Currency `json:"amount_currency,omitempty"`
PayInAdvance bool `json:"pay_in_advance"`
BillChargeMonthly bool `json:"bill_charge_monthly"`
TrialPeriod float32 `json:"trial_period"`
Charges []PlanChargeInput `json:"charges,omitempty"`
TaxCodes []string `json:"tax_codes,omitempty"`
Name string `json:"name,omitempty"`
InvoiceDisplayName string `json:"invoice_display_name,omitempty"`
Code string `json:"code,omitempty"`
Interval PlanInterval `json:"interval,omitempty"`
Description string `json:"description,omitempty"`
AmountCents int `json:"amount_cents"`
AmountCurrency Currency `json:"amount_currency,omitempty"`
PayInAdvance bool `json:"pay_in_advance"`
BillChargeMonthly bool `json:"bill_charge_monthly"`
TrialPeriod float32 `json:"trial_period"`
Charges []PlanChargeInput `json:"charges,omitempty"`
MinimumCommitment *MinimumCommitmentInput `json:"minimum_commitment,omitempty"`
TaxCodes []string `json:"tax_codes,omitempty"`
}

type PlanListInput struct {
PerPage int `json:"per_page,omitempty,string"`
Page int `json:"page,omitempty,string"`
}

type MinimumCommitment struct {
LagoID uuid.UUID `json:"lago_id"`
PlanCode string `json:"plan_code,omitempty"`
InvoiceDisplayName string `json:"invoice_display_name,omitempty"`
AmountCents int `json:"amount_cents"`
Interval PlanInterval `json:"interval,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
UpdatedAt time.Time `json:"updated_at,omitempty"`

Taxes []Tax `json:"tax,omitempty"`
}

type Plan struct {
LagoID uuid.UUID `json:"lago_id"`
Name string `json:"name,omitempty"`
InvoiceDisplayName string `json:"invoice_display_name,omitempty"`
Code string `json:"code,omitempty"`
Interval PlanInterval `json:"interval,omitempty"`
Description string `json:"description,omitempty"`
AmountCents int `json:"amount_cents,omitempty"`
AmountCurrency Currency `json:"amount_currency,omitempty"`
PayInAdvance bool `json:"pay_in_advance,omitempty"`
BillChargeMonthly bool `json:"bill_charge_monthly,omitempty"`
ActiveSubscriptionsCount int `json:"active_subscriptions_count,omitempty"`
DraftInvoicesCount int `json:"draft_invoices_count,omitempty"`
Charges []Charge `json:"charges,omitempty"`
LagoID uuid.UUID `json:"lago_id"`
Name string `json:"name,omitempty"`
InvoiceDisplayName string `json:"invoice_display_name,omitempty"`
Code string `json:"code,omitempty"`
Interval PlanInterval `json:"interval,omitempty"`
Description string `json:"description,omitempty"`
AmountCents int `json:"amount_cents,omitempty"`
AmountCurrency Currency `json:"amount_currency,omitempty"`
PayInAdvance bool `json:"pay_in_advance,omitempty"`
BillChargeMonthly bool `json:"bill_charge_monthly,omitempty"`
ActiveSubscriptionsCount int `json:"active_subscriptions_count,omitempty"`
DraftInvoicesCount int `json:"draft_invoices_count,omitempty"`
Charges []Charge `json:"charges,omitempty"`
MinimumCommitment *MinimumCommitment `json:"minimum_commitment"`

Taxes []Tax `json:"taxes,omitempty"`
}
Expand Down
25 changes: 16 additions & 9 deletions subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,23 @@ type ChargeOverridesInput struct {
TaxCodes []string `json:"tax_codes,omitempty"`
}

type MinimumCommitmentOverridesInput struct {
AmountCents int `json:"amount_cents,omitempty"`
InvoiceDisplayName string `json:"invoice_display_name,omitempty"`
TaxCodes []string `json:"tax_codes,omitempty"`
}

type PlanOverridesInput struct {
Name string `json:"name,omitempty"`
InvoiceDisplayName string `json:"invoice_display_name,omitempty"`
Code string `json:"code,omitempty"`
Description string `json:"description,omitempty"`
AmountCents int `json:"amount_cents"`
AmountCurrency Currency `json:"amount_currency,omitempty"`
TrialPeriod float32 `json:"trial_period"`
Charges []ChargeOverridesInput `json:"charges,omitempty"`
TaxCodes []string `json:"tax_codes,omitempty"`
Name string `json:"name,omitempty"`
InvoiceDisplayName string `json:"invoice_display_name,omitempty"`
Code string `json:"code,omitempty"`
Description string `json:"description,omitempty"`
AmountCents int `json:"amount_cents"`
AmountCurrency Currency `json:"amount_currency,omitempty"`
TrialPeriod float32 `json:"trial_period"`
Charges []ChargeOverridesInput `json:"charges,omitempty"`
MinimumCommitment *MinimumCommitmentOverridesInput `json:"minimum_commitment"`
TaxCodes []string `json:"tax_codes,omitempty"`
}

type SubscriptionInput struct {
Expand Down
Loading