service

package
v0.0.0-...-ace6a59 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const CampaignBucket = "campaigns"

Variables

View Source
var ErrNotFound = errors.New("not found error")

Functions

func Dump

func Dump(i interface{}) (s string)

Types

type Audit

type Audit struct {
	CreatedAt time.Time      `gorm:"type:datetime"`
	UpdatedAt time.Time      `gorm:"type:datetime"`
	DeletedAt gorm.DeletedAt `gorm:"index;type:datetime"`
}

type BlastEmailConfig

type BlastEmailConfig struct {
	Sender      string
	Concurrency uint
	Transporter mailmerger.Transporter
}

type Campaign

type Campaign struct {
	ID         ulids.ULID `gorm:"primary_key"`
	FileID     *ulids.ULID
	Name       string
	Body       string
	Subject    string
	TemplateID *ulids.ULID
	Audit

	File     File
	Events   []Event
	Template *Template `gorm:"->;foreignKey:TemplateID"`
}

func (*Campaign) BeforeCreate

func (c *Campaign) BeforeCreate(tx *gorm.DB) error

func (*Campaign) BeforeUpdate

func (c *Campaign) BeforeUpdate(tx *gorm.DB) error

func (Campaign) HasNoTemplate

func (c Campaign) HasNoTemplate() bool

func (Campaign) IsNoEvent

func (c Campaign) IsNoEvent() bool

func (Campaign) RenderTemplate

func (c Campaign) RenderTemplate() (io.Reader, error)

type CampaignRenderer

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

func NewCampaignRenderer

func NewCampaignRenderer(body string, template *Template) CampaignRenderer

func (CampaignRenderer) Render

func (c CampaignRenderer) Render() (io.Reader, error)

type CampaignService

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

func (*CampaignService) Create

func (c *CampaignService) Create(ctx context.Context, req CreateCampaignRequest) (campaign Campaign, err error)

func (*CampaignService) CreateBlastEmailEvent

func (c *CampaignService) CreateBlastEmailEvent(ctx context.Context, req CreateBlastEmailEventRequest) (event Event, err error)

CreateBlastEmailEvent create an event

func (*CampaignService) Delete

func (c *CampaignService) Delete(ctx context.Context, id ulids.ULID) (campaign Campaign, err error)

func (*CampaignService) Find

func (c *CampaignService) Find(ctx context.Context, id ulids.ULID) (campaign Campaign, err error)

func (*CampaignService) List

func (c *CampaignService) List(ctx context.Context) (campaigns []Campaign, err error)

func (*CampaignService) RenderByBodyAndTemplate

func (c *CampaignService) RenderByBodyAndTemplate(ctx context.Context, templateID ulids.ULID, body string) (result []byte, err error)

func (*CampaignService) RenderBytes

func (c *CampaignService) RenderBytes(campaign Campaign) ([]byte, error)

func (*CampaignService) Update

func (c *CampaignService) Update(ctx context.Context, req UpdateCampaignRequest) (_ Campaign, err error)

type Config

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

type CreateBlastEmailEventRequest

type CreateBlastEmailEventRequest struct {
	CampaignID ulids.ULID `form:"campaign_id"`
}

type CreateCampaignRequest

type CreateCampaignRequest struct {
	Name            string      `form:"name"`
	BodyTemplate    string      `form:"body"`
	SubjectTemplate string      `form:"subject"`
	CSV             io.Reader   `form:"-"`
	TemplateID      *ulids.ULID `form:"-"`
}

type CreateTemplateRequest

type CreateTemplateRequest struct {
	Name string `form:"name"`
	HTML string `form:"html"`
}

type Event

type Event struct {
	ID         ulids.ULID
	CampaignID ulids.ULID `gorm:"references:CampaignID"`
	Detail     string
	CreatedAt  time.Time
	Status     EventStatus
}

type EventStatus

type EventStatus string
const (
	EventStatusSuccess EventStatus = "success"
	EventStatusFailed  EventStatus = "failed"
)

type File

type File struct {
	ID       ulids.ULID `gorm:"primary_key"`
	Folder   string
	FileName string
	Audit
}

type FileService

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

func (*FileService) Find

func (f *FileService) Find(ctx context.Context, fileName string) (rc io.ReadCloser, err error)

type Service

type Service struct {
	CampaignService *CampaignService
	FileService     *FileService
	TemplateService *TemplateService
}

func NewService

func NewService(db *gorm.DB, localStorage *localfs.Storage, blastEmailCfg *BlastEmailConfig) *Service

type Template

type Template struct {
	ID   ulids.ULID `gorm:"primary_key"`
	Name string
	HTML string
	Audit
}

type TemplateService

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

func (*TemplateService) Create

func (t *TemplateService) Create(ctx context.Context, req CreateTemplateRequest) (tpl Template, err error)

func (*TemplateService) FindAll

func (t *TemplateService) FindAll(ctx context.Context) (tmplts []Template, err error)

func (*TemplateService) FindByID

func (t *TemplateService) FindByID(ctx context.Context, id ulids.ULID) (tpl Template, err error)

func (*TemplateService) Update

func (t *TemplateService) Update(ctx context.Context, req UpdateTemplateRequest) (tpl Template, err error)

type UpdateCampaignRequest

type UpdateCampaignRequest struct {
	ID         ulids.ULID  `form:"id"`
	Name       string      `form:"name"`
	Body       string      `form:"body"`
	Subject    string      `form:"subject"`
	CSV        io.Reader   `form:"-"`
	TemplateID *ulids.ULID `form:"-"`
}

type UpdateTemplateRequest

type UpdateTemplateRequest struct {
	ID   ulids.ULID `form:"id"`
	HTML string     `form:"html"`
	Name string     `form:"name"`
}

Jump to

Keyboard shortcuts

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