Documentation ¶
Index ¶
- Variables
- func AddRecipientToMailinglist(w http.ResponseWriter, r *http.Request)
- func ConnectToRabbitMQ() error
- func CreateCampaign(w http.ResponseWriter, r *http.Request)
- func CreateMailingList(w http.ResponseWriter, r *http.Request)
- func DeleteRecipientsFromMailinglist(w http.ResponseWriter, r *http.Request)
- func GetMailingList(w http.ResponseWriter, r *http.Request)
- func SendCampaignMessage(w http.ResponseWriter, r *http.Request)
- type Campaign
- type CampaignID
- type MailingList
- type RBMQQueuecreation
- type RabbitMqEnv
- type Recipient
- type Repository
- func (repository *Repository) AddRecipientToMailingList(recipientIDs []int64, mailingListID int64) error
- func (repository *Repository) DeleteRecipientsFromMailingList(mailingListID int64, recipientIDs []int64) (int64, error)
- func (repository *Repository) GetCampaign(id int64) (*Campaign, error)
- func (repository *Repository) GetMailingList(id int64) (*MailingList, error)
- func (repository *Repository) GetRecipientsFromMailingList(id int64) ([]*Recipient, error)
- func (repository *Repository) SaveCampaign(campaign *Campaign) error
- func (repository *Repository) SaveMailingList(mailingList *MailingList) error
- func (repository *Repository) SaveRecipients(recipients []*Recipient) ([]int64, error)
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 ¶
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