models

package
v0.0.0-...-8341997 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2017 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

View Source
const (
	EMAIL = "EMAIL"
	NOOP  = "NOOP"
)

valid ContentTypes

View Source
const (
	ACTIVE   = "ACTIVE"
	INACTIVE = "INACTIVE"
)

valid ContentStatuses

View Source
const (
	SUBSCRIBED   = "SUBSCRIBED"
	UNSUBSCRIBED = "UNSUBSCRIBED"
	MINIMAL      = "MINIMAL"
)

valid preference states

View Source
const (
	READY   = "READY"
	QUEUED  = "QUEUED"
	SUCCESS = "SUCCESS"
	FAILURE = "FAILURE"
)

valid Statuses

Variables

This section is empty.

Functions

func SerializeValues

func SerializeValues(values map[string]string) string

SerializeValues returns a string representation of the given map like in JSON

func ToList

func ToList(s string) []string

Types

type Content

type Content struct {
	ID      uuid.UUID     `json:"id"`
	Type    ContentType   `json:"contentType" binding:"required"`
	Text    string        `json:"text" binding:"required"`
	Params  []string      `json:"parameters" `
	Status  ContentStatus `json:"status"`
	Subject string        `json:"subject" binding:"required"`
}

Content is the representation of content entries in bloodlines

func ContentFromSQL

func ContentFromSQL(rows *sql.Rows) ([]*Content, error)

ContentFromSQL returns a new content slice from a group of sql rows

func NewContent

func NewContent(contentType ContentType, text string, subject string, params []string) *Content

NewContent constructs and returns a new content entity with a new uuid

func (*Content) ResolveText

func (c *Content) ResolveText(values map[string]string) (string, error)

ResolveText adds the given values to their corresponding position in this content's

Text string

type ContentStatus

type ContentStatus string

ContentStatus is an enum wrapper for valid ContentStatus strings

type ContentType

type ContentType string

ContentType is an enum wrapper for valid content type

type Job

type Job struct {
	ID         uuid.UUID   `json:"id"`
	SendTime   time.Time   `json:"sendTime"`
	SendStatus Status      `json:"sendStatus"`
	Receipts   []uuid.UUID `json:"receipts"`
}

Job entity data

func JobFromSQL

func JobFromSQL(rows *sql.Rows) ([]*Job, error)

JobFromSQL returns a Job splice from sql rows

func NewJob

func NewJob(receipts []uuid.UUID, sendTime time.Time) *Job

NewJob constructs and returns a new Job with a new uuid

type Preference

type Preference struct {
	ID     uuid.UUID       `json:"id"`
	UserID uuid.UUID       `json:"userId" binding:"required"`
	Email  PreferenceState `json:"email"`
}

Preference entity data

func NewPreference

func NewPreference(userID uuid.UUID) *Preference

NewPreference contstructs and returns a new preference entity with it's id

func PreferencesFromSQL

func PreferencesFromSQL(rows *sql.Rows) ([]*Preference, error)

PreferencesFromSQL returns a preference splice from sql rows

type PreferenceState

type PreferenceState string

PreferenceState wraps valid preference state strings

type Receipt

type Receipt struct {
	ID        uuid.UUID         `json:"id"`
	Created   time.Time         `json:"ts"`
	Finished  time.Time         `json:"finished"`
	Values    map[string]string `json:"values"`
	SendState Status            `json:"sendState"`
	ContentID uuid.UUID         `json:"contentId"`
	UserID    uuid.UUID         `json:"userId" binding:"required"`
}

Receipt stores data for receipts

func NewReceipt

func NewReceipt(values map[string]string, contentID uuid.UUID, userID uuid.UUID) *Receipt

NewReceipt creates and returns a new receipt with a new id

func ReceiptFromSQL

func ReceiptFromSQL(rows *sql.Rows) ([]*Receipt, error)

ReceiptFromSQL returns a receipt splice from sql rows

type SendRequest

type SendRequest struct {
	ReceiptID uuid.UUID `json:"receiptId"`
	ContentID uuid.UUID `json:"contentId"`
}

SendRequest has the info for sending a message through the sendgrid api

type Status

type Status string

Status wraps valid receipt status strings

type Trigger

type Trigger struct {
	ID        uuid.UUID         `json:"id"`
	ContentID uuid.UUID         `json:"contentId" binding:"required"`
	Key       string            `json:"tkey" binding:"required"`
	Values    map[string]string `json:"values"`
}

Trigger stores trigger entity data

func NewTrigger

func NewTrigger(contentID uuid.UUID, key string, values map[string]string) *Trigger

NewTrigger creates and returns a new trigger entity with id

func TriggerFromSQL

func TriggerFromSQL(rows *sql.Rows) ([]*Trigger, error)

TriggerFromSQL returns a trigger splice from sql rows

Jump to

Keyboard shortcuts

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