beeperdesktopapi

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2025 License: MIT Imports: 18 Imported by: 0

README

Beeper Desktop Go API Library

Go Reference

The Beeper Desktop Go library provides convenient access to the Beeper Desktop REST API from applications written in Go.

Installation

import (
	"github.com/beeper/desktop-api-go" // imported as beeperdesktopapi
)

Or to pin the version:

go get -u 'github.com/beeper/desktop-api-go@v0.1.0'

Requirements

This library requires Go 1.22+.

Usage

The full API of this library can be found in api.md.

package main

import (
	"context"
	"fmt"

	"github.com/beeper/desktop-api-go"
	"github.com/beeper/desktop-api-go/option"
)

func main() {
	client := beeperdesktopapi.NewClient(
		option.WithAccessToken("My Access Token"), // defaults to os.LookupEnv("BEEPER_ACCESS_TOKEN")
	)
	page, err := client.Chats.Search(context.TODO(), beeperdesktopapi.ChatSearchParams{
		IncludeMuted: beeperdesktopapi.Bool(true),
		Limit:        beeperdesktopapi.Int(3),
		Type:         beeperdesktopapi.ChatSearchParamsTypeSingle,
	})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", page)
}

Request fields

The beeperdesktopapi library uses the omitzero semantics from the Go 1.24+ encoding/json release for request fields.

Required primitive fields (int64, string, etc.) feature the tag `json:"...,required"`. These fields are always serialized, even their zero values.

Optional primitive types are wrapped in a param.Opt[T]. These fields can be set with the provided constructors, beeperdesktopapi.String(string), beeperdesktopapi.Int(int64), etc.

Any param.Opt[T], map, slice, struct or string enum uses the tag `json:"...,omitzero"`. Its zero value is considered omitted.

The param.IsOmitted(any) function can confirm the presence of any omitzero field.

p := beeperdesktopapi.ExampleParams{
	ID:   "id_xxx",                       // required property
	Name: beeperdesktopapi.String("..."), // optional property

	Point: beeperdesktopapi.Point{
		X: 0,                       // required field will serialize as 0
		Y: beeperdesktopapi.Int(1), // optional field will serialize as 1
		// ... omitted non-required fields will not be serialized
	},

	Origin: beeperdesktopapi.Origin{}, // the zero value of [Origin] is considered omitted
}

To send null instead of a param.Opt[T], use param.Null[T](). To send null instead of a struct T, use param.NullStruct[T]().

p.Name = param.Null[string]()       // 'null' instead of string
p.Point = param.NullStruct[Point]() // 'null' instead of struct

param.IsNull(p.Name)  // true
param.IsNull(p.Point) // true

Request structs contain a .SetExtraFields(map[string]any) method which can send non-conforming fields in the request body. Extra fields overwrite any struct fields with a matching key. For security reasons, only use SetExtraFields with trusted data.

To send a custom value instead of a struct, use param.Override[T](value).

// In cases where the API specifies a given type,
// but you want to send something else, use [SetExtraFields]:
p.SetExtraFields(map[string]any{
	"x": 0.01, // send "x" as a float instead of int
})

// Send a number instead of an object
custom := param.Override[beeperdesktopapi.FooParams](12)
Request unions

Unions are represented as a struct with fields prefixed by "Of" for each of it's variants, only one field can be non-zero. The non-zero field will be serialized.

Sub-properties of the union can be accessed via methods on the union struct. These methods return a mutable pointer to the underlying data, if present.

// Only one field can be non-zero, use param.IsOmitted() to check if a field is set
type AnimalUnionParam struct {
	OfCat *Cat `json:",omitzero,inline`
	OfDog *Dog `json:",omitzero,inline`
}

animal := AnimalUnionParam{
	OfCat: &Cat{
		Name: "Whiskers",
		Owner: PersonParam{
			Address: AddressParam{Street: "3333 Coyote Hill Rd", Zip: 0},
		},
	},
}

// Mutating a field
if address := animal.GetOwner().GetAddress(); address != nil {
	address.ZipCode = 94304
}
Response objects

All fields in response structs are ordinary value types (not pointers or wrappers). Response structs also include a special JSON field containing metadata about each property.

type Animal struct {
	Name   string `json:"name,nullable"`
	Owners int    `json:"owners"`
	Age    int    `json:"age"`
	JSON   struct {
		Name        respjson.Field
		Owner       respjson.Field
		Age         respjson.Field
		ExtraFields map[string]respjson.Field
	} `json:"-"`
}

To handle optional data, use the .Valid() method on the JSON field. .Valid() returns true if a field is not null, not present, or couldn't be marshaled.

If .Valid() is false, the corresponding field will simply be its zero value.

raw := `{"owners": 1, "name": null}`

var res Animal
json.Unmarshal([]byte(raw), &res)

// Accessing regular fields

res.Owners // 1
res.Name   // ""
res.Age    // 0

// Optional field checks

res.JSON.Owners.Valid() // true
res.JSON.Name.Valid()   // false
res.JSON.Age.Valid()    // false

// Raw JSON values

res.JSON.Owners.Raw()                  // "1"
res.JSON.Name.Raw() == "null"          // true
res.JSON.Name.Raw() == respjson.Null   // true
res.JSON.Age.Raw() == ""               // true
res.JSON.Age.Raw() == respjson.Omitted // true

These .JSON structs also include an ExtraFields map containing any properties in the json response that were not specified in the struct. This can be useful for API features not yet present in the SDK.

body := res.JSON.ExtraFields["my_unexpected_field"].Raw()
Response Unions

In responses, unions are represented by a flattened struct containing all possible fields from each of the object variants. To convert it to a variant use the .AsFooVariant() method or the .AsAny() method if present.

If a response value union contains primitive values, primitive fields will be alongside the properties but prefixed with Of and feature the tag json:"...,inline".

type AnimalUnion struct {
	// From variants [Dog], [Cat]
	Owner Person `json:"owner"`
	// From variant [Dog]
	DogBreed string `json:"dog_breed"`
	// From variant [Cat]
	CatBreed string `json:"cat_breed"`
	// ...

	JSON struct {
		Owner respjson.Field
		// ...
	} `json:"-"`
}

// If animal variant
if animal.Owner.Address.ZipCode == "" {
	panic("missing zip code")
}

// Switch on the variant
switch variant := animal.AsAny().(type) {
case Dog:
case Cat:
default:
	panic("unexpected type")
}
RequestOptions

This library uses the functional options pattern. Functions defined in the option package return a RequestOption, which is a closure that mutates a RequestConfig. These options can be supplied to the client or at individual requests. For example:

client := beeperdesktopapi.NewClient(
	// Adds a header to every request made by the client
	option.WithHeader("X-Some-Header", "custom_header_info"),
)

client.Accounts.List(context.TODO(), ...,
	// Override the header
	option.WithHeader("X-Some-Header", "some_other_custom_header_info"),
	// Add an undocumented field to the request body, using sjson syntax
	option.WithJSONSet("some.json.path", map[string]string{"my": "object"}),
)

The request option option.WithDebugLog(nil) may be helpful while debugging.

See the full list of request options.

Pagination

This library provides some conveniences for working with paginated list endpoints.

You can use .ListAutoPaging() methods to iterate through items across all pages:

iter := client.Messages.SearchAutoPaging(context.TODO(), beeperdesktopapi.MessageSearchParams{
	AccountIDs: []string{"local-telegram_ba_QFrb5lrLPhO3OT5MFBeTWv0x4BI"},
	Limit:      beeperdesktopapi.Int(10),
	Query:      beeperdesktopapi.String("deployment"),
})
// Automatically fetches more pages as needed.
for iter.Next() {
	message := iter.Current()
	fmt.Printf("%+v\n", message)
}
if err := iter.Err(); err != nil {
	panic(err.Error())
}

Or you can use simple .List() methods to fetch a single page and receive a standard response object with additional helper methods like .GetNextPage(), e.g.:

page, err := client.Messages.Search(context.TODO(), beeperdesktopapi.MessageSearchParams{
	AccountIDs: []string{"local-telegram_ba_QFrb5lrLPhO3OT5MFBeTWv0x4BI"},
	Limit:      beeperdesktopapi.Int(10),
	Query:      beeperdesktopapi.String("deployment"),
})
for page != nil {
	for _, message := range page.Items {
		fmt.Printf("%+v\n", message)
	}
	page, err = page.GetNextPage()
}
if err != nil {
	panic(err.Error())
}
Errors

When the API returns a non-success status code, we return an error with type *beeperdesktopapi.Error. This contains the StatusCode, *http.Request, and *http.Response values of the request, as well as the JSON of the error body (much like other response objects in the SDK).

To handle errors, we recommend that you use the errors.As pattern:

_, err := client.Accounts.List(context.TODO())
if err != nil {
	var apierr *beeperdesktopapi.Error
	if errors.As(err, &apierr) {
		println(string(apierr.DumpRequest(true)))  // Prints the serialized HTTP request
		println(string(apierr.DumpResponse(true))) // Prints the serialized HTTP response
	}
	panic(err.Error()) // GET "/v1/accounts": 400 Bad Request { ... }
}

When other errors occur, they are returned unwrapped; for example, if HTTP transport fails, you might receive *url.Error wrapping *net.OpError.

Timeouts

Requests do not time out by default; use context to configure a timeout for a request lifecycle.

Note that if a request is retried, the context timeout does not start over. To set a per-retry timeout, use option.WithRequestTimeout().

// This sets the timeout for the request, including all the retries.
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()
client.Accounts.List(
	ctx,
	// This sets the per-retry timeout
	option.WithRequestTimeout(20*time.Second),
)
File uploads

Request parameters that correspond to file uploads in multipart requests are typed as io.Reader. The contents of the io.Reader will by default be sent as a multipart form part with the file name of "anonymous_file" and content-type of "application/octet-stream".

The file name and content-type can be customized by implementing Name() string or ContentType() string on the run-time type of io.Reader. Note that os.File implements Name() string, so a file returned by os.Open will be sent with the file name on disk.

We also provide a helper beeperdesktopapi.File(reader io.Reader, filename string, contentType string) which can be used to wrap any io.Reader with the appropriate file name and content type.

Retries

Certain errors will be automatically retried 2 times by default, with a short exponential backoff. We retry by default all connection errors, 408 Request Timeout, 409 Conflict, 429 Rate Limit, and >=500 Internal errors.

You can use the WithMaxRetries option to configure or disable this:

// Configure the default for all requests:
client := beeperdesktopapi.NewClient(
	option.WithMaxRetries(0), // default is 2
)

// Override per-request:
client.Accounts.List(context.TODO(), option.WithMaxRetries(5))
Accessing raw response data (e.g. response headers)

You can access the raw HTTP response data by using the option.WithResponseInto() request option. This is useful when you need to examine response headers, status codes, or other details.

// Create a variable to store the HTTP response
var response *http.Response
accounts, err := client.Accounts.List(context.TODO(), option.WithResponseInto(&response))
if err != nil {
	// handle error
}
fmt.Printf("%+v\n", accounts)

fmt.Printf("Status Code: %d\n", response.StatusCode)
fmt.Printf("Headers: %+#v\n", response.Header)
Making custom/undocumented requests

This library is typed for convenient access to the documented API. If you need to access undocumented endpoints, params, or response properties, the library can still be used.

Undocumented endpoints

To make requests to undocumented endpoints, you can use client.Get, client.Post, and other HTTP verbs. RequestOptions on the client, such as retries, will be respected when making these requests.

var (
    // params can be an io.Reader, a []byte, an encoding/json serializable object,
    // or a "…Params" struct defined in this library.
    params map[string]any

    // result can be an []byte, *http.Response, a encoding/json deserializable object,
    // or a model defined in this library.
    result *http.Response
)
err := client.Post(context.Background(), "/unspecified", params, &result)
if err != nil {
    …
}
Undocumented request params

To make requests using undocumented parameters, you may use either the option.WithQuerySet() or the option.WithJSONSet() methods.

params := FooNewParams{
    ID:   "id_xxxx",
    Data: FooNewParamsData{
        FirstName: beeperdesktopapi.String("John"),
    },
}
client.Foo.New(context.Background(), params, option.WithJSONSet("data.last_name", "Doe"))
Undocumented response properties

To access undocumented response properties, you may either access the raw JSON of the response as a string with result.JSON.RawJSON(), or get the raw JSON of a particular field on the result with result.JSON.Foo.Raw().

Any fields that are not present on the response struct will be saved and can be accessed by result.JSON.ExtraFields() which returns the extra fields as a map[string]Field.

Middleware

We provide option.WithMiddleware which applies the given middleware to requests.

func Logger(req *http.Request, next option.MiddlewareNext) (res *http.Response, err error) {
	// Before the request
	start := time.Now()
	LogReq(req)

	// Forward the request to the next handler
	res, err = next(req)

	// Handle stuff after the request
	end := time.Now()
	LogRes(res, err, start - end)

    return res, err
}

client := beeperdesktopapi.NewClient(
	option.WithMiddleware(Logger),
)

When multiple middlewares are provided as variadic arguments, the middlewares are applied left to right. If option.WithMiddleware is given multiple times, for example first in the client then the method, the middleware in the client will run first and the middleware given in the method will run next.

You may also replace the default http.Client with option.WithHTTPClient(client). Only one http client is accepted (this overwrites any previous client) and receives requests after any middleware has been applied.

Semantic versioning

This package generally follows SemVer conventions, though certain backwards-incompatible changes may be released as minor versions:

  1. Changes to library internals which are technically public but not intended or documented for external use. (Please open a GitHub issue to let us know if you are relying on such internals.)
  2. Changes that we do not expect to impact the vast majority of users in practice.

We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.

We are keen for your feedback; please open an issue with questions, bugs, or suggestions.

Contributing

See the contributing documentation.

Documentation

Index

Constants

View Source
const AttachmentTypeAudio = shared.AttachmentTypeAudio

Equals "audio"

View Source
const AttachmentTypeImg = shared.AttachmentTypeImg

Equals "img"

View Source
const AttachmentTypeUnknown = shared.AttachmentTypeUnknown

Equals "unknown"

View Source
const AttachmentTypeVideo = shared.AttachmentTypeVideo

Equals "video"

Variables

This section is empty.

Functions

func Bool

func Bool(b bool) param.Opt[bool]

func BoolPtr

func BoolPtr(v bool) *bool

func DefaultClientOptions

func DefaultClientOptions() []option.RequestOption

DefaultClientOptions read from the environment (BEEPER_ACCESS_TOKEN, BEEPER_DESKTOP_BASE_URL). This should be used to initialize new clients.

func File

func File(rdr io.Reader, filename string, contentType string) file

func Float

func Float(f float64) param.Opt[float64]

func FloatPtr

func FloatPtr(v float64) *float64

func Int

func Int(i int64) param.Opt[int64]

func IntPtr

func IntPtr(v int64) *int64

func Opt

func Opt[T comparable](v T) param.Opt[T]

func Ptr

func Ptr[T any](v T) *T

func String

func String(s string) param.Opt[string]

func StringPtr

func StringPtr(v string) *string

func Time

func Time(t time.Time) param.Opt[time.Time]

func TimePtr

func TimePtr(v time.Time) *time.Time

Types

type Account

type Account struct {
	// Chat account added to Beeper. Use this to route account-scoped actions.
	AccountID string `json:"accountID,required"`
	// Display-only human-readable network name (e.g., 'WhatsApp', 'Messenger').
	//
	// Deprecated: deprecated
	Network string `json:"network,required"`
	// User the account belongs to.
	User shared.User `json:"user,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AccountID   respjson.Field
		Network     respjson.Field
		User        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

A chat account added to Beeper

func (Account) RawJSON

func (r Account) RawJSON() string

Returns the unmodified JSON received from the API

func (*Account) UnmarshalJSON

func (r *Account) UnmarshalJSON(data []byte) error

type AccountContactSearchParams

type AccountContactSearchParams struct {
	// Text to search users by. Network-specific behavior.
	Query string `query:"query,required" json:"-"`
	// contains filtered or unexported fields
}

func (AccountContactSearchParams) URLQuery

func (r AccountContactSearchParams) URLQuery() (v url.Values, err error)

URLQuery serializes AccountContactSearchParams's query parameters as `url.Values`.

type AccountContactSearchResponse

type AccountContactSearchResponse struct {
	Items []shared.User `json:"items,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Items       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (AccountContactSearchResponse) RawJSON

Returns the unmodified JSON received from the API

func (*AccountContactSearchResponse) UnmarshalJSON

func (r *AccountContactSearchResponse) UnmarshalJSON(data []byte) error

type AccountContactService

type AccountContactService struct {
	Options []option.RequestOption
}

Manage contacts on a specific account

AccountContactService contains methods and other services that help with interacting with the beeperdesktop API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewAccountContactService method instead.

func NewAccountContactService

func NewAccountContactService(opts ...option.RequestOption) (r AccountContactService)

NewAccountContactService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*AccountContactService) Search

Search contacts across on a specific account using the network's search API. Only use for creating new chats.

type AccountService

type AccountService struct {
	Options []option.RequestOption
	// Manage contacts on a specific account
	Contacts AccountContactService
}

Manage connected chat accounts

AccountService contains methods and other services that help with interacting with the beeperdesktop API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewAccountService method instead.

func NewAccountService

func NewAccountService(opts ...option.RequestOption) (r AccountService)

NewAccountService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*AccountService) List

func (r *AccountService) List(ctx context.Context, opts ...option.RequestOption) (res *[]Account, err error)

Lists chat accounts across networks (WhatsApp, Telegram, Twitter/X, etc.) actively connected to this Beeper Desktop instance

type AssetDownloadParams

type AssetDownloadParams struct {
	// Matrix content URL (mxc:// or localmxc://) for the asset to download.
	URL string `json:"url,required"`
	// contains filtered or unexported fields
}

func (AssetDownloadParams) MarshalJSON

func (r AssetDownloadParams) MarshalJSON() (data []byte, err error)

func (*AssetDownloadParams) UnmarshalJSON

func (r *AssetDownloadParams) UnmarshalJSON(data []byte) error

type AssetDownloadResponse

type AssetDownloadResponse struct {
	// Error message if the download failed.
	Error string `json:"error"`
	// Local file URL to the downloaded asset.
	SrcURL string `json:"srcURL"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Error       respjson.Field
		SrcURL      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (AssetDownloadResponse) RawJSON

func (r AssetDownloadResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*AssetDownloadResponse) UnmarshalJSON

func (r *AssetDownloadResponse) UnmarshalJSON(data []byte) error

type AssetService

type AssetService struct {
	Options []option.RequestOption
}

Manage assets in Beeper Desktop, like message attachments

AssetService contains methods and other services that help with interacting with the beeperdesktop API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewAssetService method instead.

func NewAssetService

func NewAssetService(opts ...option.RequestOption) (r AssetService)

NewAssetService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*AssetService) Download

func (r *AssetService) Download(ctx context.Context, body AssetDownloadParams, opts ...option.RequestOption) (res *AssetDownloadResponse, err error)

Download a Matrix asset using its mxc:// or localmxc:// URL to the device running Beeper Desktop and return the local file URL.

type Attachment

type Attachment = shared.Attachment

This is an alias to an internal type.

type AttachmentSize

type AttachmentSize = shared.AttachmentSize

Pixel dimensions of the attachment: width/height in px.

This is an alias to an internal type.

type AttachmentType

type AttachmentType = shared.AttachmentType

Attachment type.

This is an alias to an internal type.

type Chat

type Chat struct {
	// Unique identifier of the chat across Beeper.
	ID string `json:"id,required"`
	// Account ID this chat belongs to.
	AccountID string `json:"accountID,required"`
	// Display-only human-readable network name (e.g., 'WhatsApp', 'Messenger').
	//
	// Deprecated: deprecated
	Network string `json:"network,required"`
	// Chat participants information.
	Participants ChatParticipants `json:"participants,required"`
	// Display title of the chat as computed by the client/server.
	Title string `json:"title,required"`
	// Chat type: 'single' for direct messages, 'group' for group chats.
	//
	// Any of "single", "group".
	Type ChatType `json:"type,required"`
	// Number of unread messages.
	UnreadCount int64 `json:"unreadCount,required"`
	// True if chat is archived.
	IsArchived bool `json:"isArchived"`
	// True if chat notifications are muted.
	IsMuted bool `json:"isMuted"`
	// True if chat is pinned.
	IsPinned bool `json:"isPinned"`
	// Timestamp of last activity.
	LastActivity time.Time `json:"lastActivity" format:"date-time"`
	// Last read message sortKey.
	LastReadMessageSortKey string `json:"lastReadMessageSortKey"`
	// Local chat ID specific to this Beeper Desktop installation.
	LocalChatID string `json:"localChatID,nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID                     respjson.Field
		AccountID              respjson.Field
		Network                respjson.Field
		Participants           respjson.Field
		Title                  respjson.Field
		Type                   respjson.Field
		UnreadCount            respjson.Field
		IsArchived             respjson.Field
		IsMuted                respjson.Field
		IsPinned               respjson.Field
		LastActivity           respjson.Field
		LastReadMessageSortKey respjson.Field
		LocalChatID            respjson.Field
		ExtraFields            map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (Chat) RawJSON

func (r Chat) RawJSON() string

Returns the unmodified JSON received from the API

func (*Chat) UnmarshalJSON

func (r *Chat) UnmarshalJSON(data []byte) error

type ChatArchiveParams

type ChatArchiveParams struct {
	// True to archive, false to unarchive
	Archived param.Opt[bool] `json:"archived,omitzero"`
	// contains filtered or unexported fields
}

func (ChatArchiveParams) MarshalJSON

func (r ChatArchiveParams) MarshalJSON() (data []byte, err error)

func (*ChatArchiveParams) UnmarshalJSON

func (r *ChatArchiveParams) UnmarshalJSON(data []byte) error

type ChatGetParams

type ChatGetParams struct {
	// Maximum number of participants to return. Use -1 for all; otherwise 0–500.
	// Defaults to all (-1).
	MaxParticipantCount param.Opt[int64] `query:"maxParticipantCount,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (ChatGetParams) URLQuery

func (r ChatGetParams) URLQuery() (v url.Values, err error)

URLQuery serializes ChatGetParams's query parameters as `url.Values`.

type ChatListParams

type ChatListParams struct {
	// Opaque pagination cursor; do not inspect. Use together with 'direction'.
	Cursor param.Opt[string] `query:"cursor,omitzero" json:"-"`
	// Limit to specific account IDs. If omitted, fetches from all accounts.
	AccountIDs []string `query:"accountIDs,omitzero" json:"-"`
	// Pagination direction used with 'cursor': 'before' fetches older results, 'after'
	// fetches newer results. Defaults to 'before' when only 'cursor' is provided.
	//
	// Any of "after", "before".
	Direction ChatListParamsDirection `query:"direction,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (ChatListParams) URLQuery

func (r ChatListParams) URLQuery() (v url.Values, err error)

URLQuery serializes ChatListParams's query parameters as `url.Values`.

type ChatListParamsDirection

type ChatListParamsDirection string

Pagination direction used with 'cursor': 'before' fetches older results, 'after' fetches newer results. Defaults to 'before' when only 'cursor' is provided.

const (
	ChatListParamsDirectionAfter  ChatListParamsDirection = "after"
	ChatListParamsDirectionBefore ChatListParamsDirection = "before"
)

type ChatListResponse

type ChatListResponse struct {
	// Last message preview for this chat, if available.
	Preview shared.Message `json:"preview"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Preview     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
	Chat
}

func (ChatListResponse) RawJSON

func (r ChatListResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*ChatListResponse) UnmarshalJSON

func (r *ChatListResponse) UnmarshalJSON(data []byte) error

type ChatNewParams

type ChatNewParams struct {
	// Account to create the chat on.
	AccountID string `json:"accountID,required"`
	// User IDs to include in the new chat.
	ParticipantIDs []string `json:"participantIDs,omitzero,required"`
	// Chat type to create: 'single' requires exactly one participantID; 'group'
	// supports multiple participants and optional title.
	//
	// Any of "single", "group".
	Type ChatNewParamsType `json:"type,omitzero,required"`
	// Optional first message content if the platform requires it to create the chat.
	MessageText param.Opt[string] `json:"messageText,omitzero"`
	// Optional title for group chats; ignored for single chats on most platforms.
	Title param.Opt[string] `json:"title,omitzero"`
	// contains filtered or unexported fields
}

func (ChatNewParams) MarshalJSON

func (r ChatNewParams) MarshalJSON() (data []byte, err error)

func (*ChatNewParams) UnmarshalJSON

func (r *ChatNewParams) UnmarshalJSON(data []byte) error

type ChatNewParamsType

type ChatNewParamsType string

Chat type to create: 'single' requires exactly one participantID; 'group' supports multiple participants and optional title.

const (
	ChatNewParamsTypeSingle ChatNewParamsType = "single"
	ChatNewParamsTypeGroup  ChatNewParamsType = "group"
)

type ChatNewResponse

type ChatNewResponse struct {
	// Newly created chat ID.
	ChatID string `json:"chatID,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ChatID      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ChatNewResponse) RawJSON

func (r ChatNewResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*ChatNewResponse) UnmarshalJSON

func (r *ChatNewResponse) UnmarshalJSON(data []byte) error

type ChatParticipants

type ChatParticipants struct {
	// True if there are more participants than included in items.
	HasMore bool `json:"hasMore,required"`
	// Participants returned for this chat (limited by the request; may be a subset).
	Items []shared.User `json:"items,required"`
	// Total number of participants in the chat.
	Total int64 `json:"total,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		HasMore     respjson.Field
		Items       respjson.Field
		Total       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Chat participants information.

func (ChatParticipants) RawJSON

func (r ChatParticipants) RawJSON() string

Returns the unmodified JSON received from the API

func (*ChatParticipants) UnmarshalJSON

func (r *ChatParticipants) UnmarshalJSON(data []byte) error

type ChatReminderNewParams

type ChatReminderNewParams struct {
	// Reminder configuration
	Reminder ChatReminderNewParamsReminder `json:"reminder,omitzero,required"`
	// contains filtered or unexported fields
}

func (ChatReminderNewParams) MarshalJSON

func (r ChatReminderNewParams) MarshalJSON() (data []byte, err error)

func (*ChatReminderNewParams) UnmarshalJSON

func (r *ChatReminderNewParams) UnmarshalJSON(data []byte) error

type ChatReminderNewParamsReminder

type ChatReminderNewParamsReminder struct {
	// Unix timestamp in milliseconds when reminder should trigger
	RemindAtMs float64 `json:"remindAtMs,required"`
	// Cancel reminder if someone messages in the chat
	DismissOnIncomingMessage param.Opt[bool] `json:"dismissOnIncomingMessage,omitzero"`
	// contains filtered or unexported fields
}

Reminder configuration

The property RemindAtMs is required.

func (ChatReminderNewParamsReminder) MarshalJSON

func (r ChatReminderNewParamsReminder) MarshalJSON() (data []byte, err error)

func (*ChatReminderNewParamsReminder) UnmarshalJSON

func (r *ChatReminderNewParamsReminder) UnmarshalJSON(data []byte) error

type ChatReminderService

type ChatReminderService struct {
	Options []option.RequestOption
}

Manage reminders for chats

ChatReminderService contains methods and other services that help with interacting with the beeperdesktop API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewChatReminderService method instead.

func NewChatReminderService

func NewChatReminderService(opts ...option.RequestOption) (r ChatReminderService)

NewChatReminderService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*ChatReminderService) Delete

func (r *ChatReminderService) Delete(ctx context.Context, chatID string, opts ...option.RequestOption) (err error)

Clear an existing reminder from a chat

func (*ChatReminderService) New

func (r *ChatReminderService) New(ctx context.Context, chatID string, body ChatReminderNewParams, opts ...option.RequestOption) (err error)

Set a reminder for a chat at a specific time

type ChatSearchParams

type ChatSearchParams struct {
	// Include chats marked as Muted by the user, which are usually less important.
	// Default: true. Set to false if the user wants a more refined search.
	IncludeMuted param.Opt[bool] `query:"includeMuted,omitzero" json:"-"`
	// Set to true to only retrieve chats that have unread messages
	UnreadOnly param.Opt[bool] `query:"unreadOnly,omitzero" json:"-"`
	// Opaque pagination cursor; do not inspect. Use together with 'direction'.
	Cursor param.Opt[string] `query:"cursor,omitzero" json:"-"`
	// Provide an ISO datetime string to only retrieve chats with last activity after
	// this time
	LastActivityAfter param.Opt[time.Time] `query:"lastActivityAfter,omitzero" format:"date-time" json:"-"`
	// Provide an ISO datetime string to only retrieve chats with last activity before
	// this time
	LastActivityBefore param.Opt[time.Time] `query:"lastActivityBefore,omitzero" format:"date-time" json:"-"`
	// Set the maximum number of chats to retrieve. Valid range: 1-200, default is 50
	Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
	// Literal token search (non-semantic). Use single words users type (e.g.,
	// "dinner"). When multiple words provided, ALL must match. Case-insensitive.
	Query param.Opt[string] `query:"query,omitzero" json:"-"`
	// Provide an array of account IDs to filter chats from specific messaging accounts
	// only
	AccountIDs []string `query:"accountIDs,omitzero" json:"-"`
	// Pagination direction used with 'cursor': 'before' fetches older results, 'after'
	// fetches newer results. Defaults to 'before' when only 'cursor' is provided.
	//
	// Any of "after", "before".
	Direction ChatSearchParamsDirection `query:"direction,omitzero" json:"-"`
	// Filter by inbox type: "primary" (non-archived, non-low-priority),
	// "low-priority", or "archive". If not specified, shows all chats.
	//
	// Any of "primary", "low-priority", "archive".
	Inbox ChatSearchParamsInbox `query:"inbox,omitzero" json:"-"`
	// Search scope: 'titles' matches title + network; 'participants' matches
	// participant names.
	//
	// Any of "titles", "participants".
	Scope ChatSearchParamsScope `query:"scope,omitzero" json:"-"`
	// Specify the type of chats to retrieve: use "single" for direct messages, "group"
	// for group chats, or "any" to get all types
	//
	// Any of "single", "group", "any".
	Type ChatSearchParamsType `query:"type,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (ChatSearchParams) URLQuery

func (r ChatSearchParams) URLQuery() (v url.Values, err error)

URLQuery serializes ChatSearchParams's query parameters as `url.Values`.

type ChatSearchParamsDirection

type ChatSearchParamsDirection string

Pagination direction used with 'cursor': 'before' fetches older results, 'after' fetches newer results. Defaults to 'before' when only 'cursor' is provided.

const (
	ChatSearchParamsDirectionAfter  ChatSearchParamsDirection = "after"
	ChatSearchParamsDirectionBefore ChatSearchParamsDirection = "before"
)

type ChatSearchParamsInbox

type ChatSearchParamsInbox string

Filter by inbox type: "primary" (non-archived, non-low-priority), "low-priority", or "archive". If not specified, shows all chats.

const (
	ChatSearchParamsInboxPrimary     ChatSearchParamsInbox = "primary"
	ChatSearchParamsInboxLowPriority ChatSearchParamsInbox = "low-priority"
	ChatSearchParamsInboxArchive     ChatSearchParamsInbox = "archive"
)

type ChatSearchParamsScope

type ChatSearchParamsScope string

Search scope: 'titles' matches title + network; 'participants' matches participant names.

const (
	ChatSearchParamsScopeTitles       ChatSearchParamsScope = "titles"
	ChatSearchParamsScopeParticipants ChatSearchParamsScope = "participants"
)

type ChatSearchParamsType

type ChatSearchParamsType string

Specify the type of chats to retrieve: use "single" for direct messages, "group" for group chats, or "any" to get all types

const (
	ChatSearchParamsTypeSingle ChatSearchParamsType = "single"
	ChatSearchParamsTypeGroup  ChatSearchParamsType = "group"
	ChatSearchParamsTypeAny    ChatSearchParamsType = "any"
)

type ChatService

type ChatService struct {
	Options []option.RequestOption
	// Manage reminders for chats
	Reminders ChatReminderService
}

Manage chats

ChatService contains methods and other services that help with interacting with the beeperdesktop API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewChatService method instead.

func NewChatService

func NewChatService(opts ...option.RequestOption) (r ChatService)

NewChatService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*ChatService) Archive

func (r *ChatService) Archive(ctx context.Context, chatID string, body ChatArchiveParams, opts ...option.RequestOption) (err error)

Archive or unarchive a chat. Set archived=true to move to archive, archived=false to move back to inbox

func (*ChatService) Get

func (r *ChatService) Get(ctx context.Context, chatID string, query ChatGetParams, opts ...option.RequestOption) (res *Chat, err error)

Retrieve chat details including metadata, participants, and latest message

func (*ChatService) List

List all chats sorted by last activity (most recent first). Combines all accounts into a single paginated list.

func (*ChatService) ListAutoPaging

List all chats sorted by last activity (most recent first). Combines all accounts into a single paginated list.

func (*ChatService) New

func (r *ChatService) New(ctx context.Context, body ChatNewParams, opts ...option.RequestOption) (res *ChatNewResponse, err error)

Create a single or group chat on a specific account using participant IDs and optional title.

func (*ChatService) Search

func (r *ChatService) Search(ctx context.Context, query ChatSearchParams, opts ...option.RequestOption) (res *pagination.CursorSearch[Chat], err error)

Search chats by title/network or participants using Beeper Desktop's renderer algorithm.

func (*ChatService) SearchAutoPaging

Search chats by title/network or participants using Beeper Desktop's renderer algorithm.

type ChatType

type ChatType string

Chat type: 'single' for direct messages, 'group' for group chats.

const (
	ChatTypeSingle ChatType = "single"
	ChatTypeGroup  ChatType = "group"
)

type Client

type Client struct {
	Options []option.RequestOption
	// Manage connected chat accounts
	Accounts AccountService
	// Manage chats
	Chats ChatService
	// Manage messages in chats
	Messages MessageService
	// Manage assets in Beeper Desktop, like message attachments
	Assets AssetService
}

Client creates a struct with services and top level methods that help with interacting with the beeperdesktop API. You should not instantiate this client directly, and instead use the NewClient method instead.

func NewClient

func NewClient(opts ...option.RequestOption) (r Client)

NewClient generates a new client with the default option read from the environment (BEEPER_ACCESS_TOKEN, BEEPER_DESKTOP_BASE_URL). The option passed in as arguments are applied after these default arguments, and all option will be passed down to the services and requests that this client makes.

func (*Client) Delete

func (r *Client) Delete(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error

Delete makes a DELETE request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Execute

func (r *Client) Execute(ctx context.Context, method string, path string, params any, res any, opts ...option.RequestOption) error

Execute makes a request with the given context, method, URL, request params, response, and request options. This is useful for hitting undocumented endpoints while retaining the base URL, auth, retries, and other options from the client.

If a byte slice or an io.Reader is supplied to params, it will be used as-is for the request body.

The params is by default serialized into the body using encoding/json. If your type implements a MarshalJSON function, it will be used instead to serialize the request. If a URLQuery method is implemented, the returned url.Values will be used as query strings to the url.

If your params struct uses param.Field, you must provide either [MarshalJSON], [URLQuery], and/or [MarshalForm] functions. It is undefined behavior to use a struct uses param.Field without specifying how it is serialized.

Any "…Params" object defined in this library can be used as the request argument. Note that 'path' arguments will not be forwarded into the url.

The response body will be deserialized into the res variable, depending on its type:

  • A pointer to a *http.Response is populated by the raw response.
  • A pointer to a byte array will be populated with the contents of the request body.
  • A pointer to any other type uses this library's default JSON decoding, which respects UnmarshalJSON if it is defined on the type.
  • A nil value will not read the response body.

For even greater flexibility, see option.WithResponseInto and option.WithResponseBodyInto.

func (*Client) Focus

func (r *Client) Focus(ctx context.Context, body FocusParams, opts ...option.RequestOption) (res *FocusResponse, err error)

Focus Beeper Desktop and optionally navigate to a specific chat, message, or pre-fill draft text and attachment.

func (*Client) Get

func (r *Client) Get(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error

Get makes a GET request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Patch

func (r *Client) Patch(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error

Patch makes a PATCH request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Post

func (r *Client) Post(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error

Post makes a POST request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Put

func (r *Client) Put(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error

Put makes a PUT request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Search

func (r *Client) Search(ctx context.Context, query SearchParams, opts ...option.RequestOption) (res *SearchResponse, err error)

Returns matching chats, participant name matches in groups, and the first page of messages in one call. Paginate messages via search-messages. Paginate chats via search-chats. Uses the same sorting as the chat search in the app.

type Error

type Error = apierror.Error

type FocusParams

type FocusParams struct {
	// Optional Beeper chat ID (or local chat ID) to focus after opening the app. If
	// omitted, only opens/focuses the app.
	ChatID param.Opt[string] `json:"chatID,omitzero"`
	// Optional draft attachment path to populate in the message input field.
	DraftAttachmentPath param.Opt[string] `json:"draftAttachmentPath,omitzero"`
	// Optional draft text to populate in the message input field.
	DraftText param.Opt[string] `json:"draftText,omitzero"`
	// Optional message ID. Jumps to that message in the chat when opening.
	MessageID param.Opt[string] `json:"messageID,omitzero"`
	// contains filtered or unexported fields
}

func (FocusParams) MarshalJSON

func (r FocusParams) MarshalJSON() (data []byte, err error)

func (*FocusParams) UnmarshalJSON

func (r *FocusParams) UnmarshalJSON(data []byte) error

type FocusResponse

type FocusResponse struct {
	// Whether the app was successfully opened/focused.
	Success bool `json:"success,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Response indicating successful app focus action.

func (FocusResponse) RawJSON

func (r FocusResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*FocusResponse) UnmarshalJSON

func (r *FocusResponse) UnmarshalJSON(data []byte) error

type Message

type Message = shared.Message

This is an alias to an internal type.

type MessageListParams

type MessageListParams struct {
	// Opaque pagination cursor; do not inspect. Use together with 'direction'.
	Cursor param.Opt[string] `query:"cursor,omitzero" json:"-"`
	// Pagination direction used with 'cursor': 'before' fetches older results, 'after'
	// fetches newer results. Defaults to 'before' when only 'cursor' is provided.
	//
	// Any of "after", "before".
	Direction MessageListParamsDirection `query:"direction,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (MessageListParams) URLQuery

func (r MessageListParams) URLQuery() (v url.Values, err error)

URLQuery serializes MessageListParams's query parameters as `url.Values`.

type MessageListParamsDirection

type MessageListParamsDirection string

Pagination direction used with 'cursor': 'before' fetches older results, 'after' fetches newer results. Defaults to 'before' when only 'cursor' is provided.

const (
	MessageListParamsDirectionAfter  MessageListParamsDirection = "after"
	MessageListParamsDirectionBefore MessageListParamsDirection = "before"
)

type MessageSearchParams

type MessageSearchParams struct {
	// Exclude messages marked Low Priority by the user. Default: true. Set to false to
	// include all.
	ExcludeLowPriority param.Opt[bool] `query:"excludeLowPriority,omitzero" json:"-"`
	// Include messages in chats marked as Muted by the user, which are usually less
	// important. Default: true. Set to false if the user wants a more refined search.
	IncludeMuted param.Opt[bool] `query:"includeMuted,omitzero" json:"-"`
	// Opaque pagination cursor; do not inspect. Use together with 'direction'.
	Cursor param.Opt[string] `query:"cursor,omitzero" json:"-"`
	// Only include messages with timestamp strictly after this ISO 8601 datetime
	// (e.g., '2024-07-01T00:00:00Z' or '2024-07-01T00:00:00+02:00').
	DateAfter param.Opt[time.Time] `query:"dateAfter,omitzero" format:"date-time" json:"-"`
	// Only include messages with timestamp strictly before this ISO 8601 datetime
	// (e.g., '2024-07-31T23:59:59Z' or '2024-07-31T23:59:59+02:00').
	DateBefore param.Opt[time.Time] `query:"dateBefore,omitzero" format:"date-time" json:"-"`
	// Maximum number of messages to return.
	Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
	// Literal word search (NOT semantic). Finds messages containing these EXACT words
	// in any order. Use single words users actually type, not concepts or phrases.
	// Example: use "dinner" not "dinner plans", use "sick" not "health issues". If
	// omitted, returns results filtered only by other parameters.
	Query param.Opt[string] `query:"query,omitzero" json:"-"`
	// Limit search to specific account IDs.
	AccountIDs []string `query:"accountIDs,omitzero" json:"-"`
	// Limit search to specific chat IDs.
	ChatIDs []string `query:"chatIDs,omitzero" json:"-"`
	// Filter by chat type: 'group' for group chats, 'single' for 1:1 chats.
	//
	// Any of "group", "single".
	ChatType MessageSearchParamsChatType `query:"chatType,omitzero" json:"-"`
	// Pagination direction used with 'cursor': 'before' fetches older results, 'after'
	// fetches newer results. Defaults to 'before' when only 'cursor' is provided.
	//
	// Any of "after", "before".
	Direction MessageSearchParamsDirection `query:"direction,omitzero" json:"-"`
	// Filter messages by media types. Use ['any'] for any media type, or specify exact
	// types like ['video', 'image']. Omit for no media filtering.
	//
	// Any of "any", "video", "image", "link", "file".
	MediaTypes []string `query:"mediaTypes,omitzero" json:"-"`
	// Filter by sender: 'me' (messages sent by the authenticated user), 'others'
	// (messages sent by others), or a specific user ID string (user.id).
	Sender MessageSearchParamsSender `query:"sender,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (MessageSearchParams) URLQuery

func (r MessageSearchParams) URLQuery() (v url.Values, err error)

URLQuery serializes MessageSearchParams's query parameters as `url.Values`.

type MessageSearchParamsChatType

type MessageSearchParamsChatType string

Filter by chat type: 'group' for group chats, 'single' for 1:1 chats.

const (
	MessageSearchParamsChatTypeGroup  MessageSearchParamsChatType = "group"
	MessageSearchParamsChatTypeSingle MessageSearchParamsChatType = "single"
)

type MessageSearchParamsDirection

type MessageSearchParamsDirection string

Pagination direction used with 'cursor': 'before' fetches older results, 'after' fetches newer results. Defaults to 'before' when only 'cursor' is provided.

const (
	MessageSearchParamsDirectionAfter  MessageSearchParamsDirection = "after"
	MessageSearchParamsDirectionBefore MessageSearchParamsDirection = "before"
)

type MessageSearchParamsSender

type MessageSearchParamsSender string

Filter by sender: 'me' (messages sent by the authenticated user), 'others' (messages sent by others), or a specific user ID string (user.id).

const (
	MessageSearchParamsSenderMe     MessageSearchParamsSender = "me"
	MessageSearchParamsSenderOthers MessageSearchParamsSender = "others"
)

type MessageSendParams

type MessageSendParams struct {
	// Provide a message ID to send this as a reply to an existing message
	ReplyToMessageID param.Opt[string] `json:"replyToMessageID,omitzero"`
	// Text content of the message you want to send. You may use markdown.
	Text param.Opt[string] `json:"text,omitzero"`
	// contains filtered or unexported fields
}

func (MessageSendParams) MarshalJSON

func (r MessageSendParams) MarshalJSON() (data []byte, err error)

func (*MessageSendParams) UnmarshalJSON

func (r *MessageSendParams) UnmarshalJSON(data []byte) error

type MessageSendResponse

type MessageSendResponse struct {
	// Unique identifier of the chat.
	ChatID string `json:"chatID,required"`
	// Pending message ID
	PendingMessageID string `json:"pendingMessageID,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ChatID           respjson.Field
		PendingMessageID respjson.Field
		ExtraFields      map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (MessageSendResponse) RawJSON

func (r MessageSendResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*MessageSendResponse) UnmarshalJSON

func (r *MessageSendResponse) UnmarshalJSON(data []byte) error

type MessageService

type MessageService struct {
	Options []option.RequestOption
}

Manage messages in chats

MessageService contains methods and other services that help with interacting with the beeperdesktop API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewMessageService method instead.

func NewMessageService

func NewMessageService(opts ...option.RequestOption) (r MessageService)

NewMessageService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*MessageService) List

List all messages in a chat with cursor-based pagination. Sorted by timestamp.

func (*MessageService) ListAutoPaging

List all messages in a chat with cursor-based pagination. Sorted by timestamp.

func (*MessageService) Search

Search messages across chats using Beeper's message index

func (*MessageService) SearchAutoPaging

Search messages across chats using Beeper's message index

func (*MessageService) Send

func (r *MessageService) Send(ctx context.Context, chatID string, body MessageSendParams, opts ...option.RequestOption) (res *MessageSendResponse, err error)

Send a text message to a specific chat. Supports replying to existing messages. Returns the sent message ID.

type Reaction

type Reaction = shared.Reaction

This is an alias to an internal type.

type SearchParams

type SearchParams struct {
	// User-typed search text. Literal word matching (NOT semantic).
	Query string `query:"query,required" json:"-"`
	// contains filtered or unexported fields
}

func (SearchParams) URLQuery

func (r SearchParams) URLQuery() (v url.Values, err error)

URLQuery serializes SearchParams's query parameters as `url.Values`.

type SearchResponse

type SearchResponse struct {
	Results SearchResponseResults `json:"results,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Results     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SearchResponse) RawJSON

func (r SearchResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*SearchResponse) UnmarshalJSON

func (r *SearchResponse) UnmarshalJSON(data []byte) error

type SearchResponseResults

type SearchResponseResults struct {
	// Top chat results.
	Chats []Chat `json:"chats,required"`
	// Top group results by participant matches.
	InGroups []Chat                        `json:"in_groups,required"`
	Messages SearchResponseResultsMessages `json:"messages,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Chats       respjson.Field
		InGroups    respjson.Field
		Messages    respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SearchResponseResults) RawJSON

func (r SearchResponseResults) RawJSON() string

Returns the unmodified JSON received from the API

func (*SearchResponseResults) UnmarshalJSON

func (r *SearchResponseResults) UnmarshalJSON(data []byte) error

type SearchResponseResultsMessages

type SearchResponseResultsMessages struct {
	// Map of chatID -> chat details for chats referenced in items.
	Chats map[string]Chat `json:"chats,required"`
	// True if additional results can be fetched using the provided cursors.
	HasMore bool `json:"hasMore,required"`
	// Messages matching the query and filters.
	Items []shared.Message `json:"items,required"`
	// Cursor for fetching newer results (use with direction='after'). Opaque string;
	// do not inspect.
	NewestCursor string `json:"newestCursor,required"`
	// Cursor for fetching older results (use with direction='before'). Opaque string;
	// do not inspect.
	OldestCursor string `json:"oldestCursor,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Chats        respjson.Field
		HasMore      respjson.Field
		Items        respjson.Field
		NewestCursor respjson.Field
		OldestCursor respjson.Field
		ExtraFields  map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SearchResponseResultsMessages) RawJSON

Returns the unmodified JSON received from the API

func (*SearchResponseResultsMessages) UnmarshalJSON

func (r *SearchResponseResultsMessages) UnmarshalJSON(data []byte) error

type User

type User = shared.User

User the account belongs to.

This is an alias to an internal type.

Directories

Path Synopsis
encoding/json
Package json implements encoding and decoding of JSON as defined in RFC 7159.
Package json implements encoding and decoding of JSON as defined in RFC 7159.
encoding/json/shims
This package provides shims over Go 1.2{2,3} APIs which are missing from Go 1.22, and used by the Go 1.24 encoding/json package.
This package provides shims over Go 1.2{2,3} APIs which are missing from Go 1.22, and used by the Go 1.24 encoding/json package.
packages

Jump to

Keyboard shortcuts

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