models

package
v0.0.0-...-aa999d4 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2017 License: MIT Imports: 3 Imported by: 2

Documentation

Index

Constants

View Source
const (
	INVALID   = "INVALID"
	WEEKLY    = "WEEKLY"
	BIWEEKLY  = "BIWEEKLY"
	TRIWEEKLY = "TRIWEEKLY"
	MONTHLY   = "MONTHLY"
)

Allowed Frequencies

Variables

Frequencies are the string representations of Frequency

Functions

func ToFrequency

func ToFrequency(s Frequency) (int, bool)

ToFrequency returns the index of the frequency

string in the plan slices

Types

type Customer

type Customer struct {
	UserID     uuid.UUID `json:"userId"`
	CustomerID string    `json:"stripeCustomerId"`
}

Customer is the stripe customer data connected to a userID

func CustomersFromSQL

func CustomersFromSQL(rows *sql.Rows) ([]*Customer, error)

CustomersFromSQL returns a customer model slice from sql rows

func NewCustomer

func NewCustomer(userID uuid.UUID, id string) *Customer

NewCustomer initializes and returns the id fields of a customer

type CustomerRequest

type CustomerRequest struct {
	UserID uuid.UUID `json:"userId" binding:"required"`
	Token  string    `json:"token" binding:"required"`
}

CustomerRequest is the information needed to create/update a stripe customer

type Frequency

type Frequency string

Frequency is an enum type wrapping string representations

of the frequency of subscriptions

type Plan

type Plan struct {
	RoasterID uuid.UUID `json:"roasterId"`
	ItemID    uuid.UUID `json:"itemId"`
	PlanIDs   []string  `json:"planIds"`
}

Plan stores stripe information for a roaster's items

func NewPlan

func NewPlan(roasterID, itemID uuid.UUID, planIDs []string) *Plan

NewPlan creates and initializes the ID fields

func PlanFromSQL

func PlanFromSQL(rows *sql.Rows) ([]*Plan, error)

PlanFromSQL maps sql rows to plan models, where

order matters

type PlanRequest

type PlanRequest struct {
	ItemID uuid.UUID `json:"itemId"`
}

PlanRequest contains the information for creating a

plan in stripe for a roaster

type Roaster

type Roaster struct {
	//ID is the roaster ID in towncenter
	ID          uuid.UUID `json:"id"`
	AccountID   string    `json:"stripeAccountId"`
	Secret      string    `json:"secret"`
	Publishable string    `json:"publishable"`
}

Roaster has information retrieved from stripe and the db

about billing for roaster entities

func NewRoaster

func NewRoaster(id uuid.UUID, accountID string) *Roaster

NewRoaster initialized and returns a roaster model

func RoasterFromSQL

func RoasterFromSQL(rows *sql.Rows) ([]*Roaster, error)

RoasterFromSQL maps an sql row to roaster properties,

where order matters

type RoasterRequest

type RoasterRequest struct {
	UserID uuid.UUID `json:"userId" binding:"required"`
}

RoasterRequest has information used in creating a roaster

managed account in stripe

type SubscribeRequest

type SubscribeRequest struct {
	RoasterID uuid.UUID `json:"roasterId" binding:"required"`
	ItemID    uuid.UUID `json:"itemId" binding:"required"`
	Frequency Frequency `json:"frequency" binding:"required"`
	Quantity  uint64    `json:"quantity" binding:"required"`
}

SubscribeRequest is the information needed to subscribe a customer

to a roaster plan

func NewSubscribeRequest

func NewSubscribeRequest(roasterID uuid.UUID, itemID uuid.UUID, frequency Frequency, quantity uint64) *SubscribeRequest

NewSubscribeRequest creates a new SubscribeRequest

type Subscribed

type Subscribed struct {
	CustomerID  string    `json:"stripeCustomerId"`
	ConnectedID string    `json:"connectedId"`
	RoasterID   uuid.UUID `json:"roasterId"`
	StripeSubID string    `json:"stripeSubId"`
}

func NewSubscribed

func NewSubscribed(customerID, connectedID, stripeSubID string, roasterID uuid.UUID) *Subscribed

func SubscribedFromSQL

func SubscribedFromSQL(rows *sql.Rows) []*Subscribed

Jump to

Keyboard shortcuts

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