api

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Paginate

func Paginate[T any](fetch func(cursor string) ([]T, *Pagination, error)) ([]T, error)

Types

type APIError

type APIError struct {
	StatusCode int
	Message    string
}

func (*APIError) Error

func (e *APIError) Error() string

type APIKeyResponse

type APIKeyResponse struct {
	TeamName string `json:"teamName"`
}

type Attachment

type Attachment struct {
	Filename    string `json:"filename"`
	ContentType string `json:"contentType"`
	Data        string `json:"data"`
}

type Campaign added in v0.2.1

type Campaign struct {
	CampaignID     string  `json:"campaignId"`
	EmailMessageID *string `json:"emailMessageId"`
	Name           string  `json:"name"`
	Status         string  `json:"status"`
	CreatedAt      string  `json:"createdAt"`
	UpdatedAt      string  `json:"updatedAt"`
}

type CampaignCreateResponse added in v0.2.1

type CampaignCreateResponse struct {
	Campaign
	EmailMessageContentRevisionID *string `json:"emailMessageContentRevisionId"`
}

type CampaignListItem added in v0.3.0

type CampaignListItem struct {
	CampaignID     string  `json:"campaignId"`
	EmailMessageID *string `json:"emailMessageId"`
	Name           string  `json:"name"`
	Subject        string  `json:"subject"`
	Status         string  `json:"status"`
	CreatedAt      string  `json:"createdAt"`
	UpdatedAt      string  `json:"updatedAt"`
}

type Client

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

func NewClient

func NewClient(baseURL, apiKey string, debug bool) *Client

func (*Client) CheckContactSuppression added in v0.0.2

func (c *Client) CheckContactSuppression(email, userID string) (*ContactSuppression, error)

func (*Client) CreateCampaign added in v0.2.1

func (c *Client) CreateCampaign(req CreateCampaignRequest) (*CampaignCreateResponse, error)

func (*Client) CreateContact

func (c *Client) CreateContact(req CreateContactRequest) (string, error)

func (*Client) CreateContactProperty

func (c *Client) CreateContactProperty(name, propType string) error

func (*Client) DeleteContact

func (c *Client) DeleteContact(email, userID string) error

func (*Client) FindContacts

func (c *Client) FindContacts(params FindContactParams) ([]Contact, error)

func (*Client) GetAPIKey

func (c *Client) GetAPIKey() (*APIKeyResponse, error)

func (*Client) GetCampaign added in v0.2.1

func (c *Client) GetCampaign(id string) (*Campaign, error)

func (*Client) GetEmailMessage added in v0.2.1

func (c *Client) GetEmailMessage(id string) (*EmailMessage, error)

func (*Client) ListCampaigns added in v0.2.1

func (c *Client) ListCampaigns(params PaginationParams) ([]CampaignListItem, *Pagination, error)

func (*Client) ListContactProperties

func (c *Client) ListContactProperties(customOnly bool) ([]ContactProperty, error)

func (*Client) ListMailingLists

func (c *Client) ListMailingLists() ([]MailingList, error)

func (*Client) ListTransactional

func (c *Client) ListTransactional(params PaginationParams) ([]TransactionalEmail, *Pagination, error)

func (*Client) RemoveContactSuppression added in v0.0.2

func (c *Client) RemoveContactSuppression(email, userID string) (*ContactSuppressionRemoval, error)

func (*Client) SendEvent

func (c *Client) SendEvent(req SendEventRequest) error

func (*Client) SendTransactional

func (c *Client) SendTransactional(req SendTransactionalRequest) error

func (*Client) UpdateCampaign added in v0.3.0

func (c *Client) UpdateCampaign(id string, req UpdateCampaignRequest) (*Campaign, error)

func (*Client) UpdateContact

func (c *Client) UpdateContact(req UpdateContactRequest) error

func (*Client) UpdateEmailMessage added in v0.2.1

func (c *Client) UpdateEmailMessage(id string, req UpdateEmailMessageRequest) (*EmailMessage, error)

func (*Client) WithUserAgent

func (c *Client) WithUserAgent(ua string) *Client

type Contact

type Contact struct {
	ID           string          `json:"id"`
	Email        string          `json:"email"`
	FirstName    *string         `json:"firstName"`
	LastName     *string         `json:"lastName"`
	Source       string          `json:"source"`
	Subscribed   bool            `json:"subscribed"`
	UserGroup    string          `json:"userGroup"`
	UserID       *string         `json:"userId"`
	MailingLists map[string]bool `json:"mailingLists"`
	OptInStatus  *string         `json:"optInStatus"`
	Custom       map[string]any  `json:"-"`
}

func (Contact) MarshalJSON added in v0.0.4

func (c Contact) MarshalJSON() ([]byte, error)

func (*Contact) UnmarshalJSON added in v0.0.4

func (c *Contact) UnmarshalJSON(data []byte) error

type ContactProperty

type ContactProperty struct {
	Key   string `json:"key"`
	Label string `json:"label"`
	Type  string `json:"type"`
}

type ContactSuppression added in v0.0.2

type ContactSuppression struct {
	Contact struct {
		ID     string  `json:"id"`
		Email  string  `json:"email"`
		UserID *string `json:"userId"`
	} `json:"contact"`
	IsSuppressed bool `json:"isSuppressed"`
	RemovalQuota struct {
		Limit     int `json:"limit"`
		Remaining int `json:"remaining"`
	} `json:"removalQuota"`
}

type ContactSuppressionRemoval added in v0.0.2

type ContactSuppressionRemoval struct {
	Success      bool   `json:"success"`
	Message      string `json:"message"`
	RemovalQuota struct {
		Limit     int `json:"limit"`
		Remaining int `json:"remaining"`
	} `json:"removalQuota"`
}

type CreateCampaignRequest added in v0.2.1

type CreateCampaignRequest struct {
	Name string `json:"name"`
}

type CreateContactRequest

type CreateContactRequest struct {
	Email             string
	FirstName         string
	LastName          string
	Source            string
	Subscribed        *bool
	UserGroup         string
	UserID            string
	MailingLists      map[string]bool
	ContactProperties map[string]any
}

type EmailMessage added in v0.2.1

type EmailMessage struct {
	EmailMessageID    string       `json:"emailMessageId"`
	CampaignID        *string      `json:"campaignId"`
	Subject           string       `json:"subject"`
	PreviewText       string       `json:"previewText"`
	FromName          string       `json:"fromName"`
	FromEmail         string       `json:"fromEmail"`
	ReplyToEmail      string       `json:"replyToEmail"`
	LMX               string       `json:"lmx"`
	ContentRevisionID *string      `json:"contentRevisionId"`
	UpdatedAt         string       `json:"updatedAt"`
	Warnings          []LmxWarning `json:"warnings,omitempty"`
}

type EmailMessageFields added in v0.2.1

type EmailMessageFields struct {
	Subject      string `json:"subject,omitempty"`
	PreviewText  string `json:"previewText,omitempty"`
	FromName     string `json:"fromName,omitempty"`
	FromEmail    string `json:"fromEmail,omitempty"`
	ReplyToEmail string `json:"replyToEmail,omitempty"`
	LMX          string `json:"lmx,omitempty"`
}

type FindContactParams

type FindContactParams struct {
	Email  string
	UserID string
}

type LmxWarning added in v0.2.1

type LmxWarning struct {
	Rule     string `json:"rule"`
	Severity string `json:"severity"`
	Message  string `json:"message"`
	Path     string `json:"path,omitempty"`
}

type MailingList

type MailingList struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	IsPublic    bool   `json:"isPublic"`
}

type Pagination

type Pagination struct {
	TotalResults    int    `json:"totalResults"`
	ReturnedResults int    `json:"returnedResults"`
	PerPage         int    `json:"perPage"`
	TotalPages      int    `json:"totalPages"`
	NextCursor      string `json:"nextCursor"`
	NextPage        string `json:"nextPage"`
}

type PaginationParams

type PaginationParams struct {
	PerPage string
	Cursor  string
}

type SendEventRequest

type SendEventRequest struct {
	Email             string          `json:"-"`
	UserID            string          `json:"-"`
	EventName         string          `json:"-"`
	EventProperties   map[string]any  `json:"-"`
	MailingLists      map[string]bool `json:"-"`
	ContactProperties map[string]any  `json:"-"`
	IdempotencyKey    string          `json:"-"`
}

type SendTransactionalRequest

type SendTransactionalRequest struct {
	Email           string         `json:"email"`
	TransactionalID string         `json:"transactionalId"`
	AddToAudience   *bool          `json:"addToAudience,omitempty"`
	DataVariables   map[string]any `json:"dataVariables,omitempty"`
	Attachments     []Attachment   `json:"attachments,omitempty"`
	IdempotencyKey  string         `json:"-"`
}

type TransactionalEmail

type TransactionalEmail struct {
	ID            string   `json:"id"`
	Name          string   `json:"name"`
	LastUpdated   string   `json:"lastUpdated"`
	DataVariables []string `json:"dataVariables"`
}

type UpdateCampaignRequest added in v0.3.0

type UpdateCampaignRequest struct {
	Name string `json:"name"`
}

type UpdateContactRequest

type UpdateContactRequest struct {
	Email             string
	UserID            string
	FirstName         string
	LastName          string
	Subscribed        *bool
	UserGroup         string
	MailingLists      map[string]bool
	ContactProperties map[string]any
}

type UpdateEmailMessageRequest added in v0.2.1

type UpdateEmailMessageRequest struct {
	EmailMessageFields
	Set                map[string]bool
	ExpectedRevisionID string
}

Jump to

Keyboard shortcuts

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