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
- func IsForbidden(err error) bool
- func IsNotFound(err error) bool
- func IsUnauthorized(err error) bool
- func IsValidation(err error) bool
- func Ptr[T any](value T) *T
- type APIError
- type Attributes
- type Client
- func (c *Client) Delete(ctx context.Context, path []string, query map[string]any, result any) error
- func (c *Client) Do(ctx context.Context, request Request, result any) error
- func (c *Client) Get(ctx context.Context, path []string, query map[string]any, result any) error
- func (c *Client) Post(ctx context.Context, path []string, body any, query map[string]any, result any) error
- type Contact
- type ContactEvent
- type ContactEventAttributes
- type ContactEventListParams
- type ContactEventsService
- func (service *ContactEventsService) Create(ctx context.Context, params CreateContactEventParams) error
- func (service *ContactEventsService) List(ctx context.Context, params *ContactEventListParams) (*Page[ContactEvent], error)
- func (service *ContactEventsService) NewPager(params *ContactEventListParams) *Pager[ContactEvent]
- type ContactListParams
- type ContactsService
- func (service *ContactsService) Create(ctx context.Context, params CreateContactParams) (*Contact, error)
- func (service *ContactsService) Events(identifier string) *ContactEventsService
- func (service *ContactsService) Get(ctx context.Context, identifier string) (*Contact, error)
- func (service *ContactsService) List(ctx context.Context, params *ContactListParams) (*Page[Contact], error)
- func (service *ContactsService) NewPager(params *ContactListParams) *Pager[Contact]
- func (service *ContactsService) Subscribe(ctx context.Context, identifier string) (*Contact, error)
- func (service *ContactsService) Unsubscribe(ctx context.Context, identifier string) (*Contact, error)
- func (service *ContactsService) Update(ctx context.Context, identifier string, params UpdateContactParams) (*Contact, error)
- type CreateContactEventParams
- type CreateContactParams
- type CreateDomainAddressParams
- type CreateDomainParams
- type CreateFieldParams
- type CreateSuppressionParams
- type Domain
- type DomainAddress
- type DomainAddressListParams
- type DomainAddressesService
- func (service *DomainAddressesService) Create(ctx context.Context, params CreateDomainAddressParams) (*DomainAddress, error)
- func (service *DomainAddressesService) Delete(ctx context.Context, uuid string) error
- func (service *DomainAddressesService) Get(ctx context.Context, uuid string) (*DomainAddress, error)
- func (service *DomainAddressesService) List(ctx context.Context, params *DomainAddressListParams) (*Page[DomainAddress], error)
- func (service *DomainAddressesService) NewPager(params *DomainAddressListParams) *Pager[DomainAddress]
- type DomainDNSRecord
- type DomainListParams
- type DomainProvider
- type DomainStatus
- type DomainTrackingMode
- type DomainVerification
- type DomainsService
- func (service *DomainsService) Addresses(uuid string) *DomainAddressesService
- func (service *DomainsService) Create(ctx context.Context, params CreateDomainParams) (*Domain, error)
- func (service *DomainsService) Delete(ctx context.Context, uuid string) error
- func (service *DomainsService) Get(ctx context.Context, uuid string) (*Domain, error)
- func (service *DomainsService) List(ctx context.Context, params *DomainListParams) (*Page[Domain], error)
- func (service *DomainsService) NewPager(params *DomainListParams) *Pager[Domain]
- func (service *DomainsService) Verify(ctx context.Context, uuid string) (*Domain, error)
- type EmailRecipientType
- type EmailSend
- type EmailSendMessage
- type EmailsService
- type Field
- type FieldFilter
- type FieldFilterID
- type FieldFormat
- type FieldListParams
- type FieldTextFormat
- type FieldType
- type FieldsService
- func (service *FieldsService) Create(ctx context.Context, params CreateFieldParams) (*Field, error)
- func (service *FieldsService) Get(ctx context.Context, uuid string) (*Field, error)
- func (service *FieldsService) List(ctx context.Context, params *FieldListParams) (*Page[Field], error)
- func (service *FieldsService) NewPager(params *FieldListParams) *Pager[Field]
- func (service *FieldsService) Update(ctx context.Context, uuid string, params UpdateFieldParams) (*Field, error)
- type HTTPClient
- type Option
- type Optional
- type Page
- type Pager
- type PaginationError
- type PaginationMeta
- type Request
- type SendEmailParams
- type Suppression
- type SuppressionFilter
- type SuppressionFilterID
- type SuppressionListParams
- type SuppressionType
- type SuppressionsService
- func (service *SuppressionsService) Create(ctx context.Context, params CreateSuppressionParams) (*Suppression, error)
- func (service *SuppressionsService) Get(ctx context.Context, uuid string) (*Suppression, error)
- func (service *SuppressionsService) List(ctx context.Context, params *SuppressionListParams) (*Page[Suppression], error)
- func (service *SuppressionsService) NewPager(params *SuppressionListParams) *Pager[Suppression]
- type TimeoutError
- type UpdateContactParams
- type UpdateFieldParams
Constants ¶
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 + ")" )
const DefaultTimeout = 30 * time.Second
DefaultTimeout is the default maximum duration of an API request.
Variables ¶
This section is empty.
Functions ¶
func IsForbidden ¶
IsForbidden reports whether err is an API error with status 403.
func IsNotFound ¶
IsNotFound reports whether err is an API error with status 404.
func IsUnauthorized ¶
IsUnauthorized reports whether err is an API error with status 401.
func IsValidation ¶
IsValidation reports whether err is an API error with status 422.
Types ¶
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 (*Client) Do ¶
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.
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 ¶
ContactEventAttributes contains arbitrary event metadata.
type ContactEventListParams ¶
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 ¶
func (service *ContactEventsService) List(ctx context.Context, params *ContactEventListParams) (*Page[ContactEvent], error)
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 ¶
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) 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 ¶
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 ¶
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 ¶
func (service *DomainAddressesService) Create(ctx context.Context, params CreateDomainAddressParams) (*DomainAddress, error)
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 ¶
func (service *DomainAddressesService) List(ctx context.Context, params *DomainAddressListParams) (*Page[DomainAddress], error)
List retrieves one page of domain addresses.
func (*DomainAddressesService) NewPager ¶
func (service *DomainAddressesService) NewPager(params *DomainAddressListParams) *Pager[DomainAddress]
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 ¶
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) 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.
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 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) 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 ¶
HTTPClient is implemented by *http.Client and compatible custom transports.
type Option ¶
type Option func(*clientConfig)
Option configures a Client.
func WithBaseURL ¶
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 ¶
WithHeaders adds headers to every request. The input map is copied. SDK-owned authentication, version, user-agent, and content headers take precedence.
func WithTimeout ¶
WithTimeout overrides the per-request SDK timeout. A zero duration disables the SDK timeout. Negative durations are rejected by New.
func WithUserAgent ¶
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 (Optional[T]) IsSet ¶
IsSet reports whether the property was set, including when it was set to null.
func (Optional[T]) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (*Optional[T]) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
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.
type PaginationError ¶
PaginationError indicates that a paginated response did not advance its current page and automatic pagination was stopped to prevent a loop.
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 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 ¶
func (service *SuppressionsService) Create(ctx context.Context, params CreateSuppressionParams) (*Suppression, error)
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 ¶
func (service *SuppressionsService) List(ctx context.Context, params *SuppressionListParams) (*Page[Suppression], error)
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 ¶
TimeoutError is returned when the SDK's configured request timeout expires.
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.