api

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 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 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) 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) 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) UpdateContact

func (c *Client) UpdateContact(req UpdateContactRequest) 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"`
}

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 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 FindContactParams

type FindContactParams struct {
	Email  string
	UserID string
}

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 UpdateContactRequest

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

Jump to

Keyboard shortcuts

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