api

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

File: client.go

Index

Constants

This section is empty.

Variables

View Source
var AnsiEscape = map[string]func(a ...interface{}) string{
	"BoldRed":    color.New(color.FgRed, color.Bold).SprintFunc(),
	"BoldGreen":  color.New(color.FgGreen, color.Bold).SprintFunc(),
	"BoldCyan":   color.New(color.FgCyan, color.Bold).SprintFunc(),
	"BoldYellow": color.New(color.FgYellow, color.Bold).SprintFunc(),
}

Functions

func GetSubscriptionTypes added in v0.1.10

func GetSubscriptionTypes() []string

func LogInfof added in v0.1.6

func LogInfof(format string, a ...any)

func LogInfoln added in v0.1.6

func LogInfoln(a ...any)

func LogOKf added in v0.1.6

func LogOKf(format string, a ...any)

func LogOKln added in v0.1.6

func LogOKln(a ...any)

func LogWarningf added in v0.1.6

func LogWarningf(format string, a ...any)

func LogWarningln added in v0.1.6

func LogWarningln(a ...any)

Types

type APIClient

type APIClient struct {
	BaseURL        string
	Username       *string
	Password       *string
	Client         *listmonk.Client
	MailingListIDs sync.Map
}

func NewAPIClient

func NewAPIClient(baseURL string, username, password *string) *APIClient

func (*APIClient) AddAndSendCampaign

func (c *APIClient) AddAndSendCampaign(email string, listName string) (bool, error)

Add subscriber to list and launch campaign

func (*APIClient) AddCSVAndSendCampaign

func (c *APIClient) AddCSVAndSendCampaign(path, list string, passwords map[string]string) (bool, error)

Add subscribers from CSV and launch campaigns of affected lists. Return true if all campaigns were launched successfully

func (*APIClient) AddSubscribersFromCSV

func (c *APIClient) AddSubscribersFromCSV(path, list string, passwords map[string]string) error

Add subscribers from CSV file. Assumes CSV has columns: Duration (years), Email, Date received, Expiration date

func (*APIClient) AddToList

func (c *APIClient) AddToList(email string, listName string) error

Add subscriber to list

func (*APIClient) CreateCampaign added in v0.1.7

func (c *APIClient) CreateCampaign(name, subject string, lists []uint, content, contentType string) (uint, error)

func (*APIClient) CreateCampaignHTML

func (c *APIClient) CreateCampaignHTML(name string, subject string, lists []uint, content string) (uint, error)

Create a new campaign with HTML content

func (*APIClient) CreateCampaignHTMLOnListName

func (c *APIClient) CreateCampaignHTMLOnListName(campaignName string, subject string, listName string, content string) (uint, error)

Create campaign from HTML on a list given by name.

func (*APIClient) CreateSubscriber

func (c *APIClient) CreateSubscriber(name string, email string, lists []string, attrs map[string]interface{}) (uint, error)

Create a new subscriber and add them to mailing lists with specified names, including attributes

func (*APIClient) CreateSubscriberFromJSON added in v0.1.1

func (c *APIClient) CreateSubscriberFromJSON(jsonData []byte) (uint, error)

Create a new subscriber from JSON data

func (*APIClient) CreateSubscriberListIDs

func (c *APIClient) CreateSubscriberListIDs(name string, email string, lists []uint, attrs map[string]interface{}) (uint, error)

Create a new subscriber and add them to mailing lists with specified IDs, including attributes

func (*APIClient) DeleteList added in v0.1.7

func (c *APIClient) DeleteList(name string) error

func (*APIClient) DeleteSubscriberEmail

func (c *APIClient) DeleteSubscriberEmail(email string) error

Delete subscriber by email

func (*APIClient) DeleteSubscriberID

func (c *APIClient) DeleteSubscriberID(id uint) error

Delete subscriber by ID

func (*APIClient) GetSubscriber added in v0.1.1

func (c *APIClient) GetSubscriber(subscriberID uint) (*listmonk.Subscriber, error)

GetSubscriber retrieves a subscriber by ID

func (*APIClient) GetSubscriberAttributes added in v0.1.1

func (c *APIClient) GetSubscriberAttributes(subscriberID uint) (map[string]interface{}, error)

GetSubscriberAttributes retrieves a subscriber's attributes by ID

func (*APIClient) GetSubscriberAttributesEmail added in v0.1.2

func (c *APIClient) GetSubscriberAttributesEmail(email string) (map[string]interface{}, error)

func (*APIClient) GetSubscriberExport added in v0.2.3

func (c *APIClient) GetSubscriberExport(email string) (*ExportData, error)

Calls GET /api/subscribers/{id}/export It is currently not implemented in go-listmonk

func (*APIClient) GetSubscribers added in v0.2.0

func (c *APIClient) GetSubscribers(query string) ([]*listmonk.Subscriber, error)

Get subscribers by query

func (*APIClient) LaunchCampaign

func (c *APIClient) LaunchCampaign(id uint) (bool, error)

Launch campaign or send finished campaign to newly subscribed users

func (*APIClient) LaunchCampaignListName

func (c *APIClient) LaunchCampaignListName(listName string) (bool, error)

Launch campaign on list

func (*APIClient) ListSubscribers added in v0.1.4

func (c *APIClient) ListSubscribers(listName string) ([]map[string]string, error)

func (*APIClient) RemoveFromList

func (c *APIClient) RemoveFromList(email string, listName string) error

Remove subscriber from a list.

func (*APIClient) SendEmail added in v0.1.7

func (c *APIClient) SendEmail(subscriptionType, subscriberEmail, name, config_path string) error

func (*APIClient) SetAttribute added in v0.1.2

func (c *APIClient) SetAttribute(email, key, value string) error

Set a single attribute for subscriber

func (*APIClient) UpdateSubscriberAttributes added in v0.1.1

func (c *APIClient) UpdateSubscriberAttributes(subscriberID uint, attrs map[string]interface{}) error

UpdateSubscriberAttributes updates a subscriber's attributes

func (*APIClient) UpdateSubscriberAttributesEmail added in v0.1.2

func (c *APIClient) UpdateSubscriberAttributesEmail(email string, attrs map[string]interface{}) error

type ExportData added in v0.2.3

type ExportData struct {
	Subscriptions []Subscription `json:"subscriptions"`
}

type SubscriberInput added in v0.1.1

type SubscriberInput struct {
	Name  string                 `json:"name"`
	Email string                 `json:"email"`
	Lists []string               `json:"lists"`
	Attrs map[string]interface{} `json:"attrs"`
}

type Subscription added in v0.2.3

type Subscription struct {
	SubscriptionType string    `json:"name"`
	SubscriptionDate time.Time `json:"created_at"`
}

Jump to

Keyboard shortcuts

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