account

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Forever   CouponDuration = "forever"
	Once                     = "once"
	Repeating                = "repeating"
)

Durations.

Variables

This section is empty.

Functions

func PromptForCard

func PromptForCard() (card stripe.CardParams, err error)

PromptForCard displays an interactive form for the user to provide CC details.

Types

type Card

type Card struct {
	ID       string `json:"id"`
	Brand    string `json:"brand"`
	LastFour string `json:"last_four"`
}

Card model.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client implementation.

func New

func New(url string) *Client

New client.

func (*Client) AddCard

func (c *Client) AddCard(token, cardToken string) error

AddCard adds or updates the default card via stripe token.

func (*Client) AddFeedback

func (c *Client) AddFeedback(token, message string) error

AddFeedback sends customer feedback.

func (*Client) AddInvite

func (c *Client) AddInvite(token, email string) error

AddInvite adds a team invitation.

func (*Client) AddPlan

func (c *Client) AddPlan(token, product, interval, coupon string) error

AddPlan subscribes to plan.

func (*Client) AddTeam

func (c *Client) AddTeam(token, id, name string) error

AddTeam adds a new team.

func (*Client) GetAccessToken

func (c *Client) GetAccessToken(email, team, code string) (key string, err error)

GetAccessToken with the given email, team, and code.

func (*Client) GetCards

func (c *Client) GetCards(token string) (cards []Card, err error)

GetCards returns the user's cards.

func (*Client) GetCoupon

func (c *Client) GetCoupon(id string) (coupon *Coupon, err error)

GetCoupon by id.

func (*Client) GetPlans

func (c *Client) GetPlans(token string) (plans []Plan, err error)

GetPlans returns the user's plan(s).

func (*Client) GetTeam

func (c *Client) GetTeam(token string) (*Team, error)

GetTeam returns the active team.

func (*Client) Login

func (c *Client) Login(email, team string) (code string, err error)

Login signs in the user.

func (*Client) LoginWithToken

func (c *Client) LoginWithToken(token, email, team string) (code string, err error)

LoginWithToken signs in with the given email by sending a verification email and returning a code which can be exchanged for an access key.

When an auth token is provided the user is already authenticated, so this can be used to switch to another team, if the user is a member or owner.

The team id is optional, and may only be used when the user's email has been invited to the team.

func (*Client) PollAccessToken

func (c *Client) PollAccessToken(ctx context.Context, email, team, code string) (key string, err error)

PollAccessToken polls for an access token.

func (*Client) RemoveCard

func (c *Client) RemoveCard(token, id string) error

RemoveCard removes a user's card by id.

func (*Client) RemoveMember

func (c *Client) RemoveMember(token, email string) error

RemoveMember removes a team member or invitation if present.

func (*Client) RemovePlan

func (c *Client) RemovePlan(token, product string) error

RemovePlan unsubscribes from a plan.

type Coupon

type Coupon struct {
	ID             string         `json:"id"`
	Amount         int            `json:"amount"`
	Percent        int            `json:"percent"`
	Duration       CouponDuration `json:"duration"`
	DurationPeriod int            `json:"duration_period"`
}

Coupon model.

func (*Coupon) Description

func (c *Coupon) Description() (s string)

Description returns a humanized description of the savings.

func (*Coupon) Discount

func (c *Coupon) Discount(n int) int

Discount returns the final price from the given amount.

type CouponDuration

type CouponDuration string

CouponDuration is the coupon duration.

type Discount

type Discount struct {
	Coupon Coupon `json:"coupon"`
}

Discount model.

type Error

type Error struct {
	Message string
	Status  int
}

Error is a client error.

func (*Error) Error

func (e *Error) Error() string

Error implementation.

type Plan

type Plan struct {
	ID         string    `json:"id"`
	Name       string    `json:"name"`
	Product    string    `json:"product"`
	Plan       string    `json:"plan"`
	Amount     int       `json:"amount"`
	Interval   string    `json:"interval"`
	Status     string    `json:"status"`
	Canceled   bool      `json:"canceled"`
	Discount   *Discount `json:"discount"`
	CreatedAt  time.Time `json:"created_at"`
	CanceledAt time.Time `json:"canceled_at"`
}

Plan model.

type Team

type Team struct {
	ID        string    `json:"id"`
	Name      string    `json:"name"`
	Owner     string    `json:"owner"`
	Type      string    `json:"type"`
	Card      *Card     `json:"card"`
	Members   []User    `json:"members"`
	Invites   []string  `json:"invites"`
	UpdatedAt time.Time `json:"updated_at"`
	CreatedAt time.Time `json:"created_at"`
}

Team model.

type User

type User struct {
	Email     string    `json:"email"`
	CreatedAt time.Time `json:"created_at"`
}

User model.

Jump to

Keyboard shortcuts

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