Documentation
¶
Index ¶
- Constants
- func MapError(status int, body map[string]interface{}, retryAfter float64) error
- func VerifyWebhook(payload string, headers map[string]string, secret string, ...) (map[string]interface{}, error)
- type BatchTrackResponse
- type BulkContactResponse
- type Client
- func (c *Client) BaseURL() string
- func (c *Client) Identify(params IdentifyParams) (*ContactResponse, error)
- func (c *Client) IdentifyBatch(params IdentifyBatchParams) (*BulkContactResponse, error)
- func (c *Client) Send(params SendParams) (*SendResponse, error)
- func (c *Client) Track(params TrackParams) (*TrackResponse, error)
- func (c *Client) TrackBatch(params TrackBatchParams) (*BatchTrackResponse, error)
- type Config
- type ContactListMeta
- type ContactListParams
- type ContactListResponse
- type ContactResponse
- type ContactUpdateParams
- type ContactsClient
- func (cc *ContactsClient) Delete(externalID string) error
- func (cc *ContactsClient) Get(contactID string) (*ContactResponse, error)
- func (cc *ContactsClient) List(params ContactListParams) (*ContactListResponse, error)
- func (cc *ContactsClient) Update(externalID string, params ContactUpdateParams) (*ContactResponse, error)
- type IdentifyBatchParams
- type IdentifyParams
- type SendParams
- type SendResponse
- type SynapseAuthError
- type SynapseError
- type SynapsePlanLimitError
- type SynapseRateLimitError
- type SynapseValidationError
- type TemplateCreateParams
- type TemplatePreviewParams
- type TemplatePreviewResponse
- type TemplateResponse
- type TemplateUpdateParams
- type TemplatesClient
- func (tc *TemplatesClient) Create(params TemplateCreateParams) (*TemplateResponse, error)
- func (tc *TemplatesClient) Delete(slug string) error
- func (tc *TemplatesClient) Get(slug string) (*TemplateResponse, error)
- func (tc *TemplatesClient) List() ([]TemplateResponse, error)
- func (tc *TemplatesClient) Preview(slug string, params TemplatePreviewParams) (*TemplatePreviewResponse, error)
- func (tc *TemplatesClient) Update(slug string, params TemplateUpdateParams) (*TemplateResponse, error)
- type TrackBatchParams
- type TrackParams
- type TrackResponse
- type ValidationFieldError
Constants ¶
const Version = "0.1.0"
Version is the SDK version string.
Variables ¶
This section is empty.
Functions ¶
func VerifyWebhook ¶
func VerifyWebhook(payload string, headers map[string]string, secret string, disableTimestampCheck bool) (map[string]interface{}, error)
VerifyWebhook verifies a webhook signature from Synapse (Svix format) and returns the parsed payload. Set disableTimestampCheck to true to skip timestamp tolerance validation (for testing only).
Types ¶
type BatchTrackResponse ¶
BatchTrackResponse is the response from a batch track call.
type BulkContactResponse ¶
type BulkContactResponse struct {
Total int `json:"total"`
Created int `json:"created"`
Updated int `json:"updated"`
Skipped int `json:"skipped"`
Errors []map[string]interface{} `json:"errors"`
}
BulkContactResponse is the response from a bulk contact operation.
type Client ¶
type Client struct {
Environment string
Contacts *ContactsClient
Templates *TemplatesClient
// contains filtered or unexported fields
}
Client is the main Synapse API client.
func (*Client) Identify ¶
func (c *Client) Identify(params IdentifyParams) (*ContactResponse, error)
Identify creates or updates a contact.
func (*Client) IdentifyBatch ¶
func (c *Client) IdentifyBatch(params IdentifyBatchParams) (*BulkContactResponse, error)
IdentifyBatch creates or updates multiple contacts.
func (*Client) Send ¶
func (c *Client) Send(params SendParams) (*SendResponse, error)
Send sends an email using a template.
func (*Client) Track ¶
func (c *Client) Track(params TrackParams) (*TrackResponse, error)
Track tracks a single event.
func (*Client) TrackBatch ¶
func (c *Client) TrackBatch(params TrackBatchParams) (*BatchTrackResponse, error)
TrackBatch tracks multiple events in a single request.
type Config ¶
type Config struct {
APIKey string
WorkspaceID string
BaseURL string // default: "https://synapse-api.pyrx.tech"
Timeout time.Duration // default: 30s
MaxRetries int // default: 3
}
Config holds the configuration for a Synapse client.
type ContactListMeta ¶
type ContactListMeta struct {
Total int `json:"total"`
Page int `json:"page"`
PerPage int `json:"per_page"`
TotalPages int `json:"total_pages"`
}
ContactListMeta holds pagination metadata.
type ContactListParams ¶
ContactListParams holds the query parameters for listing contacts.
type ContactListResponse ¶
type ContactListResponse struct {
Data []ContactResponse `json:"data"`
Meta ContactListMeta `json:"meta"`
}
ContactListResponse is the response from listing contacts.
type ContactResponse ¶
type ContactResponse struct {
ID string `json:"id"`
ExternalID string `json:"external_id"`
Email string `json:"email"`
Phone string `json:"phone"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
Timezone string `json:"timezone"`
Locale string `json:"locale"`
Properties map[string]interface{} `json:"properties"`
Tags []string `json:"tags"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
ContactResponse is the response containing contact data.
type ContactUpdateParams ¶
type ContactUpdateParams struct {
Email string `json:"email,omitempty"`
Properties map[string]interface{} `json:"properties,omitempty"`
Tags []string `json:"tags,omitempty"`
AddTags []string `json:"add_tags,omitempty"`
RemoveTags []string `json:"remove_tags,omitempty"`
}
ContactUpdateParams holds the parameters for updating a contact.
type ContactsClient ¶
type ContactsClient struct {
// contains filtered or unexported fields
}
ContactsClient provides methods for managing contacts.
func (*ContactsClient) Delete ¶
func (cc *ContactsClient) Delete(externalID string) error
Delete removes a contact by external ID.
func (*ContactsClient) Get ¶
func (cc *ContactsClient) Get(contactID string) (*ContactResponse, error)
Get retrieves a single contact by ID.
func (*ContactsClient) List ¶
func (cc *ContactsClient) List(params ContactListParams) (*ContactListResponse, error)
List returns a paginated list of contacts.
func (*ContactsClient) Update ¶
func (cc *ContactsClient) Update(externalID string, params ContactUpdateParams) (*ContactResponse, error)
Update updates a contact by external ID.
type IdentifyBatchParams ¶
type IdentifyBatchParams struct {
Contacts []IdentifyParams `json:"contacts"`
OnConflict string `json:"on_conflict,omitempty"`
}
IdentifyBatchParams holds the parameters for batch identifying contacts.
type IdentifyParams ¶
type IdentifyParams struct {
ExternalID string `json:"external_id"`
Email string `json:"email,omitempty"`
Phone string `json:"phone,omitempty"`
FirstName string `json:"first_name,omitempty"`
LastName string `json:"last_name,omitempty"`
Timezone string `json:"timezone,omitempty"`
Locale string `json:"locale,omitempty"`
Properties map[string]interface{} `json:"properties,omitempty"`
Tags []string `json:"tags,omitempty"`
}
IdentifyParams holds the parameters for identifying a contact.
type SendParams ¶
type SendParams struct {
TemplateSlug string `json:"template_slug"`
To map[string]interface{} `json:"to"`
Attributes map[string]interface{} `json:"attributes,omitempty"`
IdempotencyKey string `json:"idempotency_key,omitempty"`
}
SendParams holds the parameters for sending an email.
type SendResponse ¶
SendResponse is the response from a send email call.
type SynapseAuthError ¶
type SynapseAuthError struct {
SynapseError
}
SynapseAuthError is raised on 401 Unauthorized or 403 Forbidden.
type SynapseError ¶
SynapseError is the base error for all Synapse API errors.
func (*SynapseError) Error ¶
func (e *SynapseError) Error() string
type SynapsePlanLimitError ¶
type SynapsePlanLimitError struct {
SynapseError
LimitType string
Current int
Maximum int
Plan string
}
SynapsePlanLimitError is raised on 403 with code "plan_limit_reached".
type SynapseRateLimitError ¶
type SynapseRateLimitError struct {
SynapseError
RetryAfter float64
}
SynapseRateLimitError is raised on 429 Too Many Requests.
type SynapseValidationError ¶
type SynapseValidationError struct {
SynapseError
Errors []ValidationFieldError
}
SynapseValidationError is raised on 422 Unprocessable Entity.
type TemplateCreateParams ¶
type TemplateCreateParams struct {
Name string `json:"name"`
Slug string `json:"slug"`
Subject string `json:"subject"`
BodyHTML string `json:"body_html"`
SenderName string `json:"sender_name"`
FromEmail string `json:"from_email"`
ReplyTo string `json:"reply_to,omitempty"`
}
TemplateCreateParams holds the parameters for creating a template.
type TemplatePreviewParams ¶
type TemplatePreviewParams struct {
Contact map[string]interface{} `json:"contact,omitempty"`
TriggerEvent map[string]interface{} `json:"trigger_event,omitempty"`
AdditionalEvents []map[string]interface{} `json:"additional_events,omitempty"`
}
TemplatePreviewParams holds the parameters for previewing a template.
type TemplatePreviewResponse ¶
type TemplatePreviewResponse struct {
Subject string `json:"subject"`
HTML string `json:"html"`
Suppressed bool `json:"suppressed"`
SuppressedReason string `json:"suppressed_reason"`
}
TemplatePreviewResponse is the response from previewing a template.
type TemplateResponse ¶
type TemplateResponse struct {
ID string `json:"id"`
Name string `json:"name"`
Slug string `json:"slug"`
Subject string `json:"subject"`
BodyHTML string `json:"body_html"`
SenderName string `json:"sender_name"`
FromEmail string `json:"from_email"`
ReplyTo string `json:"reply_to"`
ContentType string `json:"content_type"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
TemplateResponse is the response containing template data.
type TemplateUpdateParams ¶
type TemplateUpdateParams struct {
Name string `json:"name,omitempty"`
Subject string `json:"subject,omitempty"`
BodyHTML string `json:"body_html,omitempty"`
SenderName string `json:"sender_name,omitempty"`
FromEmail string `json:"from_email,omitempty"`
}
TemplateUpdateParams holds the parameters for updating a template.
type TemplatesClient ¶
type TemplatesClient struct {
// contains filtered or unexported fields
}
TemplatesClient provides methods for managing email templates.
func (*TemplatesClient) Create ¶
func (tc *TemplatesClient) Create(params TemplateCreateParams) (*TemplateResponse, error)
Create creates a new email template.
func (*TemplatesClient) Delete ¶
func (tc *TemplatesClient) Delete(slug string) error
Delete removes a template by slug.
func (*TemplatesClient) Get ¶
func (tc *TemplatesClient) Get(slug string) (*TemplateResponse, error)
Get retrieves a single template by slug.
func (*TemplatesClient) List ¶
func (tc *TemplatesClient) List() ([]TemplateResponse, error)
List returns all email templates.
func (*TemplatesClient) Preview ¶
func (tc *TemplatesClient) Preview(slug string, params TemplatePreviewParams) (*TemplatePreviewResponse, error)
Preview renders a template with sample data.
func (*TemplatesClient) Update ¶
func (tc *TemplatesClient) Update(slug string, params TemplateUpdateParams) (*TemplateResponse, error)
Update updates an existing template by slug.
type TrackBatchParams ¶
type TrackBatchParams struct {
Events []TrackParams `json:"events"`
}
TrackBatchParams holds the parameters for tracking multiple events.
type TrackParams ¶
type TrackParams struct {
ExternalID string `json:"external_id"`
EventName string `json:"event_name"`
Attributes map[string]interface{} `json:"attributes,omitempty"`
Contact map[string]interface{} `json:"contact,omitempty"`
IdempotencyKey string `json:"idempotency_key,omitempty"`
OccurredAt string `json:"occurred_at,omitempty"`
}
TrackParams holds the parameters for tracking an event.
type TrackResponse ¶
TrackResponse is the response from tracking a single event.
type ValidationFieldError ¶
ValidationFieldError represents a single field validation error.