apitypes

package
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 13, 2023 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const Inf = 1<<63 - 1

Variables

This section is empty.

Functions

func UsageByFeature added in v0.3.8

func UsageByFeature(a, b Usage) bool

Types

type CheckoutRequest added in v0.7.1

type CheckoutRequest struct {
	Org                   string   `json:"org"`
	TrialDays             int      `json:"trial_days"`
	Features              []string `json:"features"`
	SuccessURL            string   `json:"success_url"`
	CancelURL             string   `json:"cancel_url"`
	RequireBillingAddress bool     `json:"require_billing_address"`
	Tax                   Taxation `json:"tax"`
}

type CheckoutResponse added in v0.7.1

type CheckoutResponse struct {
	URL string `json:"url"`
}

type ClockRequest added in v0.10.0

type ClockRequest struct {
	ID      string
	Name    string
	Present time.Time
}

type ClockResponse added in v0.10.0

type ClockResponse struct {
	ID      string    `json:"id"`
	Link    string    `json:"link"`
	Present time.Time `json:"present"`
	Status  string    `json:"status"`
}

type Coupon added in v0.12.0

type Coupon struct {
	ID               string `json:"id"`
	Metadata         map[string]string
	Created          time.Time
	AmountOff        int     `json:"amount_off,omitempty"`
	Currency         string  `json:"currency,omitempty"`
	Duration         string  `json:"duration,omitempty"`
	DurationInMonths int     `json:"duration_in_months,omitempty"`
	MaxRedemptions   int     `json:"max_redemptions,omitempty"`
	Name             string  `json:"name,omitempty"`
	PercentOff       float64 `json:"percent_off,omitempty"`
	RedeemBy         time.Time
	TimesRedeemed    int  `json:"times_redeemed,omitempty"`
	Valid            bool `json:"valid,omitempty"`
}

type Divide added in v0.10.0

type Divide struct {
	By       int    `json:"by,omitempty"`
	Rounding string `json:"rounding,omitempty"`
}

type Error added in v0.5.0

type Error struct {
	Status  int    `json:"status"`
	Code    string `json:"code"` // (e.g. "invalid_request")
	Message string `json:"message"`
}

func (*Error) Error added in v0.5.0

func (e *Error) Error() string

type Feature added in v0.4.2

type Feature struct {
	Title     string  `json:"title,omitempty"`
	Base      float64 `json:"base,omitempty"`
	Mode      string  `json:"mode,omitempty"`
	Aggregate string  `json:"aggregate,omitempty"`
	Tiers     []Tier  `json:"tiers,omitempty"`
	Divide    *Divide `json:"divide,omitempty"`
}

type InvoiceSettings added in v0.7.1

type InvoiceSettings struct {
	DefaultPaymentMethod string `json:"default_payment_method"`
}

type Model added in v0.4.2

type Model struct {
	Plans map[refs.Plan]Plan `json:"plans"`
}

type OrgInfo added in v0.6.0

type OrgInfo struct {
	Email       string            `json:"email"`
	Name        string            `json:"name"`
	Description string            `json:"description"`
	Phone       string            `json:"phone"`
	Created     time.Time         `json:"created"`
	Metadata    map[string]string `json:"metadata"`

	PaymentMethod   string          `json:"payment_method"`
	InvoiceSettings InvoiceSettings `json:"invoice_settings"`
}

type PaymentMethodsResponse added in v0.9.0

type PaymentMethodsResponse struct {
	Org            string           `json:"org"`
	PaymentMethods []payment.Method `json:"methods"`
}

type Period added in v0.10.0

type Period struct {
	Effective time.Time `json:"effective,omitempty"`
	End       time.Time `json:"end,omitempty"`
}

func (*Period) IsZero added in v0.10.0

func (p *Period) IsZero() bool

type Phase

type Phase struct {
	Trial      bool      `json:"trial,omitempty"`
	Effective  time.Time `json:"effective,omitempty"`
	Features   []string  `json:"features,omitempty"`
	Coupon     string    `json:"coupon,omitempty"`
	CouponData *Coupon   `json:"coupon_data,omitempty"`
}

type PhaseResponse added in v0.3.8

type PhaseResponse struct {
	Effective  time.Time          `json:"effective,omitempty"`
	End        time.Time          `json:"end,omitempty"`
	Features   []refs.FeaturePlan `json:"features,omitempty"`
	Plans      []refs.Plan        `json:"plans,omitempty"`
	Fragments  []refs.FeaturePlan `json:"fragments,omitempty"`
	Trial      bool               `json:"trial,omitempty"`
	Tax        Taxation           `json:"tax,omitempty"`
	Current    Period             `json:"current,omitempty"` // not set on PhasesResponse
	Coupon     string             `json:"coupon,omitempty"`
	CouponData *Coupon            `json:"coupon_data,omitempty"`
}

The PhaseResponse is a response with all current phase fields exposed as top-level fields. Clients that need all phase data should use the Phases field.

func (PhaseResponse) MarshalJSON added in v0.10.0

func (pr PhaseResponse) MarshalJSON() ([]byte, error)

type PhasesResponse

type PhasesResponse struct {
	Current Period          `json:"current,omitempty"`
	Phases  []PhaseResponse `json:"phases"`
}

type Plan added in v0.4.2

type Plan struct {
	Title    string                `json:"title,omitempty"`
	Interval string                `json:"interval,omitempty"`
	Currency string                `json:"currency,omitempty"`
	Features map[refs.Name]Feature `json:"features,omitempty"`
}

type PushResponse added in v0.4.2

type PushResponse struct {
	Results []PushResult `json:"results,omitempty"`
}

type PushResult added in v0.4.2

type PushResult struct {
	Feature refs.FeaturePlan `json:"feature"`
	Status  string           `json:"status"`
	Reason  string           `json:"reason"`
}

type ReportRequest

type ReportRequest struct {
	Org     string    `json:"org"`
	Feature refs.Name `json:"feature"`
	N       int       `json:"n"`
	At      time.Time `json:"at"`
	Clobber bool      `json:"clobber"`
}

type ScheduleRequest added in v0.6.0

type ScheduleRequest struct {
	Org             string   `json:"org"`
	PaymentMethodID string   `json:"payment_method_id"`
	Info            *OrgInfo `json:"info"`
	Phases          []Phase  `json:"phases"`
	Tax             Taxation `json:"tax"`
}

type ScheduleResponse added in v0.7.1

type ScheduleResponse struct{}

ScheduleResponse is the expected response from a schedule request. It is currently empty, reserved for furture use.

type Taxation added in v0.10.0

type Taxation struct {
	Automatic bool `json:"automatic,omitempty"`
	CollectID bool `json:"collect_id,omitempty"` // specifics is taxID is collected
}

type Tier added in v0.4.2

type Tier struct {
	Upto  int     `json:"upto,omitempty"`
	Price float64 `json:"price,omitempty"`
	Base  int     `json:"base,omitempty"`
}

func (*Tier) MarshalJSON added in v0.4.2

func (t *Tier) MarshalJSON() ([]byte, error)

func (*Tier) UnmarshalJSON added in v0.4.2

func (t *Tier) UnmarshalJSON(data []byte) error

type Usage

type Usage struct {
	Feature refs.Name `json:"feature"`
	Used    int       `json:"used"`
	Limit   int       `json:"limit"`
}

type UsageResponse

type UsageResponse struct {
	Org   string  `json:"org"`
	Usage []Usage `json:"usage"`
}

type WhoAmIResponse added in v0.5.0

type WhoAmIResponse struct {
	ProviderID string    `json:"id"`
	Email      string    `json:"email"`
	Created    time.Time `json:"created"`
	KeySource  string    `json:"key_source"`
	Isolated   bool      `json:"isolated"`
	URL        string    `json:"url"`
}

type WhoIsResponse

type WhoIsResponse struct {
	*OrgInfo
	Org      string `json:"org"`
	StripeID string `json:"stripe_id"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL