contact

package
v0.0.0-...-421306c Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2024 License: BSD-2-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete(c messagebird.Client, id string) error

Delete attempts deleting the contact with the provided ID. If nil is returned, the resource was deleted successfully.

Types

type Contact

type Contact struct {
	ID              string
	HRef            string
	DisplayName     string
	FirstName       string
	LastName        string
	Identifiers     []Identifier
	Languages       []string
	Timezone        string
	Country         string
	Avatar          string
	Gender          string
	Profiles        []Profile
	Attributes      map[string]string
	Status          string
	CreatedDatetime *time.Time
	UpdatedDatetime *time.Time
}

Contact gets returned by the API.

func Create

func Create(c messagebird.Client, contactRequest *CreateRequest) (*Contact, error)

func Read

func Read(c messagebird.Client, id string) (*Contact, error)

Read retrieves the information of an existing contact.

func Update

func Update(c messagebird.Client, id string, contactRequest *CreateRequest) (*Contact, error)

Update updates the record referenced by id with any values set in contactRequest. Do not set any values that should not be updated.

type Contacts

type Contacts struct {
	Limit, Offset     int
	Count, TotalCount int
	Items             []Contact
}

func List

func List(c messagebird.Client, options *Filter) (*Contacts, error)

List retrieves a paginated and filtered list of contacts, based on the options provided. It's worth noting DefaultListOptions.

type CreateRequest

type CreateRequest struct {
	DisplayName string            `json:"displayName,omitempty"`
	FirstName   string            `json:"firstName,omitempty"`
	LastName    string            `json:"lastName,omitempty"`
	Avatar      string            `json:"avatar,omitempty"`
	Gender      string            `json:"gender,omitempty"`
	Country     string            `json:"country,omitempty"`
	Languages   []string          `json:"languages,omitempty"`
	Identifiers []Identifier      `json:"identifiers,omitempty"`
	Profiles    []Profile         `json:"profiles,omitempty"`
	Attributes  map[string]string `json:"attributes,omitempty"`
}

CreateRequest represents a contact for write operations, e.g. for creating a new contact or updating an existing one.

type Filter

type Filter struct {
	IDs             []string
	ChannelId       string
	IdentifierExact string
	Status          string
	Offset          int
	Limit           int
}

Filter can be applied to a list request to filter the results and paginate through them.

func (*Filter) QueryParams

func (f *Filter) QueryParams() string

type Identifier

type Identifier struct {
	ID        string    `json:"id,omitempty"`
	Type      string    `json:"type,omitempty"`
	Value     string    `json:"value,omitempty"`
	CreatedAt time.Time `json:"createdAt,omitempty"`
}

func ReadIdentifier

func ReadIdentifier(c messagebird.Client, contact, id string) (*Identifier, error)

type Identifiers

type Identifiers struct {
	Count, TotalCount int
	Offset, Limit     int
	Items             []Identifier
}

func ListIdentifiers

func ListIdentifiers(c messagebird.Client, contact string) (*Identifiers, error)

type Profile

type Profile struct {
	ID         string `json:"id,omitempty"`
	Identifier string `json:"identifier,omitempty"`
	Platform   string `json:"platform,omitempty"`
	ChannelId  string `json:"channelId,omitempty"`
}

type UpsertRequest

type UpsertRequest struct {
	UpdateContact bool           `json:"updateContact"`
	Contact       *CreateRequest `json:"contact"`
}

type UpsertResponse

type UpsertResponse struct {
	ContactId string `json:"contactId"`
	Created   bool   `json:"created"`
}

func Upsert

func Upsert(c messagebird.Client, contactRequest *UpsertRequest) (*UpsertResponse, error)

Upsert looks for an existing contact matching the criteria and either updates it or creates a new one. The contact ID is always returned as well as an indicator if the contact has been created.

Jump to

Keyboard shortcuts

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