### Run Example Source: https://github.com/beeper/desktop-api-go/blob/main/CONTRIBUTING.md Execute your added example using the go run command. ```sh $ go run ./examples/ ``` -------------------------------- ### Add Example to Project Source: https://github.com/beeper/desktop-api-go/blob/main/CONTRIBUTING.md Add new example files to the examples/ directory. The generator will not modify these files. ```go # add an example to examples//main.go package main func main() { // ... } ``` -------------------------------- ### Bootstrap and Lint Project Source: https://github.com/beeper/desktop-api-go/blob/main/CONTRIBUTING.md Run these commands to install dependencies and build the SDK. Ensure Go 1.22+ is installed. ```sh $ ./scripts/bootstrap $ ./scripts/lint ``` -------------------------------- ### Installation Source: https://github.com/beeper/desktop-api-go/blob/main/README.md Import the Beeper Desktop Go library into your project. You can use the latest version or pin a specific version. ```Go import ( "github.com/beeper/desktop-api-go/v5" ) // imported as beeperdesktopapi ``` ```Shell go get -u 'github.com/beeper/desktop-api-go@v5.0.0' ``` -------------------------------- ### Run Mock Server Source: https://github.com/beeper/desktop-api-go/blob/main/CONTRIBUTING.md Set up a mock server against the OpenAPI spec to run tests. Refer to the steady repository for setup details. ```sh $ ./scripts/mock ``` -------------------------------- ### Start New Chat Source: https://github.com/beeper/desktop-api-go/blob/main/api.md Initiates a new chat. This is the entry point for creating new conversations, requiring parameters to define the chat's initial state or participants. ```go client.Chats.Start(ctx context.Context, body beeperdesktopapi.ChatStartParams) (*beeperdesktopapi.ChatStartResponse, error) ``` -------------------------------- ### Start New Chat Source: https://github.com/beeper/desktop-api-go/blob/main/api.md Initiates a new chat. This operation requires a request body containing the parameters needed to start a new chat. ```APIDOC ## POST /v1/chats/start ### Description Starts a new chat conversation. ### Method POST ### Endpoint /v1/chats/start ### Parameters #### Request Body - **body** (ChatStartParams) - Required - Parameters required to start a new chat. ``` -------------------------------- ### Get Info Source: https://github.com/beeper/desktop-api-go/blob/main/api.md Retrieves general information about the Beeper Desktop API service. ```APIDOC ## GET /v1/info ### Description Retrieves general information about the Beeper Desktop API service. ### Method GET ### Endpoint /v1/info ### Response #### Success Response (200) - **InfoGetResponse** (*beeperdesktopapi.InfoGetResponse) - Information about the service. ``` -------------------------------- ### Pin Beeper Desktop Go API Version Source: https://github.com/beeper/desktop-api-go/blob/main/README.md Use this command to get a specific version of the Beeper Desktop Go library, ensuring compatibility with your project. ```sh go get -u 'github.com/beeper/desktop-api-go@v5.0.0' ``` -------------------------------- ### Create a New Chat Source: https://github.com/beeper/desktop-api-go/blob/main/api.md Initiates a new chat. This method is used to start a conversation, potentially with specific participants or initial messages. ```APIDOC ## POST /v1/chats ### Description Creates a new chat. ### Method POST ### Endpoint /v1/chats ### Request Body - **body** (beeperdesktopapi.ChatNewParams) - Required - Parameters for creating a new chat. ### Response #### Success Response (200) - **ChatNewResponse** (beeperdesktopapi.ChatNewResponse) - Details of the newly created chat. ``` -------------------------------- ### Get Message Source: https://github.com/beeper/desktop-api-go/blob/main/api.md Retrieves a specific message by its ID within a given chat. ```APIDOC ## GET /v1/chats/{chatID}/messages/{messageID} ### Description Retrieves a specific message by its ID within a given chat. ### Method GET ### Endpoint /v1/chats/{chatID}/messages/{messageID} ### Parameters #### Path Parameters - **chatID** (string) - Required - The ID of the chat. - **messageID** (string) - Required - The ID of the message. #### Query Parameters - **query** (beeperdesktopapi.MessageGetParams) - Required - Parameters for fetching the message. ``` -------------------------------- ### Get Chat Details Source: https://github.com/beeper/desktop-api-go/blob/main/api.md Retrieves detailed information about a specific chat using its unique identifier. ```APIDOC ## GET /v1/chats/{chatID} ### Description Retrieves details for a specific chat. ### Method GET ### Endpoint /v1/chats/{chatID} ### Parameters #### Path Parameters - **chatID** (string) - Required - The unique identifier of the chat. #### Query Parameters - **query** (beeperdesktopapi.ChatGetParams) - Optional - Parameters for retrieving chat details. ### Response #### Success Response (200) - **Chat** (beeperdesktopapi.Chat) - Detailed information about the chat. ``` -------------------------------- ### Initialize Beeper Desktop API Client and Search Chats Source: https://github.com/beeper/desktop-api-go/blob/main/README.md Demonstrates how to initialize the Beeper Desktop API client with an access token and perform a chat search. Requires Go 1.22+ and the 'github.com/beeper/desktop-api-go/v5' package. ```go package main import ( "context" "fmt" "github.com/beeper/desktop-api-go/v5" "github.com/beeper/desktop-api-go/v5/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{ AccountIDs: []string{"matrix", "discordgo", "local-whatsapp_ba_EvYDBBsZbRQAy3UOSWqG0LuTVkc"}, IncludeMuted: beeperdesktopapi.Bool(true), Limit: beeperdesktopapi.Int(3), Type: beeperdesktopapi.ChatSearchParamsTypeSingle, }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` -------------------------------- ### Run Tests Source: https://github.com/beeper/desktop-api-go/blob/main/CONTRIBUTING.md Execute the project's test suite. Ensure the mock server is running. ```sh $ ./scripts/test ``` -------------------------------- ### Configure Client and Requests with Functional Options in Go Source: https://github.com/beeper/desktop-api-go/blob/main/README.md Illustrates the use of functional options to configure the API client and individual requests. Options like `WithHeader` and `WithJSONSet` modify request behavior. ```go 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"}), ) ``` -------------------------------- ### Define and Use Request Union Parameters Source: https://github.com/beeper/desktop-api-go/blob/main/README.md Demonstrates the structure of union parameters where only one field can be non-zero. Shows how to initialize a union and access/mutate its sub-properties using generated methods. ```go // 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 } ``` -------------------------------- ### File Uploads with io.Reader Source: https://github.com/beeper/desktop-api-go/blob/main/README.md Demonstrates how to upload files using io.Reader. The filename and content-type can be customized by implementing Name() or ContentType() methods on the reader, or by using the beeperdesktopapi.File helper function. ```go // A file from the file system file, err := os.Open("/path/to/file") beeperdesktopapi.AssetUploadParams{ File: file, } ``` ```go // A file from a string beeperdesktopapi.AssetUploadParams{ File: strings.NewReader("my file contents"), } ``` ```go // With a custom filename and contentType beeperdesktopapi.AssetUploadParams{ File: beeperdesktopapi.File(strings.NewReader(`{"hello": "foo"}`), "file.go", "application/json"), } ``` -------------------------------- ### Import Beeper Desktop Go API Source: https://github.com/beeper/desktop-api-go/blob/main/README.md Import the Beeper Desktop Go library for use in your project. This is the standard import path for the latest version. ```go import ( "github.com/beeper/desktop-api-go/v5" ) // imported as beeperdesktopapi ``` -------------------------------- ### Fetching Single Page with GetNextPage in Go Source: https://github.com/beeper/desktop-api-go/blob/main/README.md Demonstrates fetching a single page of results using `.List()` and then using `.GetNextPage()` to retrieve subsequent pages. This provides more control over pagination. ```go page, err := client.Messages.Search(context.TODO(), beeperdesktopapi.MessageSearchParams{ AccountIDs: []string{"discordgo", "local-whatsapp_ba_EvYDBBsZbRQAy3UOSWqG0LuTVkc"}, Limit: beeperdesktopapi.Int(10), Query: beeperdesktopapi.String("oauth"), }) for page != nil { for _, message := range page.Items { fmt.Printf("%+v\n", message) } page, err = page.GetNextPage() } if err != nil { panic(err.Error()) } ``` -------------------------------- ### Configure Request Retries Source: https://github.com/beeper/desktop-api-go/blob/main/README.md Shows how to configure the default number of retries for all requests using option.WithMaxRetries(0) when creating a new client, or override it for a specific request. ```go // Configure the default for all requests: client := beeperdesktopapi.NewClient( option.WithMaxRetries(0), // default is 2 ) ``` ```go // Override per-request: client.Accounts.List(context.TODO(), option.WithMaxRetries(5)) ``` -------------------------------- ### Auto-Paging List Results in Go Source: https://github.com/beeper/desktop-api-go/blob/main/README.md Shows how to use `.ListAutoPaging()` for iterating through all items across multiple pages of a list endpoint. This method automatically fetches subsequent pages as needed. ```go iter := client.Messages.SearchAutoPaging(context.TODO(), beeperdesktopapi.MessageSearchParams{ AccountIDs: []string{"discordgo", "local-whatsapp_ba_EvYDBBsZbRQAy3UOSWqG0LuTVkc"}, Limit: beeperdesktopapi.Int(10), Query: beeperdesktopapi.String("oauth"), }) // 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()) } ``` -------------------------------- ### Use Local Repository from Source Source: https://github.com/beeper/desktop-api-go/blob/main/CONTRIBUTING.md Modify your go.mod file with a replace directive to use a local version of the library. This is useful for development. ```sh $ go mod edit -replace github.com/beeper/desktop-api-go=/path/to/desktop-api-go ``` -------------------------------- ### Define Request Parameters with OmitZero Semantics Source: https://github.com/beeper/desktop-api-go/blob/main/README.md Demonstrates how to define request parameters using `omitzero` semantics for both required and optional fields. Optional fields use `param.Opt[T]` and are omitted if their zero value is not explicitly set. ```go 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 } ``` -------------------------------- ### Serve Asset Source: https://github.com/beeper/desktop-api-go/blob/main/api.md Serves an asset based on the provided query parameters. Returns an http.Response. ```APIDOC ## GET /v1/assets/serve ### Description Serves an asset based on the provided query parameters. ### Method GET ### Endpoint /v1/assets/serve ### Query Parameters - **query** (AssetServeParams) - Required - Parameters for serving an asset. ### Response #### Success Response (200) - **http.Response** - The HTTP response containing the asset. ``` -------------------------------- ### Access Raw HTTP Response Data Source: https://github.com/beeper/desktop-api-go/blob/main/README.md Demonstrates how to access raw HTTP response data, such as headers and status codes, using the option.WithResponseInto() request option. Ensure to handle potential errors during the request. ```go // 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) ``` -------------------------------- ### Handle API Errors using errors.As in Go Source: https://github.com/beeper/desktop-api-go/blob/main/README.md Explains how to handle API errors, which are returned as `*beeperdesktopapi.Error` for non-success status codes. Use `errors.As` to check for and extract API error details, including request and response dumps. ```go _, err := client.Accounts.List(context.TODO()) if err != nil { var apierr *beeperdesktopapi.Error if errors.As(err, &apierr) { println(string(apierr.DumpRequest(true))) println(string(apierr.DumpResponse(true))) } panic(err.Error()) // GET "/v1/accounts": 400 Bad Request { ... } } ``` -------------------------------- ### Download Asset Source: https://github.com/beeper/desktop-api-go/blob/main/api.md Initiates the download of an asset. Requires AssetDownloadParams to specify download details. ```APIDOC ## POST /v1/assets/download ### Description Initiates the download of an asset. ### Method POST ### Endpoint /v1/assets/download ### Request Body - **body** (AssetDownloadParams) - Required - Parameters for downloading an asset. ### Response #### Success Response (200) - **AssetDownloadResponse** (*beeperdesktopapi.AssetDownloadResponse) - Details of the downloaded asset. ``` -------------------------------- ### Add Undocumented Request Parameters Source: https://github.com/beeper/desktop-api-go/blob/main/README.md Shows how to add undocumented parameters to a request using option.WithQuerySet() or option.WithJSONSet(). This is useful for interacting with endpoints that have parameters not explicitly defined in the client library. ```go params := FooNewParams{ ID: "id_xxxx", Data: FooNewParamsData{ FirstName: beeperdesktopapi.String("John"), }, } client.Foo.New(context.Background(), params, option.WithJSONSet("data.last_name", "Doe")) ``` -------------------------------- ### Make Undocumented POST Requests Source: https://github.com/beeper/desktop-api-go/blob/main/README.md Illustrates how to make POST requests to undocumented endpoints using client.Post. The params can be an io.Reader, []byte, JSON serializable object, or a "...Params" struct. The result can be []byte, *http.Response, JSON deserializable object, or a library-defined model. ```go 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 { … } ``` -------------------------------- ### Handle Response Unions in Go Source: https://github.com/beeper/desktop-api-go/blob/main/README.md Demonstrates how to define and interact with union types in API responses. Use `.AsFooVariant()` or `.AsAny()` to convert to a specific variant. Primitive fields in unions are prefixed with 'Of' and use `json:"...,inline`. ```go 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") } ``` -------------------------------- ### Send Null Instead of Optional Fields or Structs Source: https://github.com/beeper/desktop-api-go/blob/main/README.md Shows how to explicitly send `null` for optional fields (`param.Opt[T]`) or struct types using `param.Null[T]()` and `param.NullStruct[T]()`. Includes checks for nullability using `param.IsNull()`. ```go 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 ``` -------------------------------- ### Create Chat Reminder Source: https://github.com/beeper/desktop-api-go/blob/main/api.md Use this method to create a new reminder for a specific chat. Requires chat ID and reminder parameters. ```go client.Chats.Reminders.New(ctx, chatID, body) ``` -------------------------------- ### Configure Request Timeouts in Go Source: https://github.com/beeper/desktop-api-go/blob/main/README.md Details how to set request timeouts using `context.WithTimeout` for the entire request lifecycle, including retries. For per-retry timeouts, use `option.WithRequestTimeout()`. ```go // 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), ) ``` -------------------------------- ### Format Code Source: https://github.com/beeper/desktop-api-go/blob/main/CONTRIBUTING.md Apply the standard gofmt code formatter to maintain consistent code style. ```sh $ ./scripts/format ``` -------------------------------- ### Apply Custom Middleware to Beeper Client Source: https://github.com/beeper/desktop-api-go/blob/main/README.md Define and apply a custom middleware function to the Beeper client to intercept and process requests. The middleware receives the request and a `next` function to forward the request. Ensure the middleware handles request and response logging or modification as needed. ```go 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), ) ``` -------------------------------- ### Handle Optional Response Fields and Raw JSON Values Source: https://github.com/beeper/desktop-api-go/blob/main/README.md Explains how to use the `.Valid()` method on the `JSON` field to check for the presence and validity of optional response data. Demonstrates accessing raw JSON values, including `null` and omitted fields. ```go 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 ``` -------------------------------- ### Define Response Object Structure with Metadata Source: https://github.com/beeper/desktop-api-go/blob/main/README.md Shows the structure of response objects, where fields are ordinary types and a special `JSON` struct provides metadata for each property, including its validity and raw JSON value. ```go 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:"-" } ``` -------------------------------- ### Upload Asset Source: https://github.com/beeper/desktop-api-go/blob/main/api.md Uploads an asset using the provided parameters. Returns AssetUploadResponse. ```APIDOC ## POST /v1/assets/upload ### Description Uploads an asset using the provided parameters. ### Method POST ### Endpoint /v1/assets/upload ### Request Body - **body** (AssetUploadParams) - Required - Parameters for uploading an asset. ### Response #### Success Response (200) - **AssetUploadResponse** (*beeperdesktopapi.AssetUploadResponse) - Details of the uploaded asset. ``` -------------------------------- ### Upload Asset Base64 Source: https://github.com/beeper/desktop-api-go/blob/main/api.md Uploads an asset encoded in Base64 format. Returns AssetUploadBase64Response. ```APIDOC ## POST /v1/assets/upload/base64 ### Description Uploads an asset encoded in Base64 format. ### Method POST ### Endpoint /v1/assets/upload/base64 ### Request Body - **body** (AssetUploadBase64Params) - Required - Parameters for uploading a Base64 encoded asset. ### Response #### Success Response (200) - **AssetUploadBase64Response** (*beeperdesktopapi.AssetUploadBase64Response) - Details of the uploaded Base64 asset. ``` -------------------------------- ### Send Extra Fields and Override Struct Types Source: https://github.com/beeper/desktop-api-go/blob/main/README.md Illustrates using `SetExtraFields` to send non-conforming fields that overwrite struct fields, and `param.Override[T](value)` to send a custom value instead of a struct. Use `SetExtraFields` with trusted data only. ```go // 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) ``` -------------------------------- ### List Accounts Source: https://github.com/beeper/desktop-api-go/blob/main/api.md Retrieves a list of all accounts configured in the Beeper client. This is useful for managing multiple Beeper accounts. ```APIDOC ## GET /v1/accounts ### Description Retrieves a list of all accounts configured in the Beeper client. ### Method GET ### Endpoint /v1/accounts ### Response #### Success Response (200) - **Account** ([]beeperdesktopapi.Account) - A list of account objects. ``` -------------------------------- ### Request Fields Source: https://github.com/beeper/desktop-api-go/blob/main/README.md Explains how request fields are handled, including required, optional, and zero-value omissions using `omitzero` semantics. ```APIDOC ## Request Fields The beeperdesktopapi library uses the [`omitzero`](https://tip.golang.org/doc/go1.24#encodingjsonpkgencodingjson) semantics from the Go 1.24+ `encoding/json` release for request fields. Required primitive fields (`int64`, `string`, etc.) feature the tag `api:"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. ```go 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]()`. ```go 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)`. ```go // 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) ``` ``` -------------------------------- ### Response Objects Source: https://github.com/beeper/desktop-api-go/blob/main/README.md Details the structure of response objects, including regular fields, metadata via the `JSON` field, and handling of optional data. ```APIDOC ## 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. ```go 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. ```go 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. ```go body := res.JSON.ExtraFields["my_unexpected_field"].Raw() ``` ``` -------------------------------- ### Create Chat Reminder Source: https://github.com/beeper/desktop-api-go/blob/main/api.md Creates a new reminder for a specific chat. Requires chatID and reminder parameters. ```APIDOC ## POST /v1/chats/{chatID}/reminders ### Description Creates a new reminder for a specific chat. ### Method POST ### Endpoint /v1/chats/{chatID}/reminders ### Parameters #### Path Parameters - **chatID** (string) - Required - The ID of the chat to add a reminder to. #### Request Body - **body** (beeperdesktopapi.ChatReminderNewParams) - Required - The parameters for creating the new reminder. ``` -------------------------------- ### Add Message Reaction Source: https://github.com/beeper/desktop-api-go/blob/main/api.md Use this method to add a reaction to a chat message. Requires the message ID and reaction parameters. ```go client.Chats.Messages.Reactions.Add(ctx, messageID, params) ``` -------------------------------- ### Focus Source: https://github.com/beeper/desktop-api-go/blob/main/api.md Sets the focus for the Beeper desktop client. This method is used to direct the client's attention to a specific conversation or context. ```APIDOC ## POST /v1/focus ### Description Sets the focus for the Beeper desktop client. ### Method POST ### Endpoint /v1/focus ### Parameters #### Request Body - **body** (beeperdesktopapi.FocusParams) - Required - Parameters for setting focus. ### Response #### Success Response (200) - **FocusResponse** (beeperdesktopapi.FocusResponse) - The response indicating the result of the focus operation. ``` -------------------------------- ### Mark Chat as Read Source: https://github.com/beeper/desktop-api-go/blob/main/api.md Use this method to mark all messages in a specific chat as read. Requires the chat ID and parameters for the read operation. ```go client.Chats.MarkRead(ctx context.Context, chatID string, body beeperdesktopapi.ChatMarkReadParams) (*beeperdesktopapi.Chat, error) ``` -------------------------------- ### List Contacts Source: https://github.com/beeper/desktop-api-go/blob/main/api.md Retrieves a paginated list of contacts for a specified account. Supports cursor-based pagination. ```APIDOC ## GET /v1/accounts/{accountID}/contacts/list ### Description Retrieves a paginated list of contacts for a specified account. ### Method GET ### Endpoint /v1/accounts/{accountID}/contacts/list ### Parameters #### Path Parameters - **accountID** (string) - Required - The ID of the account to list contacts from. #### Query Parameters - **query** (beeperdesktopapi.AccountContactListParams) - Required - Parameters for listing contacts, including pagination cursors and filters. ``` -------------------------------- ### Send Message Source: https://github.com/beeper/desktop-api-go/blob/main/api.md Sends a message to a specified chat. Requires a context, chat ID, and message parameters. ```APIDOC ## POST /v1/chats/{chatID}/messages ### Description Sends a message to a specified chat. ### Method POST ### Endpoint /v1/chats/{chatID}/messages ### Parameters #### Path Parameters - **chatID** (string) - Required - The ID of the chat to send the message to. #### Request Body - **body** (beeperdesktopapi.MessageSendParams) - Required - The parameters for sending the message, including message content. ### Response #### Success Response (200) - **MessageSendResponse** (beeperdesktopapi.MessageSendResponse) - Details of the sent message. #### Error Response - **error** (error) - An error object if the message sending fails. ``` -------------------------------- ### Search Chats Source: https://github.com/beeper/desktop-api-go/blob/main/api.md Searches for chats based on a query. This function supports cursor-based pagination for efficient retrieval of chat results. ```go client.Chats.Search(ctx context.Context, query beeperdesktopapi.ChatSearchParams) (*pagination.CursorSearch[beeperdesktopapi.Chat], error) ``` -------------------------------- ### List Messages Source: https://github.com/beeper/desktop-api-go/blob/main/api.md Lists all messages within a specific chat, with support for pagination. ```APIDOC ## GET /v1/chats/{chatID}/messages ### Description Lists all messages within a specific chat, with support for pagination. ### Method GET ### Endpoint /v1/chats/{chatID}/messages ### Parameters #### Path Parameters - **chatID** (string) - Required - The ID of the chat. #### Query Parameters - **query** (beeperdesktopapi.MessageListParams) - Required - Parameters for listing messages. ``` -------------------------------- ### Access Unexpected Extra Fields in Response Source: https://github.com/beeper/desktop-api-go/blob/main/README.md Demonstrates how to access unexpected or un-modelled properties present in the JSON response using the `ExtraFields` map within the `JSON` struct of a response object. ```go body := res.JSON.ExtraFields["my_unexpected_field"].Raw() ``` -------------------------------- ### Add Message Reaction Source: https://github.com/beeper/desktop-api-go/blob/main/api.md Adds a reaction to a message. Requires messageID and reaction parameters. ```APIDOC ## POST /v1/chats/{chatID}/messages/{messageID}/reactions ### Description Adds a reaction to a message. ### Method POST ### Endpoint /v1/chats/{chatID}/messages/{messageID}/reactions ### Parameters #### Path Parameters - **messageID** (string) - Required - The ID of the message to add a reaction to. #### Request Body - **params** (beeperdesktopapi.ChatMessageReactionAddParams) - Required - The parameters for adding the reaction. ``` -------------------------------- ### List Chats Source: https://github.com/beeper/desktop-api-go/blob/main/api.md Retrieves a list of chats. This method can be used to fetch all conversations associated with the user, potentially with pagination. ```APIDOC ## GET /v1/chats ### Description Retrieves a list of chats. ### Method GET ### Endpoint /v1/chats ### Parameters #### Query Parameters - **query** (beeperdesktopapi.ChatListParams) - Optional - Parameters for filtering or paginating the chat list. ### Response #### Success Response (200) - **CursorNoLimit[ChatListResponse]** (pagination.CursorNoLimit[beeperdesktopapi.ChatListResponse]) - A paginated list of chats. ``` -------------------------------- ### Mark Chat as Read Source: https://github.com/beeper/desktop-api-go/blob/main/api.md Marks a specific chat as read. This operation requires the chat ID and a request body containing parameters for marking the chat as read. ```APIDOC ## POST /v1/chats/{chatID}/read ### Description Marks a specific chat as read. ### Method POST ### Endpoint /v1/chats/{chatID}/read ### Parameters #### Path Parameters - **chatID** (string) - Required - The ID of the chat to mark as read. #### Request Body - **body** (ChatMarkReadParams) - Required - Parameters for marking the chat as read. ``` -------------------------------- ### Search Source: https://github.com/beeper/desktop-api-go/blob/main/api.md Searches for messages or conversations within the Beeper client. This method allows users to find specific content. ```APIDOC ## GET /v1/search ### Description Searches for messages or conversations within the Beeper client. ### Method GET ### Endpoint /v1/search ### Parameters #### Query Parameters - **query** (beeperdesktopapi.SearchParams) - Required - Parameters for the search query. ### Response #### Success Response (200) - **SearchResponse** (beeperdesktopapi.SearchResponse) - The response containing search results. ``` -------------------------------- ### Notify Anyway Source: https://github.com/beeper/desktop-api-go/blob/main/api.md Sends a notification for a chat regardless of its current state. This operation requires the chat ID and a request body with notification parameters. ```APIDOC ## POST /v1/chats/{chatID}/notify-anyway ### Description Sends a notification for a chat, even if it's not currently active or unread. ### Method POST ### Endpoint /v1/chats/{chatID}/notify-anyway ### Parameters #### Path Parameters - **chatID** (string) - Required - The ID of the chat to send a notification for. #### Request Body - **body** (ChatNotifyAnywayParams) - Required - Parameters for sending the notification. ``` -------------------------------- ### Search Chats Source: https://github.com/beeper/desktop-api-go/blob/main/api.md Searches for chats based on provided query parameters. This operation returns a paginated list of chats. ```APIDOC ## GET /v1/chats/search ### Description Searches for chats based on specified criteria. ### Method GET ### Endpoint /v1/chats/search ### Parameters #### Query Parameters - **query** (ChatSearchParams) - Required - The search parameters for finding chats. ``` -------------------------------- ### Notify Chat Anyway Source: https://github.com/beeper/desktop-api-go/blob/main/api.md This method allows sending a notification to a chat even if the user has muted it or if normal notification conditions are not met. Requires the chat ID and specific notification parameters. ```go client.Chats.NotifyAnyway(ctx context.Context, chatID string, body beeperdesktopapi.ChatNotifyAnywayParams) (*beeperdesktopapi.Chat, error) ``` -------------------------------- ### Search Contacts Source: https://github.com/beeper/desktop-api-go/blob/main/api.md Searches for contacts within a specified account based on provided query parameters. ```APIDOC ## GET /v1/accounts/{accountID}/contacts ### Description Searches for contacts within a specified account. ### Method GET ### Endpoint /v1/accounts/{accountID}/contacts ### Parameters #### Path Parameters - **accountID** (string) - Required - The ID of the account to search contacts within. #### Query Parameters - **query** (beeperdesktopapi.AccountContactSearchParams) - Required - Parameters for searching contacts, such as name or email. ``` -------------------------------- ### Delete Message Reaction Source: https://github.com/beeper/desktop-api-go/blob/main/api.md Use this method to delete a reaction from a chat message. Requires the reaction key and deletion parameters. ```go client.Chats.Messages.Reactions.Delete(ctx, reactionKey, body) ``` -------------------------------- ### Request Unions Source: https://github.com/beeper/desktop-api-go/blob/main/README.md Describes how union types are represented in requests, where only one field within the union can be non-zero. ```APIDOC ## Request Unions Unions are represented as a struct with fields prefixed by "Of" for each of its 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. ```go // 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 } ``` ``` -------------------------------- ### Mark Chat as Unread Source: https://github.com/beeper/desktop-api-go/blob/main/api.md Use this method to mark a chat as unread. This is useful for bringing attention to a chat that may have been overlooked. Requires the chat ID and parameters for the unread operation. ```go client.Chats.MarkUnread(ctx context.Context, chatID string, body beeperdesktopapi.ChatMarkUnreadParams) (*beeperdesktopapi.Chat, error) ``` -------------------------------- ### Update Message Source: https://github.com/beeper/desktop-api-go/blob/main/api.md Updates an existing message within a chat. ```APIDOC ## PUT /v1/chats/{chatID}/messages/{messageID} ### Description Updates an existing message within a chat. ### Method PUT ### Endpoint /v1/chats/{chatID}/messages/{messageID} ### Parameters #### Path Parameters - **chatID** (string) - Required - The ID of the chat. - **messageID** (string) - Required - The ID of the message. #### Request Body - **params** (beeperdesktopapi.MessageUpdateParams) - Required - Parameters for updating the message. ``` -------------------------------- ### Archive Chat Source: https://github.com/beeper/desktop-api-go/blob/main/api.md Archives a specific chat. This action typically hides the chat from the main view without deleting it. ```APIDOC ## POST /v1/chats/{chatID}/archive ### Description Archives a specific chat. ### Method POST ### Endpoint /v1/chats/{chatID}/archive ### Parameters #### Path Parameters - **chatID** (string) - Required - The unique identifier of the chat to archive. ### Request Body - **body** (beeperdesktopapi.ChatArchiveParams) - Required - Parameters for archiving the chat. ``` -------------------------------- ### Search Messages Source: https://github.com/beeper/desktop-api-go/blob/main/api.md Searches for messages based on specified criteria. ```APIDOC ## GET /v1/messages/search ### Description Searches for messages based on specified criteria. ### Method GET ### Endpoint /v1/messages/search ### Parameters #### Query Parameters - **query** (beeperdesktopapi.MessageSearchParams) - Required - Parameters for searching messages. ``` -------------------------------- ### Update Chat Source: https://github.com/beeper/desktop-api-go/blob/main/api.md Modifies an existing chat. This can be used for various updates such as changing chat settings or metadata. ```APIDOC ## PATCH /v1/chats/{chatID} ### Description Updates an existing chat. ### Method PATCH ### Endpoint /v1/chats/{chatID} ### Parameters #### Path Parameters - **chatID** (string) - Required - The unique identifier of the chat to update. ### Request Body - **body** (beeperdesktopapi.ChatUpdateParams) - Required - Parameters for updating the chat. ### Response #### Success Response (200) - **Chat** (beeperdesktopapi.Chat) - The updated chat object. ``` -------------------------------- ### Delete Message Reaction Source: https://github.com/beeper/desktop-api-go/blob/main/api.md Deletes a reaction from a message. Requires reactionKey and body parameters. ```APIDOC ## DELETE /v1/chats/{chatID}/messages/{messageID}/reactions/{reactionKey} ### Description Deletes a reaction from a message. ### Method DELETE ### Endpoint /v1/chats/{chatID}/messages/{messageID}/reactions/{reactionKey} ### Parameters #### Path Parameters - **reactionKey** (string) - Required - The key of the reaction to delete. #### Request Body - **body** (beeperdesktopapi.ChatMessageReactionDeleteParams) - Required - The parameters for deleting the reaction. ``` -------------------------------- ### Delete Chat Reminder Source: https://github.com/beeper/desktop-api-go/blob/main/api.md Use this method to delete a reminder from a specific chat. Requires the chat ID. ```go client.Chats.Reminders.Delete(ctx, chatID) ``` -------------------------------- ### Mark Chat as Unread Source: https://github.com/beeper/desktop-api-go/blob/main/api.md Marks a specific chat as unread. This operation requires the chat ID and a request body containing parameters for marking the chat as unread. ```APIDOC ## POST /v1/chats/{chatID}/unread ### Description Marks a specific chat as unread. ### Method POST ### Endpoint /v1/chats/{chatID}/unread ### Parameters #### Path Parameters - **chatID** (string) - Required - The ID of the chat to mark as unread. #### Request Body - **body** (ChatMarkUnreadParams) - Required - Parameters for marking the chat as unread. ``` -------------------------------- ### Delete Message Source: https://github.com/beeper/desktop-api-go/blob/main/api.md Deletes a specific message from a chat. ```APIDOC ## DELETE /v1/chats/{chatID}/messages/{messageID} ### Description Deletes a specific message from a chat. ### Method DELETE ### Endpoint /v1/chats/{chatID}/messages/{messageID} ### Parameters #### Path Parameters - **chatID** (string) - Required - The ID of the chat. - **messageID** (string) - Required - The ID of the message. #### Request Body - **params** (beeperdesktopapi.MessageDeleteParams) - Required - Parameters for deleting the message. ``` -------------------------------- ### Delete Chat Reminder Source: https://github.com/beeper/desktop-api-go/blob/main/api.md Deletes a reminder from a specific chat. Requires chatID. ```APIDOC ## DELETE /v1/chats/{chatID}/reminders ### Description Deletes a reminder from a specific chat. ### Method DELETE ### Endpoint /v1/chats/{chatID}/reminders ### Parameters #### Path Parameters - **chatID** (string) - Required - The ID of the chat from which to delete the reminder. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.