group

package
v7.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2022 License: BSD-2-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultListOptions = &ListOptions{
	Limit:  10,
	Offset: 0,
}

DefaultListOptions provides reasonable values for List().

Functions

func AddContacts

func AddContacts(c *messagebird.Client, groupID string, contactIDs []string) error

AddContacts adds a maximum of 50 contacts to the group.

func Delete

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

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

func ListContacts

func ListContacts(c *messagebird.Client, groupID string, options *ListOptions) (*contact.ContactList, error)

ListContacts lists the contacts that are a member of a group.

func RemoveContact

func RemoveContact(c *messagebird.Client, groupID, contactID string) error

RemoveContact removes the contact from a group. If nil is returned, the operation was successful.

func Update

func Update(c *messagebird.Client, id string, request *Request) error

Update overrides the group with any values provided in request.

Types

type Group

type Group struct {
	ID       string
	HRef     string
	Name     string
	Contacts struct {
		TotalCount int
		HRef       string
	}
	CreatedDatetime *time.Time
	UpdatedDatetime *time.Time
}

Group gets returned by the API.

func Create

func Create(c *messagebird.Client, request *Request) (*Group, error)

func Read

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

Read retrieves the information of an existing group.

type GroupList

type GroupList struct {
	Offset     int
	Limit      int
	Count      int
	TotalCount int
	Links      struct {
		First    string
		Previous string
		Next     string
		Last     string
	}
	Items []Group
}

func List

func List(c *messagebird.Client, options *ListOptions) (*GroupList, error)

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

type ListOptions

type ListOptions struct {
	Limit, Offset int
}

ListOptions can be used to set pagination options in List() and ListContacts().

type Request

type Request struct {
	Name string `json:"name"`
}

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

Jump to

Keyboard shortcuts

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