email

package
v0.0.0-...-46021d3 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//RabbitMQChan is a pointer to a rabbitmq channel
	RabbitMQChan *amqp.Channel
	//RabbitMQQueue is a rabbitmq queue
	RabbitMQQueue amqp.Queue
)

Functions

func AddRecipientToMailinglist

func AddRecipientToMailinglist(w http.ResponseWriter, r *http.Request)

AddRecipientToMailinglist is a handler func to add recipient to a mailing list

func ConnectToRabbitMQ

func ConnectToRabbitMQ() error

ConnectToRabbitMQ is for connecting to rabbitmq

func CreateCampaign

func CreateCampaign(w http.ResponseWriter, r *http.Request)

CreateCampaign is a handler func to create a new campaign

func CreateMailingList

func CreateMailingList(w http.ResponseWriter, r *http.Request)

CreateMailingList is the handler func to create a new mailing list

func DeleteRecipientsFromMailinglist

func DeleteRecipientsFromMailinglist(w http.ResponseWriter, r *http.Request)

DeleteRecipientsFromMailinglist is a handler func to delete recipients from a mailing list

func GetMailingList

func GetMailingList(w http.ResponseWriter, r *http.Request)

GetMailingList is a handler func to get a mailing list by id

func SendCampaignMessage

func SendCampaignMessage(w http.ResponseWriter, r *http.Request)

SendCampaignMessage is a handler func to send a message for a campaign

Types

type Campaign

type Campaign struct {
	ID            int64  `json:"id"`
	Name          string `json:"name,omitempty"`
	Description   string `json:"description,omitempty"`
	TemplateName  string `json:"template_name,omitempty"`
	TemplatePath  string `json:"template_path,omitempty"`
	IDMailingList int64  `json:"id_mailing_list,omitempty"`
}

Campaign is a marketing campaign

type CampaignID

type CampaignID struct {
	ID int64 `json:"id"`
}

CampaignID represent a campaign ID

type MailingList

type MailingList struct {
	ID          int64        `json:"id"`
	Name        string       `json:"name"`
	Description string       `json:"description"`
	Recipients  []*Recipient `json:"recipients" db:"-"`
}

MailingList with recipients emails

type RBMQQueuecreation

type RBMQQueuecreation struct {
	RabbitMQChan  *amqp.Channel
	RabbitMQQueue amqp.Queue
}

RBMQQueuecreation is a rabbitmq model

type RabbitMqEnv

type RabbitMqEnv struct {
	RabbitMqHost string `env:"RABBITMQ_HOST"`
	RabbitMqPort string `env:"RABBITMQ_PORT"`
	RabbitMqUser string `env:"RABBITMQ_DEFAULT_USER"`
	RabbitMqPass string `env:"RABBITMQ_DEFAULT_PASS"`
}

RabbitMqEnv contains rabbitmq env credentials

type Recipient

type Recipient struct {
	ID        int64  `json:"id,omitempty" db:"id"`
	Email     string `json:"email" db:"email"`
	FirstName string `json:"first_name" db:"first_name"`
	LastName  string `json:"last_name" db:"last_name"`
	UserName  string `json:"username" db:"username"`
}

Recipient of an email

type Repository

type Repository struct {
	Conn *sql.DB
}

Repository struct for db connection

func (*Repository) AddRecipientToMailingList

func (repository *Repository) AddRecipientToMailingList(recipientIDs []int64, mailingListID int64) error

AddRecipientToMailingList is for adding recipients to a mailing list

func (*Repository) DeleteRecipientsFromMailingList

func (repository *Repository) DeleteRecipientsFromMailingList(mailingListID int64, recipientIDs []int64) (int64, error)

DeleteRecipientsFromMailingList is for deleting recipients from a mailing list

func (*Repository) GetCampaign

func (repository *Repository) GetCampaign(id int64) (*Campaign, error)

GetCampaign get a campaign by id in the database

func (*Repository) GetMailingList

func (repository *Repository) GetMailingList(id int64) (*MailingList, error)

GetMailingList gets a mailing list by ID from the database

func (*Repository) GetRecipientsFromMailingList

func (repository *Repository) GetRecipientsFromMailingList(id int64) ([]*Recipient, error)

GetRecipientsFromMailingList is for getting all recipients from a mailing list

func (*Repository) SaveCampaign

func (repository *Repository) SaveCampaign(campaign *Campaign) error

SaveCampaign save a new campaign in database

func (*Repository) SaveMailingList

func (repository *Repository) SaveMailingList(mailingList *MailingList) error

SaveMailingList saves a new mailing list to database

func (*Repository) SaveRecipients

func (repository *Repository) SaveRecipients(recipients []*Recipient) ([]int64, error)

SaveRecipients is for saving new recipients

Jump to

Keyboard shortcuts

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