sib

package module
v0.0.0-...-378a6df Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2017 License: Apache-2.0 Imports: 10 Imported by: 16

README

SendInBlue APIv2.0 Client Library (Go)

Travis GoDoc Go Report Card codecov

Install

go get -u github.com/JKhawaja/sendinblue

Features

  • SMTP API Client
  • SMS API Client

TODO

Campaign API Client
Marketing Automation API Client

Documentation

Overview

Package sib is a library for constructing a SendInBlue API2.0 client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AggregateData

type AggregateData struct {
	Date          string `json:"date"`
	Tag           string `json:"tag"`
	Requests      int    `json:"requests"`
	Delivered     int    `json:"delivered"`
	Bounces       int    `json:"bounces"`
	Clicks        int    `json:"clicks"`
	Unique_clicks int    `json:"unique_clicks"`
	Opens         int    `json:"opens"`
	Unique_opens  int    `json:"unique_opens"`
	SpamReports   int    `json:"spamreports"`
	Blocked       int    `json:"blocked"`
	Invalid       int    `json:"invalid"`
}

type AggregateReport

type AggregateReport struct {
	Aggregate  int    `json:"aggregate"` // 0 or 1, 0 means no aggregation (stats per day)
	Start_date string `json:"start_date"`
	End_date   string `json:"end_date"`
	Days       int    `json:"days"`
	Tag        string `json:"tag"`
}

type AggregateResponse

type AggregateResponse struct {
	Code    string          `json:"code"`
	Message string          `json:"message"`
	Data    []AggregateData `json:"data"`
}

type CampaignData

type CampaignData struct {
	ID            int    `json:"id"`
	Campaign_name string `json:"campaign_name"`
	Subject       string `json:"subject"`
	Bat_sent      string `json:"bat_sent"`
	Type          string `json:"type"`
	Html_content  string `json:"html_content"`
	Entered       string `json:"entered"`
	Modified      string `json:"modified"`
	Templ_status  string `json:"templ_status"`
	From_name     string `json:"from_name"`
	From_email    string `json:"from_email"`
	Reply_to      string `json:"reply_to"`
	To_field      string `json:"to_field"`
}

type CampaignResponse

type CampaignResponse struct {
	Code    string         `json:"code"`
	Message string         `json:"message"`
	Data    []CampaignData `json:"data"`
}

type Client

type Client struct {
	Client *http.Client
	// contains filtered or unexported fields
}

The Client type is the primary type in the package.

func NewClient

func NewClient(apiKey string) (*Client, error)

NewClient takes a private SendInBlue API key and constructs a Client Object that can be used to talk to the SendInBlue API via the Client methods.

func (*Client) AggregateReport

func (c *Client) AggregateReport(a *AggregateReport) (AggregateResponse, error)

AggregateReport is a Client Method for the SMTP API. Developers can access information about aggregate / date-wise report of the SendinBlue SMTP account using this API. https://apidocs.sendinblue.com/statistics/

func (*Client) CreateSMSCampaign

func (c *Client) CreateSMSCampaign(s *SMSCampaign) (SMSCampaignResponse, error)

CreateSMSCampaign ...

func (*Client) CreateTemplate

func (c *Client) CreateTemplate(t *Template) (TemplateResponse, error)

CreateTemplate ...

func (*Client) DeleteBouncedEmails

func (c *Client) DeleteBouncedEmails(start, end, email string) error

DeleteBouncedEmails ... Start and End dates must be in YYYY-MM-DD format Start date must be before end date, and end date must be after start date

func (*Client) GetTemplate

func (c *Client) GetTemplate(template_id int) (CampaignResponse, error)

GetTemplate ...

func (*Client) ListTemplates

func (c *Client) ListTemplates(t *TemplateList) (TemplateListResponse, error)

ListTemplates ...

func (*Client) SMSCampaignTest

func (c *Client) SMSCampaignTest(id int, to string) (SMSResponse, error)

SMSCampaignTest ...

func (*Client) SendEmail

func (c *Client) SendEmail(e *Email) (EmailResponse, error)

SendEmail ...

func (*Client) SendSMS

func (c *Client) SendSMS(s *SMSRequest) (SMSResponse, error)

SendSMS ...

func (*Client) SendTemplateEmail

func (c *Client) SendTemplateEmail(id int, to []string, e *EmailOptions) (EmailResponse, error)

SendTemplateEmail ...

func (*Client) UpdateSMSCampaign

func (c *Client) UpdateSMSCampaign(id int, s *SMSCampaign) error

UpdateSMSCampaign ...

func (*Client) UpdateTemplate

func (c *Client) UpdateTemplate(id int, t *Template) error

UpdateTemplate ...

type DeleteBouncesRequest

type DeleteBouncesRequest struct {
	Start_date string `json:"start_date"`
	End_date   string `json:"end_date"`
	Email      string `json:"email"`
}

type Email

type Email struct {
	To           map[string]string `json:"to"`
	Subject      string            `json:"subject"`
	From         [2]string         `json:"from"`
	HTML         string            `json:"html"`
	Text         string            `json:"text"`
	CC           map[string]string `json:"cc"`
	Bcc          map[string]string `json:"bcc"`
	ReplyTo      map[string]string `json:"replyto"`
	Attachment   map[string]string `json:"attachment"` // must be URL
	Headers      map[string]string `json:"headers"`
	Inline_image map[string]string `json:"inline_image"`
}

API Docs: https://apidocs.sendinblue.com/tutorial-sending-transactional-email/

func NewEmail

func NewEmail() *Email

func (*Email) AddImage

func (e *Email) AddImage(f *os.File) string

AddImage() Method ... returns the filename, which can (and should) be used as a variable in HTML < img src="{{{filename}}}" alt="image" border="0" >

type EmailData

type EmailData struct {
	Message_id string `json:"message-id"`
}

type EmailOptions

type EmailOptions struct {
	Cc             string // multiple addresses, delimiter = pipe
	Bcc            string // multiple addresses, delimiter = pipe
	ReplyTo        string
	Attr           map[string]string
	Attachment_url string
	Attachment     map[string]string
	Headers        map[string]string
}

func NewEmailOptions

func NewEmailOptions(replyto, attachment_url string, cc, bcc []string) *EmailOptions

func (*EmailOptions) AddAttachment

func (e *EmailOptions) AddAttachment(f *os.File) error

type EmailResponse

type EmailResponse struct {
	Code    string    `json:"code"`
	Message string    `json:"message"`
	Data    EmailData `json:"data"`
}

type SMSCampaign

type SMSCampaign struct {
	Name           string `json:"name"` // Mandatory
	Sender         string `json:"sender"`
	Content        string `json:"content"`
	Bat_sent       string `json:"bat_sent"`
	List_ids       []int  `json:"listid"` // Mandatory if Scheduled_date
	Exclude_list   []int  `json:"exclude_list"`
	Scheduled_date string `json:"scheduled_date"` // Format: YYYY-MM-DD 00:00:00
	Send_now       int    `json:"send_now"`       // 0 = campaign not ready to send, 1 = ready to send now
}

type SMSCampaignData

type SMSCampaignData struct {
	Id int `json:"id"`
}

type SMSCampaignResponse

type SMSCampaignResponse struct {
	Code    string          `json:"code"`
	Message string          `json:"message"`
	Data    SMSCampaignData `json:"data"`
}

type SMSData

type SMSData struct {
	Status           string       `json:"status"`
	Number_sent      int          `json:"number_sent"`
	To               string       `json:"to"`
	Sms_count        int          `json:"sms_count"`
	Credits_used     float64      `json:"credits_used"`
	Remaining_credit float64      `json:"remaining_credit"`
	Reference        SMSReference `json:"reference"`
	Description      string       `json:"description"`
	Reply            string       `json:"reply"`
	Bounce_type      string       `json:"bounce_type"`
	Error_code       int          `json:"error_code"`
}

type SMSReference

type SMSReference struct {
	One string `json:"1"`
}

type SMSRequest

type SMSRequest struct {
	To      string `json:"to"`   // Mobile Number (Mandatory)
	From    string `json:"from"` // No more than 11 alphanumeric characters (Mandatory)
	Text    string `json:"text"` // No more than 160 characters (Mandatory)
	Web_url string `json:"web_url"`
	Tag     string `json:"tag"`
	Type    string `json:"type"` // "marketing" (default) or "transactional"
}

type SMSResponse

type SMSResponse struct {
	Code    string  `json:"code"`
	Message string  `json:"message"`
	Data    SMSData `json:"data"`
}

type SMSTest

type SMSTest struct {
	To string `json:"to"`
}

type Template

type Template struct {
	From_name      string `json:"from_name"`
	Template_name  string `json:"template_name"` // Mandatory
	Bat            string `json:"bat"`
	Html_content   string `json:"html_content"` // Mandatory (if no html_url)
	Html_url       string `json:"html_url"`     // Mandatory (if no html_content)
	Subject        string `json:"subject"`      // Mandatory
	From_email     string `json:"from_email"`   // Mandatory
	Reply_to       string `json:"reply_to"`
	To_field       string `json:"to_field"`
	Status         int    `json:"status"` // 0 (inactive -- default) or 1 (active)
	Attachment_url string `json:"attachment_url"`
}

API Docs: https://apidocs.sendinblue.com/template/

type TemplateData

type TemplateData struct {
	ID int `json:"id"`
}

type TemplateEmail

type TemplateEmail struct {
	To             string            `json:"to"`  // multiple addresses, delimiter = pipe
	Cc             string            `json:"cc"`  // multiple addresses, delimiter = pipe
	Bcc            string            `json:"bcc"` // multiple addresses, delimiter = pipe
	ReplyTo        string            `json:"replyto"`
	Attr           map[string]string `json:"attr"`
	Attachment_url string            `json:"attachment_url"`
	Attachment     map[string]string `json:"attachment"`
	Headers        map[string]string `json:"headers"`
}

type TemplateList

type TemplateList struct {
	Type       string `json:"type"`
	Status     string `json:"status"`
	Page       int    `json:"page"`
	Page_limit int    `json:"page_limit"`
}

type TemplateListData

type TemplateListData struct {
	Campaign_records       []CampaignData `json:"campaign_records"`
	Page                   int            `json:"page"`
	Page_limit             int            `json:"page_limit"`
	Total_campaign_records int            `json:"total_campaign_records"`
}

type TemplateListResponse

type TemplateListResponse struct {
	Code    string           `json:"code"`
	Message string           `json:"message"`
	Data    TemplateListData `json:"data"`
}

type TemplateResponse

type TemplateResponse struct {
	Code    string       `json:"code"`
	Message string       `json:"message"`
	Data    TemplateData `json:"data"`
}

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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