loops

package module
v0.0.0-...-1b9afc3 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2023 License: MIT Imports: 7 Imported by: 0

README

loops-go

A small go sdk for loops.

Currently supports:

  • Contact create, update, and delete.
  • Sending events.
  • Initiating transactional emails.

Feel free to make a PR if you want to add more functionality.

Documentation

Index

Constants

View Source
const DefaultEndpoint = "https://app.loops.so/api/v1"

DefaultEndpoint is the default endpoint used for the Loops API.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client implements the Loops API for a given API Key / endpoint.

func NewClient

func NewClient(apiKey string) *Client

NewClient creates a new Client object.

func (*Client) CreateContact

func (c *Client) CreateContact(
	ctx context.Context,
	email string,

	fields map[string]interface{},
) (*CreateContactResponse, error)

CreateContact creates a new contact in Loops.

func (*Client) DeleteContact

func (c *Client) DeleteContact(ctx context.Context, email string) (*DeleteContactResponse, error)

DeleteContact deletes a contact from Loops.

func (*Client) SendEvent

func (c *Client) SendEvent(ctx context.Context, req SendEventRequest) (*SendEventResponse, error)

Send Event sends an event Loop to a contact. WARNING: This will create a contact if it doesn't exist.

func (*Client) SendTransactional

SendTransactional sends a transactional Loop to a contact. DataVariables is an optional map of data variables to be used in the Loop.

func (*Client) UpsertContact

func (c *Client) UpsertContact(ctx context.Context, email string, fields map[string]interface{}) (*UpsertContactResponse, error)

UpsertContact updates or creates a contact in Loops.

func (*Client) WithEndpoint

func (c *Client) WithEndpoint(endpoint string) *Client

WithEndpoint attaches a non-default endpoint to the Client. This is generally used with dedicated, or non-serverless deployments.

func (*Client) WithHTTPClient

func (c *Client) WithHTTPClient(client *http.Client) *Client

WithHTTPClient attaches a non-default HTTP client to the Client.

type CreateContactResponse

type CreateContactResponse struct {
	Success bool   `json:"success"`
	ID      string `json:"id"`
}

type DeleteContactResponse

type DeleteContactResponse struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
}

type SendEventRequest

type SendEventRequest struct {
	Email     string `json:"email"`
	EventName string `json:"eventName"`
}

type SendEventResponse

type SendEventResponse struct {
	Success bool `json:"success"`
}

type SendTransactionalRequest

type SendTransactionalRequest struct {
	Email           string                 `json:"email"`
	TransactionalID string                 `json:"transactionalId"`
	DataVariables   map[string]interface{} `json:"dataVariables"`
}

type SendTransactionalResponse

type SendTransactionalResponse struct {
	Success bool `json:"success"`
}

type UpsertContactResponse

type UpsertContactResponse struct {
	Success bool   `json:"success"`
	ID      string `json:"id"`
}

Jump to

Keyboard shortcuts

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