leadpush

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: MIT Imports: 12 Imported by: 0

README

leadpush-go

Official Go SDK for the Leadpush API.

Create a Leadpush account at leadpush.io.

Installation

go get github.com/LeadPush/leadpush-go@v1.0.0

Requirements:

  • Go 1.25 or newer
  • A Leadpush API key

Quick start

package main

import (
	"context"
	"fmt"
	"log"
	"os"

	leadpush "github.com/LeadPush/leadpush-go"
)

func main() {
	client, err := leadpush.New(os.Getenv("LEADPUSH_API_KEY"))
	if err != nil {
		log.Fatal(err)
	}

	contacts, err := client.Contacts.List(context.Background(), &leadpush.ContactListParams{
		Page:    1,
		PerPage: 10,
	})
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(contacts.Data)
}

Configuration

client, err := leadpush.New(
	"leadpush_api_key",
	leadpush.WithBaseURL("https://api.leadpush.io/v1"),
	leadpush.WithTimeout(30*time.Second),
	leadpush.WithHeaders(map[string]string{"X-App-Name": "my-app"}),
	leadpush.WithUserAgent("my-app/1.0"),
	leadpush.WithHTTPClient(customHTTPClient),
)

Defaults:

  • baseURL: https://api.leadpush.io/v1
  • timeout: 30 seconds; use WithTimeout(0) to disable the SDK timeout
  • userAgent: leadpush-go/1.0.0 (api=v1)
  • httpClient: http.DefaultClient

An HTTP client passed with WithHTTPClient remains caller-owned.

Contacts

Contact identifiers may be either a contact UUID or the workspace identity value, such as an email address.

contact, err := client.Contacts.Get(ctx, "person@example.com")

created, err := client.Contacts.Create(ctx, leadpush.CreateContactParams{
	Attributes: leadpush.Attributes{
		"email":      "person@example.com",
		"first_name": "Person",
	},
	Subscribed: leadpush.Ptr(true),
})

updated, err := client.Contacts.Update(ctx, contact.UUID, leadpush.UpdateContactParams{
	Attributes: leadpush.Attributes{"first_name": "Updated"},
	Subscribed: leadpush.Ptr(false),
})

contact, err = client.Contacts.Subscribe(ctx, "person@example.com")
contact, err = client.Contacts.Unsubscribe(ctx, "person@example.com")
Contact events
events := client.Contacts.Events("person@example.com")

page, err := events.List(ctx, &leadpush.ContactEventListParams{
	Search: "purchase",
})

err = events.Create(ctx, leadpush.CreateContactEventParams{
	EventName:  "purchase",
	Attributes: leadpush.ContactEventAttributes{"plan": "enterprise"},
})

Event creation returns only an error because the API does not return the created event.

Pagination

List methods retrieve one page. A pager advances using the API's has_next metadata and preserves request errors:

pager := client.Contacts.NewPager(&leadpush.ContactListParams{PerPage: 100})

for pager.Next(ctx) {
	for _, contact := range pager.Page().Data {
		fmt.Println(contact.UUID)
	}
}

if err := pager.Err(); err != nil {
	log.Fatal(err)
}

Setting Page on the list parameters controls the pager's starting page.

Domains and addresses

domain, err := client.Domains.Create(ctx, leadpush.CreateDomainParams{
	Name:              "example.com",
	DKIMSelectors:     leadpush.Some([]string{"default"}),
	TrackingSubdomain: leadpush.Some("click"),
	TrackingMode:      leadpush.Some(leadpush.DomainTrackingModeCloudflare),
})

domain, err = client.Domains.Verify(ctx, domain.UUID)

addresses := client.Domains.Addresses(domain.UUID)
address, err := addresses.Create(ctx, leadpush.CreateDomainAddressParams{
	Address:        "sender",
	DisplayName:    "Sender Name",
	ReplyTo:        "reply@example.com",
	CompanyAddress: "123 Main St",
	CompanyCity:    "New York",
	CompanyState:   "NY",
	CompanyZIP:     "10001",
	CompanyCountry: "US",
})

err = addresses.Delete(ctx, address.UUID)
err = client.Domains.Delete(ctx, domain.UUID)

Optional[T] distinguishes omitted, explicit values, and explicit null:

leadpush.Some("click")
leadpush.Null[string]()

Use Ptr for pointer request fields when a zero value, such as false or an empty string, must be included.

Emails

send, err := client.Emails.Send(ctx, leadpush.SendEmailParams{
	From:    "sender@example.com",
	Subject: "Developer API email",
	HTML:    leadpush.Ptr("<p>Hello world</p>"),
	Text:    leadpush.Ptr("Hello world"),
	To:      []string{"known@example.com", "other@example.com"},
	BCC:     []string{"audit@example.com"},
	ReplyTo: leadpush.Ptr("reply@example.com"),
	Headers: map[string]string{"X-Correlation-ID": "abc-123"},
})

fmt.Println(send.Accepted, send.MessageCount)

The sender must be a verified sendable address in the API key's workspace. Provide HTML, text, or both, and at least one recipient across To and BCC.

Fields and suppressions

fields, err := client.Fields.List(ctx, &leadpush.FieldListParams{
	Search: "company",
	Filters: []leadpush.FieldFilter{{
		ID:    leadpush.FieldFilterIDType,
		Value: []leadpush.FieldType{leadpush.FieldTypeText},
	}},
})

field, err := client.Fields.Create(ctx, leadpush.CreateFieldParams{
	Name: "company_name",
	Type: leadpush.FieldTypeText,
	Format: leadpush.Some(leadpush.FieldFormat{
		Text: leadpush.Ptr(leadpush.FieldTextFormatURL),
	}),
})

suppression, err := client.Suppressions.Create(ctx, leadpush.CreateSuppressionParams{
	Email: "blocked@example.com",
	Type:  leadpush.Ptr(leadpush.SuppressionTypeManual),
})

Suppressions intentionally do not expose an update method because the API endpoint is unsupported.

Low-level requests

Use Get, Post, Delete, or Do for endpoints without a typed resource method:

var response any
err := client.Get(
	ctx,
	[]string{"contacts", "person@example.com", "events"},
	map[string]any{"page": 1},
	&response,
)

Each path slice entry is escaped as one segment, so identity values containing /, @, or spaces are preserved. Arrays and objects in query values are encoded as compact JSON.

Errors

contact, err := client.Contacts.Get(ctx, "missing-contact")
if err != nil {
	var apiError *leadpush.APIError
	if errors.As(err, &apiError) {
		fmt.Println(apiError.StatusCode, apiError.Payload)
	}

	if leadpush.IsNotFound(err) {
		fmt.Println("contact not found")
	}
}

Documentation

Overview

Package leadpush provides an idiomatic Go client for the Leadpush API.

Create a client with New, then use its resource services to manage contacts, domains, fields, suppressions, and email sends. Every network operation accepts a context.Context.

Index

Constants

View Source
const (
	// SDKName is the name sent to the Leadpush API for this SDK.
	SDKName = "leadpush-go"

	// SDKVersion is the version of this SDK.
	SDKVersion = "1.0.0"

	// APIVersion is the Leadpush API version used by this SDK.
	APIVersion = "v1"

	// DefaultBaseURL is the production Leadpush API base URL.
	DefaultBaseURL = "https://api.leadpush.io/" + APIVersion

	// DefaultUserAgent is sent with API requests unless overridden.
	DefaultUserAgent = SDKName + "/" + SDKVersion + " (api=" + APIVersion + ")"
)
View Source
const DefaultTimeout = 30 * time.Second

DefaultTimeout is the default maximum duration of an API request.

Variables

This section is empty.

Functions

func IsForbidden

func IsForbidden(err error) bool

IsForbidden reports whether err is an API error with status 403.

func IsNotFound

func IsNotFound(err error) bool

IsNotFound reports whether err is an API error with status 404.

func IsUnauthorized

func IsUnauthorized(err error) bool

IsUnauthorized reports whether err is an API error with status 401.

func IsValidation

func IsValidation(err error) bool

IsValidation reports whether err is an API error with status 422.

func Ptr

func Ptr[T any](value T) *T

Ptr returns a pointer to value. It is useful for optional request fields where a zero value such as false or an empty string must still be sent.

Types

type APIError

type APIError struct {
	StatusCode int
	Payload    any
	RawBody    []byte
}

APIError is returned when the Leadpush API responds with a non-2xx status.

func (*APIError) Error

func (e *APIError) Error() string

Error implements error.

type Attributes

type Attributes map[string]any

Attributes contains custom contact field values.

type Client

type Client struct {
	Contacts     *ContactsService
	Domains      *DomainsService
	Emails       *EmailsService
	Fields       *FieldsService
	Suppressions *SuppressionsService
	// contains filtered or unexported fields
}

Client is a Leadpush API client.

func New

func New(apiKey string, options ...Option) (*Client, error)

New creates a Leadpush API client.

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, path []string, query map[string]any, result any) error

Delete performs a low-level DELETE request.

func (*Client) Do

func (c *Client) Do(ctx context.Context, request Request, result any) error

Do performs a low-level request and decodes the response into result. Path entries are always treated as individual URL path segments. Pass nil for result when no response body is expected.

func (*Client) Get

func (c *Client) Get(ctx context.Context, path []string, query map[string]any, result any) error

Get performs a low-level GET request.

func (*Client) Post

func (c *Client) Post(ctx context.Context, path []string, body any, query map[string]any, result any) error

Post performs a low-level POST request.

type Contact

type Contact struct {
	UUID       string     `json:"uuid"`
	Subscribed bool       `json:"subscribed"`
	Attributes Attributes `json:"attributes"`
	Provider   *string    `json:"provider"`
	UpdatedAt  time.Time  `json:"updated_at"`
	CreatedAt  time.Time  `json:"created_at"`
}

Contact is returned by contact endpoints.

type ContactEvent

type ContactEvent struct {
	UUID       string                  `json:"uuid"`
	EventName  string                  `json:"event_name"`
	Attributes *ContactEventAttributes `json:"attributes"`
	CreatedAt  time.Time               `json:"created_at"`
}

ContactEvent is returned by contact event list endpoints.

type ContactEventAttributes

type ContactEventAttributes map[string]any

ContactEventAttributes contains arbitrary event metadata.

type ContactEventListParams

type ContactEventListParams struct {
	Page    int
	PerPage int
	Search  string
}

ContactEventListParams configures a contact event list request.

type ContactEventsService

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

ContactEventsService provides nested contact event API operations.

func (*ContactEventsService) Create

func (service *ContactEventsService) Create(ctx context.Context, params CreateContactEventParams) error

Create creates a contact event. The API does not return the created event.

func (*ContactEventsService) List

List retrieves one page of contact events.

func (*ContactEventsService) NewPager

func (service *ContactEventsService) NewPager(params *ContactEventListParams) *Pager[ContactEvent]

NewPager returns a pager that retrieves all contact event pages.

type ContactListParams

type ContactListParams struct {
	Page    int
	PerPage int
}

ContactListParams configures a contact list request.

type ContactsService

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

ContactsService provides contact API operations.

func (*ContactsService) Create

func (service *ContactsService) Create(ctx context.Context, params CreateContactParams) (*Contact, error)

Create creates a contact.

func (*ContactsService) Events

func (service *ContactsService) Events(identifier string) *ContactEventsService

Events returns contact event operations for a UUID or workspace identity value.

func (*ContactsService) Get

func (service *ContactsService) Get(ctx context.Context, identifier string) (*Contact, error)

Get retrieves a contact by UUID or workspace identity value.

func (*ContactsService) List

func (service *ContactsService) List(ctx context.Context, params *ContactListParams) (*Page[Contact], error)

List retrieves one page of contacts.

func (*ContactsService) NewPager

func (service *ContactsService) NewPager(params *ContactListParams) *Pager[Contact]

NewPager returns a pager that retrieves all contact pages.

func (*ContactsService) Subscribe

func (service *ContactsService) Subscribe(ctx context.Context, identifier string) (*Contact, error)

Subscribe subscribes a contact by UUID or workspace identity value.

func (*ContactsService) Unsubscribe

func (service *ContactsService) Unsubscribe(ctx context.Context, identifier string) (*Contact, error)

Unsubscribe unsubscribes a contact by UUID or workspace identity value.

func (*ContactsService) Update

func (service *ContactsService) Update(ctx context.Context, identifier string, params UpdateContactParams) (*Contact, error)

Update updates a contact by UUID or workspace identity value.

type CreateContactEventParams

type CreateContactEventParams struct {
	EventName  string
	Attributes ContactEventAttributes
}

CreateContactEventParams is accepted by ContactEventsService.Create.

type CreateContactParams

type CreateContactParams struct {
	Attributes Attributes `json:"attributes"`
	Subscribed *bool      `json:"subscribed,omitzero"`
}

CreateContactParams is accepted by ContactsService.Create.

type CreateDomainAddressParams

type CreateDomainAddressParams struct {
	Address         string           `json:"address"`
	DisplayName     string           `json:"display_name"`
	ReplyTo         string           `json:"reply_to"`
	CompanyAddress  string           `json:"company_address"`
	CompanyAddress2 Optional[string] `json:"company_address_2,omitzero"`
	CompanyCity     string           `json:"company_city"`
	CompanyState    string           `json:"company_state"`
	CompanyZIP      string           `json:"company_zip"`
	CompanyCountry  string           `json:"company_country"`
}

CreateDomainAddressParams is accepted by DomainAddressesService.Create.

type CreateDomainParams

type CreateDomainParams struct {
	Name              string                       `json:"name"`
	DKIMSelectors     Optional[[]string]           `json:"dkim_selectors,omitzero"`
	TrackingSubdomain Optional[string]             `json:"tracking_subdomain,omitzero"`
	TrackingMode      Optional[DomainTrackingMode] `json:"tracking_mode,omitzero"`
}

CreateDomainParams is accepted by DomainsService.Create.

type CreateFieldParams

type CreateFieldParams struct {
	Name   string                `json:"name"`
	Type   FieldType             `json:"type"`
	Format Optional[FieldFormat] `json:"format,omitzero"`
}

CreateFieldParams is accepted by FieldsService.Create.

type CreateSuppressionParams

type CreateSuppressionParams struct {
	Email string           `json:"email"`
	Type  *SuppressionType `json:"type,omitzero"`
}

CreateSuppressionParams is accepted by SuppressionsService.Create.

type Domain

type Domain struct {
	UUID             string             `json:"uuid"`
	Name             string             `json:"name"`
	Domain           string             `json:"domain"`
	Verified         bool               `json:"verified"`
	Provider         DomainProvider     `json:"provider"`
	Status           DomainStatus       `json:"status"`
	Verification     DomainVerification `json:"verification"`
	MailFromDomain   string             `json:"mail_from_domain"`
	MailFromVerified bool               `json:"mail_from_verified"`
	DNS              []DomainDNSRecord  `json:"dns"`
	UpdatedAt        time.Time          `json:"updated_at"`
	CreatedAt        time.Time          `json:"created_at"`
}

Domain is returned by domain endpoints.

type DomainAddress

type DomainAddress struct {
	UUID         string             `json:"uuid"`
	DomainUUID   string             `json:"domain_uuid"`
	Address      string             `json:"address"`
	FullAddress  string             `json:"full_address"`
	Provider     *DomainProvider    `json:"provider"`
	DisplayName  string             `json:"display_name"`
	Verification DomainVerification `json:"verification"`
	UpdatedAt    time.Time          `json:"updated_at"`
	CreatedAt    time.Time          `json:"created_at"`
}

DomainAddress is returned by nested domain address endpoints.

type DomainAddressListParams

type DomainAddressListParams struct {
	Page    int
	PerPage int
}

DomainAddressListParams configures a domain address list request.

type DomainAddressesService

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

DomainAddressesService provides nested domain address API operations.

func (*DomainAddressesService) Create

Create creates a domain address.

func (*DomainAddressesService) Delete

func (service *DomainAddressesService) Delete(ctx context.Context, uuid string) error

Delete deletes a domain address by UUID.

func (*DomainAddressesService) Get

func (service *DomainAddressesService) Get(ctx context.Context, uuid string) (*DomainAddress, error)

Get retrieves a domain address by UUID.

func (*DomainAddressesService) List

List retrieves one page of domain addresses.

func (*DomainAddressesService) NewPager

NewPager returns a pager that retrieves all domain address pages.

type DomainDNSRecord

type DomainDNSRecord struct {
	Type    string `json:"type"`
	Name    string `json:"name"`
	Value   string `json:"value"`
	IsValid bool   `json:"is_valid"`
}

DomainDNSRecord describes a DNS record required for domain verification.

type DomainListParams

type DomainListParams struct {
	Page    int
	PerPage int
	Search  string
}

DomainListParams configures a domain list request.

type DomainProvider

type DomainProvider string

DomainProvider identifies the provider backing a domain or address.

const (
	DomainProviderAWS      DomainProvider = "aws"
	DomainProviderLeadpush DomainProvider = "leadpush"
)

type DomainStatus

type DomainStatus string

DomainStatus describes the lifecycle status of a domain.

const (
	DomainStatusPending DomainStatus = "pending"
)

type DomainTrackingMode

type DomainTrackingMode string

DomainTrackingMode configures tracking DNS behavior.

const (
	DomainTrackingModeDirect     DomainTrackingMode = "direct"
	DomainTrackingModeCloudflare DomainTrackingMode = "cloudflare"
)

type DomainVerification

type DomainVerification string

DomainVerification describes domain or address verification status.

const (
	DomainVerificationPending   DomainVerification = "pending"
	DomainVerificationCompleted DomainVerification = "completed"
	DomainVerificationFailed    DomainVerification = "failed"
)

type DomainsService

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

DomainsService provides domain API operations.

func (*DomainsService) Addresses

func (service *DomainsService) Addresses(uuid string) *DomainAddressesService

Addresses returns address operations for a domain UUID.

func (*DomainsService) Create

func (service *DomainsService) Create(ctx context.Context, params CreateDomainParams) (*Domain, error)

Create creates a domain.

func (*DomainsService) Delete

func (service *DomainsService) Delete(ctx context.Context, uuid string) error

Delete deletes a domain by UUID.

func (*DomainsService) Get

func (service *DomainsService) Get(ctx context.Context, uuid string) (*Domain, error)

Get retrieves a domain by UUID.

func (*DomainsService) List

func (service *DomainsService) List(ctx context.Context, params *DomainListParams) (*Page[Domain], error)

List retrieves one page of domains.

func (*DomainsService) NewPager

func (service *DomainsService) NewPager(params *DomainListParams) *Pager[Domain]

NewPager returns a pager that retrieves all domain pages.

func (*DomainsService) Verify

func (service *DomainsService) Verify(ctx context.Context, uuid string) (*Domain, error)

Verify refreshes domain verification status.

type EmailRecipientType

type EmailRecipientType string

EmailRecipientType identifies a per-recipient message category.

const (
	EmailRecipientTypeTo  EmailRecipientType = "to"
	EmailRecipientTypeBCC EmailRecipientType = "bcc"
)

type EmailSend

type EmailSend struct {
	Accepted     bool               `json:"accepted"`
	MessageCount int                `json:"message_count"`
	Messages     []EmailSendMessage `json:"messages"`
}

EmailSend describes an accepted email send.

type EmailSendMessage

type EmailSendMessage struct {
	UUID      string             `json:"uuid"`
	Recipient string             `json:"recipient"`
	Type      EmailRecipientType `json:"type"`
	From      string             `json:"from"`
	Status    string             `json:"status"`
}

EmailSendMessage describes a per-recipient message accepted for delivery.

type EmailsService

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

EmailsService provides email sending API operations.

func (*EmailsService) Send

func (service *EmailsService) Send(ctx context.Context, params SendEmailParams) (*EmailSend, error)

Send queues an email for delivery.

type Field

type Field struct {
	UUID      string       `json:"uuid"`
	Name      string       `json:"name"`
	Type      FieldType    `json:"type"`
	Format    *FieldFormat `json:"format"`
	CreatedAt time.Time    `json:"created_at"`
}

Field is returned by custom field endpoints.

type FieldFilter

type FieldFilter struct {
	ID    FieldFilterID `json:"id"`
	Value []FieldType   `json:"value"`
}

FieldFilter configures one API field-list filter.

type FieldFilterID

type FieldFilterID string

FieldFilterID identifies a supported field list filter.

const (
	FieldFilterIDType FieldFilterID = "type"
)

type FieldFormat

type FieldFormat struct {
	Text      *FieldTextFormat `json:"text,omitzero"`
	Pattern   *string          `json:"pattern,omitzero"`
	ISOFormat *string          `json:"iso_format,omitzero"`
}

FieldFormat describes optional field format settings.

type FieldListParams

type FieldListParams struct {
	Page    int
	PerPage int
	Search  string
	Filters []FieldFilter
}

FieldListParams configures a field list request.

type FieldTextFormat

type FieldTextFormat string

FieldTextFormat configures validation for text fields.

const (
	FieldTextFormatEmail FieldTextFormat = "email"
	FieldTextFormatPhone FieldTextFormat = "phone"
	FieldTextFormatUUID  FieldTextFormat = "uuid"
	FieldTextFormatURL   FieldTextFormat = "url"
	FieldTextFormatRegex FieldTextFormat = "regex"
)

type FieldType

type FieldType string

FieldType is a custom contact field data type.

const (
	FieldTypeInteger  FieldType = "integer"
	FieldTypeText     FieldType = "text"
	FieldTypeDate     FieldType = "date"
	FieldTypeDateTime FieldType = "datetime"
	FieldTypeBoolean  FieldType = "boolean"
)

type FieldsService

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

FieldsService provides custom field API operations.

func (*FieldsService) Create

func (service *FieldsService) Create(ctx context.Context, params CreateFieldParams) (*Field, error)

Create creates a custom field.

func (*FieldsService) Get

func (service *FieldsService) Get(ctx context.Context, uuid string) (*Field, error)

Get retrieves a custom field by UUID.

func (*FieldsService) List

func (service *FieldsService) List(ctx context.Context, params *FieldListParams) (*Page[Field], error)

List retrieves one page of custom fields.

func (*FieldsService) NewPager

func (service *FieldsService) NewPager(params *FieldListParams) *Pager[Field]

NewPager returns a pager that retrieves all custom field pages.

func (*FieldsService) Update

func (service *FieldsService) Update(ctx context.Context, uuid string, params UpdateFieldParams) (*Field, error)

Update updates a custom field by UUID.

type HTTPClient

type HTTPClient interface {
	Do(*http.Request) (*http.Response, error)
}

HTTPClient is implemented by *http.Client and compatible custom transports.

type Option

type Option func(*clientConfig)

Option configures a Client.

func WithBaseURL

func WithBaseURL(baseURL string) Option

WithBaseURL overrides the Leadpush API base URL.

func WithHTTPClient

func WithHTTPClient(client HTTPClient) Option

WithHTTPClient uses client for requests. The client remains caller-owned.

func WithHeaders

func WithHeaders(headers map[string]string) Option

WithHeaders adds headers to every request. The input map is copied. SDK-owned authentication, version, user-agent, and content headers take precedence.

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout overrides the per-request SDK timeout. A zero duration disables the SDK timeout. Negative durations are rejected by New.

func WithUserAgent

func WithUserAgent(userAgent string) Option

WithUserAgent overrides the default SDK user agent.

type Optional

type Optional[T any] struct {
	// contains filtered or unexported fields
}

Optional represents a JSON property that can be omitted, set to a value, or explicitly set to null. Its zero value is omitted by fields tagged with json:",omitzero".

func Null

func Null[T any]() Optional[T]

Null returns an Optional explicitly set to JSON null.

func Some

func Some[T any](value T) Optional[T]

Some returns an Optional set to value.

func (Optional[T]) IsNull

func (o Optional[T]) IsNull() bool

IsNull reports whether the property was explicitly set to null.

func (Optional[T]) IsSet

func (o Optional[T]) IsSet() bool

IsSet reports whether the property was set, including when it was set to null.

func (Optional[T]) IsZero

func (o Optional[T]) IsZero() bool

IsZero reports whether the property is unset and should be omitted.

func (Optional[T]) MarshalJSON

func (o Optional[T]) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*Optional[T]) UnmarshalJSON

func (o *Optional[T]) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (Optional[T]) Value

func (o Optional[T]) Value() (T, bool)

Value returns the configured value and true when the property contains a non-null value.

type Page

type Page[T any] struct {
	Data []T            `json:"data"`
	Meta PaginationMeta `json:"meta"`
}

Page contains one page of API resources and its pagination metadata.

type Pager

type Pager[T any] struct {
	// contains filtered or unexported fields
}

Pager retrieves consecutive pages from a list endpoint.

func (*Pager[T]) Err

func (p *Pager[T]) Err() error

Err returns the first error encountered by the pager.

func (*Pager[T]) Next

func (p *Pager[T]) Next(ctx context.Context) bool

Next retrieves the next page. It returns false after the final page or when a request fails. Inspect Err after iteration.

func (*Pager[T]) Page

func (p *Pager[T]) Page() *Page[T]

Page returns the most recently retrieved page, or nil before the first successful call to Next.

type PaginationError

type PaginationError struct {
	CurrentPage   int
	RequestedPage int
}

PaginationError indicates that a paginated response did not advance its current page and automatic pagination was stopped to prevent a loop.

func (*PaginationError) Error

func (e *PaginationError) Error() string

Error implements error.

type PaginationMeta

type PaginationMeta struct {
	CurrentPage int  `json:"current_page"`
	PerPage     int  `json:"per_page"`
	Total       int  `json:"total"`
	LastPage    int  `json:"last_page"`
	HasNext     bool `json:"has_next"`
}

PaginationMeta describes one page returned by the Leadpush API.

type Request

type Request struct {
	Method string
	Path   []string
	Query  map[string]any
	Body   any
}

Request describes a low-level Leadpush API request.

type SendEmailParams

type SendEmailParams struct {
	From    string            `json:"from"`
	Subject string            `json:"subject"`
	HTML    *string           `json:"html,omitzero"`
	Text    *string           `json:"text,omitzero"`
	To      []string          `json:"to,omitzero"`
	BCC     []string          `json:"bcc,omitzero"`
	ReplyTo *string           `json:"reply_to,omitzero"`
	Headers map[string]string `json:"headers,omitzero"`
}

SendEmailParams is accepted by EmailsService.Send.

type Suppression

type Suppression struct {
	UUID      string          `json:"uuid"`
	Email     string          `json:"email"`
	Type      SuppressionType `json:"type"`
	CreatedAt time.Time       `json:"created_at"`
}

Suppression is returned by suppression endpoints.

type SuppressionFilter

type SuppressionFilter struct {
	ID    SuppressionFilterID `json:"id"`
	Value []SuppressionType   `json:"value"`
}

SuppressionFilter configures one API suppression-list filter.

type SuppressionFilterID

type SuppressionFilterID string

SuppressionFilterID identifies a supported suppression list filter.

const (
	SuppressionFilterIDType SuppressionFilterID = "type"
)

type SuppressionListParams

type SuppressionListParams struct {
	Page    int
	PerPage int
	Search  string
	Filters []SuppressionFilter
}

SuppressionListParams configures a suppression list request.

type SuppressionType

type SuppressionType string

SuppressionType identifies why an email address is suppressed.

const (
	SuppressionTypeBounce    SuppressionType = "bounce"
	SuppressionTypeComplaint SuppressionType = "complaint"
	SuppressionTypeManual    SuppressionType = "manual"
)

type SuppressionsService

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

SuppressionsService provides suppression API operations.

func (*SuppressionsService) Create

Create creates a suppression.

func (*SuppressionsService) Get

func (service *SuppressionsService) Get(ctx context.Context, uuid string) (*Suppression, error)

Get retrieves a suppression by UUID.

func (*SuppressionsService) List

List retrieves one page of suppressions.

func (*SuppressionsService) NewPager

func (service *SuppressionsService) NewPager(params *SuppressionListParams) *Pager[Suppression]

NewPager returns a pager that retrieves all suppression pages.

type TimeoutError

type TimeoutError struct {
	Timeout time.Duration
	Err     error
}

TimeoutError is returned when the SDK's configured request timeout expires.

func (*TimeoutError) Error

func (e *TimeoutError) Error() string

Error implements error.

func (*TimeoutError) Unwrap

func (e *TimeoutError) Unwrap() error

Unwrap returns the underlying context deadline error.

type UpdateContactParams

type UpdateContactParams struct {
	Attributes Attributes `json:"attributes,omitzero"`
	Subscribed *bool      `json:"subscribed,omitzero"`
}

UpdateContactParams is accepted by ContactsService.Update.

type UpdateFieldParams

type UpdateFieldParams struct {
	Name   *string               `json:"name,omitzero"`
	Type   *FieldType            `json:"type,omitzero"`
	Format Optional[FieldFormat] `json:"format,omitzero"`
}

UpdateFieldParams is accepted by FieldsService.Update.

Jump to

Keyboard shortcuts

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