outreach

package
v0.0.0-...-b99b532 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2024 License: MIT Imports: 10 Imported by: 0

README

Outreach connector

Read

Read is used to list all records of a given type. For example, if you want to list all users, you would use the Read method with the users object.

Example Usage

// Create the outreach connector instance 
// This assumes you called the instance client

// Call Read to list records in a users object
res, err := client.Read(context.TODO(),common.ReadParams{
		ObjectName: "users",
})
if err != nil {
	log.Fatal(err)
}

Write

Write is used to create/update objects in outreach connector. For an instance creating an emailAddress object, you use the Write method and emailAddress object

Example usage

type Attribute struct {
	Email     string `json:"email"`
	EmailType string `json:"emailType"`
	Order     int    `json:"order"`
	Status    string `json:"status"`
}

type EmailAddress struct {
	Attributes Attribute `json:"attributes"`
	Type       string    `json:"type"`
}

// Create an outreach connector instance (any method you prefer)
// This Assumes you named the instance client

attribute := Attribute{
		Email:     gofakeit.Email(),
		EmailType: "email",
		Order:     0,
		Status:    "null",
	}

	config := common.WriteParams{
		ObjectName: "emailAddresses",
		RecordData: EmailAddress{
			Attributes: attribute,
			Type:       "emailAddress",
		},
	}

result, err := client.Write(ctx, config)
if err != nil {
	log.Fatal(err)
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingClient = errors.New("JSON http client not set")
	ErrNotArray      = errors.New("results data is not an array")
	ErrNotObject     = errors.New("record is not an object")
	ErrNotString     = errors.New("next is not a string")
	ErrEmptyResponse = errors.New("empty response body")
)
View Source
var JSONAPIContentTypeHeader = common.Header{
	Key:   "Content-Type",
	Value: "application/vnd.api+json",
}

Functions

This section is empty.

Types

type Connector

type Connector struct {
	BaseURL string
	Client  *common.JSONHTTPClient
}

func NewConnector

func NewConnector(opts ...Option) (conn *Connector, outErr error)

func (*Connector) Close

func (c *Connector) Close() error

func (*Connector) HTTPClient

func (c *Connector) HTTPClient() *common.HTTPClient

func (*Connector) JSONHTTPClient

func (c *Connector) JSONHTTPClient() *common.JSONHTTPClient

JSONHTTPClient returns the underlying JSON HTTP client.

func (*Connector) ListObjectMetadata

func (c *Connector) ListObjectMetadata(ctx context.Context,
	objectNames []string,
) (*common.ListObjectMetadataResult, error)

func (*Connector) Provider

func (c *Connector) Provider() providers.Provider

Provider returns the connector provider.

func (*Connector) Read

func (c *Connector) Read(ctx context.Context, config common.ReadParams) (*common.ReadResult, error)

func (*Connector) String

func (c *Connector) String() string

func (*Connector) Write

func (c *Connector) Write(ctx context.Context, config common.WriteParams) (*common.WriteResult, error)

type ObjectOKResponse

type ObjectOKResponse struct {
	Data []map[string]any `json:"data"`
}

type Option

type Option func(params *outreachParams)

func WithAuthenticatedClient

func WithAuthenticatedClient(client common.AuthenticatedHTTPClient) Option

func WithClient

func WithClient(ctx context.Context, client *http.Client, config *oauth2.Config, token *oauth2.Token,
) Option

type WriteResponse

type WriteResponse struct {
	Data map[string]any `json:"data"`
}

Jump to

Keyboard shortcuts

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