linq

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2026 License: MIT Imports: 14 Imported by: 0

README

  ██╗     ██╗███╗   ██╗ ██████╗      ██████╗  ██████╗     ███████╗██████╗ ██╗  ██╗
  ██║     ██║████╗  ██║██╔═══██╗    ██╔════╝ ██╔═══██╗    ██╔════╝██╔══██╗██║ ██╔╝
  ██║     ██║██╔██╗ ██║██║   ██║    ██║  ███╗██║   ██║    ███████╗██║  ██║█████╔╝
  ██║     ██║██║╚██╗██║██║▄▄ ██║    ██║   ██║██║   ██║    ╚════██║██║  ██║██╔═██╗
  ███████╗██║██║ ╚████║╚██████╔╝    ╚██████╔╝╚██████╔╝    ███████║██████╔╝██║  ██╗
  ╚══════╝╚═╝╚═╝  ╚═══╝ ╚══▀▀═╝      ╚═════╝  ╚═════╝     ╚══════╝╚═════╝ ╚═╝  ╚═╝
                        iMessage · RCS · SMS — one Go client

Go Reference CI Go Report Card codecov Release Go Version OpenSSF Scorecard Last commit GitHub stars

An unofficial Go client for the Linq Partner API V3 — send and receive iMessage, RCS, and SMS from Go.

Install

go get github.com/vsima/linq-go-sdk@latest

Requires Go 1.25+. Zero third-party dependencies.

Quick start

package main

import (
	"context"
	"fmt"
	"log"
	"os"

	linq "github.com/vsima/linq-go-sdk"
)

func main() {
	c := linq.NewClient(os.Getenv("LINQ_TOKEN"))
	ctx := context.Background()

	res, err := c.Chats.Create(ctx, &linq.CreateChatRequest{
		From: "+15551234567",
		To:   []string{"+15557654321"},
		Message: linq.CreateChatMessage{
			Parts: []linq.MessagePart{linq.NewTextPart("Hello from Go! 👋")},
		},
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println("chat:", res.Chat.ID, "message:", res.Chat.Message.ID)
}

Features

  • Full V3 coverage — chats, messages, reactions, attachments, phone numbers, webhooks
  • Typed message parts — text / media / link with a discriminated union
  • Message effects — screen (confetti, fireworks…) and bubble (slam, loud…) effects
  • Threaded replies and custom-emoji reactions
  • Presigned attachment uploads with a helper Upload method
  • Webhook event parsing + signature verification (HMAC-SHA256, replay-safe)
  • Typed errorsAPIError with IsNotFound, IsUnauthorized, IsRateLimited helpers
  • Context-aware — every call takes a context.Context
  • Pluggable http.Client for retries, instrumentation, proxying
  • No third-party dependencies

Runnable examples

Two ready-to-run example programs live under examples/:

# Send a single text message
LINQ_TOKEN=xxx go run ./examples/send-message \
    -from +15551234567 -to +15557654321 -text "Hello from Go"

# Receive webhooks (verifies HMAC signatures, logs each event)
LINQ_SIGNING_SECRET=xxx go run ./examples/webhook-server

Snippets

Send a message with a screen effect

msg, err := c.Messages.Send(ctx, chatID, &linq.SendMessageRequest{
	Parts:  []linq.MessagePart{linq.NewTextPart("🎉")},
	Effect: &linq.MessageEffect{Type: "screen", Name: "confetti"},
})

Reply in a thread

msg, err := c.Messages.Send(ctx, chatID, &linq.SendMessageRequest{
	Parts:   []linq.MessagePart{linq.NewTextPart("same")},
	ReplyTo: &linq.ReplyTo{MessageID: parentID},
})

React with a custom emoji

emoji := "🔥"
err := c.Reactions.Set(ctx, messageID, &linq.ReactionRequest{
	Type:        linq.ReactionCustom,
	CustomEmoji: &emoji,
})

Upload and send an attachment

f, _ := os.Open("cat.png")
defer f.Close()

att, err := c.Attachments.Create(ctx, &linq.CreateAttachmentRequest{
	FileName: "cat.png",
	MimeType: "image/png",
})
if err != nil { log.Fatal(err) }

if err := c.Attachments.Upload(ctx, att, "image/png", f); err != nil {
	log.Fatal(err)
}

_, err = c.Messages.Send(ctx, chatID, &linq.SendMessageRequest{
	Parts: []linq.MessagePart{linq.NewMediaPartByID(att.AttachmentID)},
})

Handle a signed webhook

VerifyWebhookRequest verifies the HMAC-SHA256 signature Linq sets on X-Webhook-Signature over {timestamp}.{rawBody}, rejects replays older than the tolerance, and returns the raw body for parsing.

http.HandleFunc("/linq", func(w http.ResponseWriter, r *http.Request) {
	body, err := linq.VerifyWebhookRequest(r, signingSecret, linq.DefaultWebhookTolerance)
	if err != nil {
		http.Error(w, err.Error(), http.StatusUnauthorized)
		return
	}
	evt, err := linq.ParseEvent(body)
	if err != nil {
		http.Error(w, err.Error(), http.StatusBadRequest)
		return
	}
	switch evt.EventType {
	case linq.EventMessageReceived:
		var msg linq.Message
		_ = evt.DecodeData(&msg)
		log.Println("received:", msg.ID)
	}
	w.WriteHeader(http.StatusOK)
})

Error handling

_, err := c.Chats.Get(ctx, chatID)
switch {
case linq.IsNotFound(err):
	// 404
case linq.IsUnauthorized(err):
	// 401
case linq.IsRateLimited(err):
	var ae *linq.APIError
	errors.As(err, &ae)
	time.Sleep(time.Duration(ae.RetryAfter) * time.Second)
case err != nil:
	log.Fatal(err)
}

Testing

make test           # go test ./...
make cover          # coverage report
make lint           # gofmt + go vet

Contributing

Issues and PRs welcome. See CONTRIBUTING.md.

Disclaimer

This SDK is not affiliated with Linq. Product names and trademarks are property of their respective owners.

License

MIT © Victor Sima

Documentation

Overview

Package linq is a Go client for the Linq Partner API V3.

See https://apidocs.linqapp.com/ for API reference.

Package linq is an unofficial Go client for the Linq Partner API V3.

The Linq Partner API sends and receives iMessage, RCS, and SMS messages. Create a Client with an integration token and call methods grouped by resource: [Client.Chats], [Client.Messages], [Client.Reactions], [Client.Attachments], [Client.PhoneNumbers], and [Client.Webhooks].

See the README for end-to-end examples.

Index

Examples

Constants

View Source
const (
	DefaultBaseURL   = "https://api.linqapp.com/api/partner"
	DefaultUserAgent = "linq-go-sdk/0.1"
)
View Source
const (
	HeaderWebhookTimestamp = "X-Webhook-Timestamp"
	HeaderWebhookSignature = "X-Webhook-Signature"
)

Webhook header names set by the Linq signing process.

View Source
const DefaultWebhookTolerance = 5 * time.Minute

DefaultWebhookTolerance is the default maximum age accepted by VerifyWebhook. Requests older than this are rejected as possible replays.

Variables

View Source
var (
	ErrWebhookMissingHeader    = errors.New("linq: missing webhook signature header")
	ErrWebhookInvalidTimestamp = errors.New("linq: invalid webhook timestamp")
	ErrWebhookStale            = errors.New("linq: webhook timestamp outside tolerance")
	ErrWebhookSignature        = errors.New("linq: webhook signature mismatch")
)

Errors returned by VerifyWebhook and VerifyWebhookRequest.

Functions

func IsNotFound

func IsNotFound(err error) bool

IsNotFound reports whether err is a 404 from the API.

func IsRateLimited

func IsRateLimited(err error) bool

IsRateLimited reports whether err is a 429 from the API.

func IsUnauthorized

func IsUnauthorized(err error) bool

IsUnauthorized reports whether err is a 401 from the API.

func VerifyWebhook added in v0.2.0

func VerifyWebhook(body []byte, timestamp, signature, secret string, tolerance time.Duration) error

VerifyWebhook verifies an HMAC-SHA256 webhook signature as specified by Linq.

The signed payload is "{timestamp}.{body}" where body is the raw request bytes (do not re-serialize JSON before calling). signature is the value of the HeaderWebhookSignature header, hex-encoded.

If tolerance is > 0, requests with a timestamp older than tolerance (or more than tolerance in the future) are rejected with ErrWebhookStale. Pass 0 to disable the freshness check — not recommended in production.

func VerifyWebhookRequest added in v0.2.0

func VerifyWebhookRequest(r *http.Request, secret string, tolerance time.Duration) ([]byte, error)

VerifyWebhookRequest reads the full body of r, verifies its signature using VerifyWebhook, and returns the raw body bytes for downstream parsing.

On success the caller can pass the returned bytes to ParseEvent. The body of r is consumed; re-reading r.Body after this call will yield nothing.

Example
// Inside an http.HandlerFunc:
//
//   body, err := linq.VerifyWebhookRequest(r, secret, linq.DefaultWebhookTolerance)
//   if err != nil {
//       http.Error(w, err.Error(), http.StatusUnauthorized)
//       return
//   }
//   evt, _ := linq.ParseEvent(body)
//   _ = evt
fmt.Println("ok")
Output:
ok

Types

type APIError

type APIError struct {
	StatusCode int       `json:"-"`
	Code       ErrorCode `json:"code"`
	Message    string    `json:"message"`
	RetryAfter int       `json:"retry_after,omitempty"`
	TraceID    string    `json:"-"`
	RequestID  string    `json:"-"`
	Raw        []byte    `json:"-"`
}

APIError represents a non-2xx response from the Linq API.

func (*APIError) Error

func (e *APIError) Error() string

type Attachment

type Attachment struct {
	AttachmentID string    `json:"attachment_id"`
	UploadURL    string    `json:"upload_url"`
	DownloadURL  string    `json:"download_url"`
	ExpiresAt    time.Time `json:"expires_at"`
	Status       string    `json:"status,omitempty"`
}

Attachment is the presigned-upload response.

type AttachmentsService

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

AttachmentsService groups attachment endpoints.

func (*AttachmentsService) Create

Create requests a presigned URL for uploading an attachment.

func (*AttachmentsService) Get

func (s *AttachmentsService) Get(ctx context.Context, attachmentID string) (*Attachment, error)

Get returns the current status of an attachment.

func (*AttachmentsService) Upload

func (s *AttachmentsService) Upload(ctx context.Context, att *Attachment, mimeType string, body io.Reader) error

Upload PUTs the given content to the presigned URL. It reads body fully to set Content-Length, which S3-style presigned PUTs require.

type Chat

type Chat struct {
	ID          string       `json:"id"`
	DisplayName *string      `json:"display_name,omitempty"`
	Service     *ServiceType `json:"service,omitempty"`
	Handles     []ChatHandle `json:"handles,omitempty"`
	IsArchived  bool         `json:"is_archived"`
	IsGroup     bool         `json:"is_group"`
	CreatedAt   time.Time    `json:"created_at"`
	UpdatedAt   time.Time    `json:"updated_at"`
	Message     *Message     `json:"message,omitempty"`
}

Chat is a conversation.

Message is populated only on the response from ChatsService.Create; it carries the initial message and is nil on other endpoints.

type ChatHandle

type ChatHandle struct {
	ID       string        `json:"id"`
	Handle   string        `json:"handle"`
	Service  ServiceType   `json:"service"`
	Status   *HandleStatus `json:"status,omitempty"`
	JoinedAt time.Time     `json:"joined_at"`
	LeftAt   *time.Time    `json:"left_at,omitempty"`
	IsMe     *bool         `json:"is_me,omitempty"`
}

ChatHandle identifies a participant in a chat.

type ChatsService

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

ChatsService groups chat endpoints.

func (*ChatsService) AddParticipant

func (s *ChatsService) AddParticipant(ctx context.Context, chatID, handle string) error

AddParticipant adds a handle (phone or email) to a group chat.

func (*ChatsService) Create

Create creates a new chat with an initial message.

func (*ChatsService) Get

func (s *ChatsService) Get(ctx context.Context, chatID string) (*Chat, error)

Get retrieves a chat by ID.

func (*ChatsService) Leave

func (s *ChatsService) Leave(ctx context.Context, chatID string) error

Leave leaves a group chat.

func (*ChatsService) List

List returns a paginated set of chats.

func (*ChatsService) MarkRead

func (s *ChatsService) MarkRead(ctx context.Context, chatID string) error

MarkRead marks all messages in the chat as read.

func (*ChatsService) RemoveParticipant

func (s *ChatsService) RemoveParticipant(ctx context.Context, chatID, handle string) error

RemoveParticipant removes a handle from a group chat.

func (*ChatsService) SendVoiceMemo

func (s *ChatsService) SendVoiceMemo(ctx context.Context, chatID string, req *SendVoiceMemoRequest) (*Message, error)

SendVoiceMemo sends a voice memo to a chat. The attachment must be pre-uploaded.

func (*ChatsService) ShareContactCard

func (s *ChatsService) ShareContactCard(ctx context.Context, chatID string) error

ShareContactCard shares the authenticated partner's contact card in the chat.

func (*ChatsService) StartTyping

func (s *ChatsService) StartTyping(ctx context.Context, chatID string) error

StartTyping sends a typing-started indicator.

func (*ChatsService) StopTyping

func (s *ChatsService) StopTyping(ctx context.Context, chatID string) error

StopTyping sends a typing-stopped indicator.

func (*ChatsService) Update

func (s *ChatsService) Update(ctx context.Context, chatID string, req *UpdateChatRequest) error

Update updates the display name or icon of a group chat.

type Client

type Client struct {
	Chats        *ChatsService
	Messages     *MessagesService
	Reactions    *ReactionsService
	Attachments  *AttachmentsService
	PhoneNumbers *PhoneNumbersService
	Webhooks     *WebhooksService
	// contains filtered or unexported fields
}

Client is the Linq Partner API client.

func NewClient

func NewClient(token string, opts ...Option) *Client

NewClient returns a Client authenticated with the given bearer token.

type CreateAttachmentRequest

type CreateAttachmentRequest struct {
	FileName string `json:"file_name"`
	MimeType string `json:"mime_type"`
	Size     int64  `json:"size,omitempty"`
}

CreateAttachmentRequest requests a presigned upload URL.

type CreateChatMessage

type CreateChatMessage struct {
	Parts            []MessagePart  `json:"parts"`
	Effect           *MessageEffect `json:"effect,omitempty"`
	PreferredService *ServiceType   `json:"preferred_service,omitempty"`
	ReplyTo          *ReplyTo       `json:"reply_to,omitempty"`
}

CreateChatMessage is the initial message sent when a chat is created.

type CreateChatRequest

type CreateChatRequest struct {
	From    string            `json:"from"`
	To      []string          `json:"to"`
	Message CreateChatMessage `json:"message"`
}

CreateChatRequest is the body for creating a chat with an initial message.

type CreateChatResult

type CreateChatResult struct {
	Chat Chat `json:"chat"`
}

CreateChatResult is the 201 response from creating a chat.

The initial message lives at Chat.Message, not at the top level.

type CreateWebhookSubscriptionRequest

type CreateWebhookSubscriptionRequest struct {
	TargetURL        string   `json:"target_url"`
	SubscribedEvents []string `json:"subscribed_events"`
	PhoneNumbers     []string `json:"phone_numbers,omitempty"`
}

CreateWebhookSubscriptionRequest creates a new webhook subscription.

Set PhoneNumbers to scope the subscription to specific sender numbers; leave nil to receive events for all numbers associated with the token.

type DeliveryStatus

type DeliveryStatus string

DeliveryStatus is the lifecycle state of an outbound message.

const (
	DeliveryPending   DeliveryStatus = "pending"
	DeliveryQueued    DeliveryStatus = "queued"
	DeliverySent      DeliveryStatus = "sent"
	DeliveryDelivered DeliveryStatus = "delivered"
	DeliveryFailed    DeliveryStatus = "failed"
)

type ErrorCode

type ErrorCode int

ErrorCode is the Linq-specific error code returned in the error body.

const (
	ErrCodeServer           ErrorCode = 1001
	ErrCodeUnauthorized     ErrorCode = 1002
	ErrCodeNotFound         ErrorCode = 1004
	ErrCodeInvalidParameter ErrorCode = 1005
	ErrCodeRateLimited      ErrorCode = 1007
)

type Event

type Event struct {
	APIVersion string          `json:"api_version"`
	EventType  EventType       `json:"event_type"`
	EventID    string          `json:"event_id"`
	CreatedAt  time.Time       `json:"created_at"`
	TraceID    string          `json:"trace_id"`
	PartnerID  string          `json:"partner_id"`
	Data       json.RawMessage `json:"data"`
}

Event is a webhook envelope. Data holds the raw event payload; decode it with DecodeData into the matching concrete type for the EventType.

func ParseEvent

func ParseEvent(body []byte) (*Event, error)

ParseEvent decodes a webhook request body into an Event.

func (*Event) DecodeData

func (e *Event) DecodeData(out any) error

DecodeData unmarshals Event.Data into out.

type EventType

type EventType string

EventType enumerates webhook event types.

const (
	EventMessageSent               EventType = "message.sent"
	EventMessageDelivered          EventType = "message.delivered"
	EventMessageFailed             EventType = "message.failed"
	EventMessageReceived           EventType = "message.received"
	EventMessageRead               EventType = "message.read"
	EventReactionSent              EventType = "reaction.sent"
	EventReactionReceived          EventType = "reaction.received"
	EventTypingIndicatorReceived   EventType = "typing_indicator.received"
	EventTypingIndicatorRemoved    EventType = "typing_indicator.removed"
	EventParticipantAdded          EventType = "participant.added"
	EventParticipantRemoved        EventType = "participant.removed"
	EventChatGroupNameUpdated      EventType = "chat.group_name_updated"
	EventChatGroupIconUpdated      EventType = "chat.group_icon_updated"
	EventChatGroupNameUpdateFailed EventType = "chat.group_name_update_failed"
	EventChatGroupIconUpdateFailed EventType = "chat.group_icon_update_failed"
)

type HandleStatus

type HandleStatus string

HandleStatus is the membership state of a participant in a chat.

const (
	HandleActive  HandleStatus = "active"
	HandleLeft    HandleStatus = "left"
	HandleRemoved HandleStatus = "removed"
)

type LinkPart

type LinkPart struct {
	Value     string     `json:"value"`
	Reactions []Reaction `json:"reactions,omitempty"`
}

LinkPart is a link preview segment.

type ListChatsParams

type ListChatsParams struct {
	From   string // E.164 phone number
	To     string // participant handle (phone or email)
	Limit  int    // 1-100
	Cursor string
}

ListChatsParams filters the List call.

type ListChatsResult

type ListChatsResult struct {
	Chats      []Chat `json:"chats"`
	NextCursor string `json:"next_cursor,omitempty"`
}

ListChatsResult is a paginated page of chats.

type ListMessagesParams

type ListMessagesParams struct {
	Limit  int
	Cursor string
}

ListMessagesParams filters the List call.

type ListMessagesResult

type ListMessagesResult struct {
	Messages   []Message `json:"messages"`
	NextCursor string    `json:"next_cursor,omitempty"`
}

ListMessagesResult is a paginated page of messages.

type ListPhoneNumbersResult

type ListPhoneNumbersResult struct {
	PhoneNumbers []PhoneNumber `json:"phone_numbers"`
}

ListPhoneNumbersResult is the response for List.

type ListWebhookSubscriptionsResult

type ListWebhookSubscriptionsResult struct {
	Subscriptions []WebhookSubscription `json:"subscriptions"`
}

ListWebhookSubscriptionsResult is a page of subscriptions.

type MediaPart

type MediaPart struct {
	URL          *string    `json:"url,omitempty"`
	AttachmentID *string    `json:"attachment_id,omitempty"`
	Reactions    []Reaction `json:"reactions,omitempty"`
}

MediaPart references an attachment by URL or attachment_id.

type Message

type Message struct {
	ID               string         `json:"id"`
	Service          *ServiceType   `json:"service,omitempty"`
	PreferredService *ServiceType   `json:"preferred_service,omitempty"`
	Parts            []MessagePart  `json:"parts"`
	CreatedAt        time.Time      `json:"created_at"`
	SentAt           *time.Time     `json:"sent_at,omitempty"`
	DeliveredAt      *time.Time     `json:"delivered_at,omitempty"`
	DeliveryStatus   DeliveryStatus `json:"delivery_status"`
	IsRead           bool           `json:"is_read"`
	Effect           *MessageEffect `json:"effect,omitempty"`
	FromHandle       *ChatHandle    `json:"from_handle,omitempty"`
	ReplyTo          *ReplyTo       `json:"reply_to,omitempty"`
}

Message is a chat message.

type MessageEffect

type MessageEffect struct {
	Type string `json:"type"`
	Name string `json:"name"`
}

MessageEffect is a screen or bubble effect applied to a message. Type must be "screen" or "bubble".

type MessagePart

type MessagePart struct {
	Text  *TextPart
	Media *MediaPart
	Link  *LinkPart
}

MessagePart is a discriminated union: Text, Media, or Link. Exactly one of the pointer fields on the wrapper is set after unmarshal.

func NewLinkPart

func NewLinkPart(url string) MessagePart

NewLinkPart builds a link MessagePart.

func NewMediaPartByID

func NewMediaPartByID(attachmentID string) MessagePart

NewMediaPartByID builds a media MessagePart from an uploaded attachment.

func NewMediaPartByURL

func NewMediaPartByURL(url string) MessagePart

NewMediaPartByURL builds a media MessagePart from an HTTPS URL.

func NewTextPart

func NewTextPart(value string) MessagePart

NewTextPart is a convenience for building a text MessagePart.

func (MessagePart) MarshalJSON

func (p MessagePart) MarshalJSON() ([]byte, error)

MarshalJSON encodes the active variant with its type discriminator.

func (*MessagePart) UnmarshalJSON

func (p *MessagePart) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes a tagged part and populates the matching variant.

type MessagesService

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

MessagesService groups message endpoints.

func (*MessagesService) Delete

func (s *MessagesService) Delete(ctx context.Context, messageID string) error

Delete deletes a message.

func (*MessagesService) Get

func (s *MessagesService) Get(ctx context.Context, messageID string) (*Message, error)

Get retrieves a single message by ID.

func (*MessagesService) List

List returns messages in a chat.

func (*MessagesService) Send

func (s *MessagesService) Send(ctx context.Context, chatID string, req *SendMessageRequest) (*Message, error)

Send sends a message to the given chat.

func (*MessagesService) Thread

func (s *MessagesService) Thread(ctx context.Context, messageID string) (*ThreadResult, error)

Thread fetches the threaded reply chain for a message.

type Option

type Option func(*Client)

Option configures the Client.

func WithBaseURL

func WithBaseURL(u string) Option

WithBaseURL overrides the API base URL (no trailing slash).

func WithHTTPClient

func WithHTTPClient(h *http.Client) Option

WithHTTPClient overrides the underlying HTTP client.

func WithUserAgent

func WithUserAgent(ua string) Option

WithUserAgent overrides the User-Agent header.

type PhoneNumber

type PhoneNumber struct {
	Number    string   `json:"number"`
	Services  []string `json:"services,omitempty"`
	Label     string   `json:"label,omitempty"`
	IsDefault bool     `json:"is_default,omitempty"`
}

PhoneNumber is a sender phone number associated with the partner token.

type PhoneNumbersService

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

PhoneNumbersService groups phone-number endpoints.

func (*PhoneNumbersService) List

List returns the phone numbers the partner token may send from.

type Reaction

type Reaction struct {
	IsMe        bool         `json:"is_me"`
	Handle      ChatHandle   `json:"handle"`
	Type        ReactionType `json:"type"`
	CustomEmoji *string      `json:"custom_emoji,omitempty"`
	Sticker     *Sticker     `json:"sticker,omitempty"`
}

Reaction is a reaction attached to a message part.

type ReactionRequest

type ReactionRequest struct {
	Type        ReactionType `json:"type"`
	PartIndex   int          `json:"part_index,omitempty"`
	CustomEmoji *string      `json:"custom_emoji,omitempty"`
	Sticker     *Sticker     `json:"sticker,omitempty"`
	Remove      bool         `json:"remove,omitempty"`
}

ReactionRequest adds or removes a reaction on a message part. Set Remove to true to remove; otherwise the reaction is added.

type ReactionType

type ReactionType string

ReactionType enumerates built-in reaction kinds. Use ReactionCustom with CustomEmoji, or ReactionSticker with a Sticker payload.

const (
	ReactionLove      ReactionType = "love"
	ReactionLike      ReactionType = "like"
	ReactionDislike   ReactionType = "dislike"
	ReactionLaugh     ReactionType = "laugh"
	ReactionEmphasize ReactionType = "emphasize"
	ReactionQuestion  ReactionType = "question"
	ReactionCustom    ReactionType = "custom"
	ReactionSticker   ReactionType = "sticker"
)

type ReactionsService

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

ReactionsService groups reaction endpoints.

func (*ReactionsService) Set

func (s *ReactionsService) Set(ctx context.Context, messageID string, req *ReactionRequest) error

Set adds or removes a reaction on a message.

type ReplyTo

type ReplyTo struct {
	MessageID string `json:"message_id"`
	PartIndex int    `json:"part_index,omitempty"`
}

ReplyTo targets a message (and optional part index) for threaded replies.

type SendMessageRequest

type SendMessageRequest struct {
	Parts            []MessagePart  `json:"parts"`
	Effect           *MessageEffect `json:"effect,omitempty"`
	PreferredService *ServiceType   `json:"preferred_service,omitempty"`
	ReplyTo          *ReplyTo       `json:"reply_to,omitempty"`
}

SendMessageRequest is the body for sending a message into a chat.

type SendVoiceMemoRequest

type SendVoiceMemoRequest struct {
	AttachmentID     string       `json:"attachment_id"`
	PreferredService *ServiceType `json:"preferred_service,omitempty"`
}

SendVoiceMemoRequest is the body for SendVoiceMemo.

type ServiceType

type ServiceType string

ServiceType identifies the delivery protocol for a chat or message.

const (
	ServiceIMessage ServiceType = "iMessage"
	ServiceSMS      ServiceType = "SMS"
	ServiceRCS      ServiceType = "RCS"
)

type Sticker

type Sticker struct {
	URL      string `json:"url"`
	MimeType string `json:"mime_type"`
	Width    int    `json:"width"`
	Height   int    `json:"height"`
	FileName string `json:"file_name"`
}

Sticker is a custom sticker used in a reaction.

type TextDecoration

type TextDecoration struct {
	Range     [2]int  `json:"range"`
	Style     *string `json:"style,omitempty"`
	Animation *string `json:"animation,omitempty"`
}

TextDecoration applies a style or animation to a character range [Start,End). Set Style or Animation, not both.

type TextPart

type TextPart struct {
	Value           string           `json:"value"`
	TextDecorations []TextDecoration `json:"text_decorations,omitempty"`
	Reactions       []Reaction       `json:"reactions,omitempty"`
}

TextPart is a textual segment of a message.

type ThreadResult

type ThreadResult struct {
	Messages []Message `json:"messages"`
}

ThreadResult is the threaded-reply list for a given message.

type UpdateChatRequest

type UpdateChatRequest struct {
	DisplayName   *string `json:"display_name,omitempty"`
	GroupChatIcon *string `json:"group_chat_icon,omitempty"`
}

UpdateChatRequest updates mutable properties of a chat.

type UpdateWebhookSubscriptionRequest

type UpdateWebhookSubscriptionRequest struct {
	TargetURL        *string  `json:"target_url,omitempty"`
	SubscribedEvents []string `json:"subscribed_events,omitempty"`
	PhoneNumbers     []string `json:"phone_numbers,omitempty"`
	IsActive         *bool    `json:"is_active,omitempty"`
}

UpdateWebhookSubscriptionRequest updates mutable fields of a subscription.

type WebhookSubscription

type WebhookSubscription struct {
	ID               string    `json:"id"`
	TargetURL        string    `json:"target_url"`
	SubscribedEvents []string  `json:"subscribed_events"`
	SigningSecret    string    `json:"signing_secret,omitempty"`
	PhoneNumbers     []string  `json:"phone_numbers,omitempty"`
	IsActive         bool      `json:"is_active"`
	CreatedAt        time.Time `json:"created_at,omitempty"`
	UpdatedAt        time.Time `json:"updated_at,omitempty"`
}

WebhookSubscription describes a webhook endpoint and its subscribed events.

SigningSecret is the HMAC key for VerifyWebhookRequest; it is returned on Create and Get but may be omitted from List responses. Store it securely.

type WebhooksService

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

WebhooksService groups webhook-subscription endpoints and event parsing.

func (*WebhooksService) Create

Create registers a new webhook subscription.

func (*WebhooksService) Delete

func (s *WebhooksService) Delete(ctx context.Context, id string) error

Delete removes a webhook subscription.

func (*WebhooksService) List

List returns all webhook subscriptions.

func (*WebhooksService) Update

Update modifies a webhook subscription.

Directories

Path Synopsis
examples
send-message command
Command send-message is a runnable example that creates a chat and sends one text message via the Linq Partner API.
Command send-message is a runnable example that creates a chat and sends one text message via the Linq Partner API.
webhook-server command
Command webhook-server is a runnable example of a Linq webhook receiver.
Command webhook-server is a runnable example of a Linq webhook receiver.

Jump to

Keyboard shortcuts

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