11# Beeper Desktop Go API Library
22
3- <a href = " https://pkg.go.dev/github.com/beeper/beeper-desktop-api-go " >< img src = " https://pkg.go.dev/badge/github.com/beeper/beeper-desktop-api-go.svg " alt = " Go Reference " ></ a >
3+ <!-- x-release-please-start-version -- >
44
5- The Beeper Desktop Go library provides convenient access to the [ Beeper Desktop REST API] ( https://www.beeper.com/desktop-api )
6- from applications written in Go.
5+ <a href =" https://pkg.go.dev/github.com/beeper/desktop-api-go " ><img src =" https://pkg.go.dev/badge/github.com/beeper/desktop-api-go.svg " alt =" Go Reference " ></a >
6+
7+ <!-- x-release-please-end -->
78
8- It is generated with [ Stainless] ( https://www.stainless.com/ ) .
9+ The Beeper Desktop Go library provides convenient access to the [ Beeper Desktop REST API] ( https://developers.beeper.com/desktop-api/ )
10+ from applications written in Go.
911
1012## Installation
1113
1214<!-- x-release-please-start-version -->
1315
1416``` go
1517import (
16- " github.com/beeper/beeper- desktop-api-go" // imported as githubcombeeperbeeperdesktopapigo
18+ " github.com/beeper/desktop-api-go" // imported as beeperdesktopapi
1719)
1820```
1921
@@ -24,14 +26,14 @@ Or to pin the version:
2426<!-- x-release-please-start-version -->
2527
2628``` sh
27- go get -u ' github.com/beeper/beeper- desktop-api-go@v0.0.1 '
29+ go get -u ' github.com/beeper/desktop-api-go@v0.1.0 '
2830```
2931
3032<!-- x-release-please-end -->
3133
3234## Requirements
3335
34- This library requires Go 1.18 +.
36+ This library requires Go 1.22 +.
3537
3638## Usage
3739
@@ -44,17 +46,18 @@ import (
4446 " context"
4547 " fmt"
4648
47- " github.com/beeper/beeper- desktop-api-go"
48- " github.com/beeper/beeper- desktop-api-go/option"
49+ " github.com/beeper/desktop-api-go"
50+ " github.com/beeper/desktop-api-go/option"
4951)
5052
5153func main () {
52- client := githubcombeeperbeeperdesktopapigo .NewClient (
54+ client := beeperdesktopapi .NewClient (
5355 option.WithAccessToken (" My Access Token" ), // defaults to os.LookupEnv("BEEPER_ACCESS_TOKEN")
5456 )
55- page , err := client.Chats .Find (context.TODO (), githubcombeeperbeeperdesktopapigo.ChatFindParams {
56- Limit: githubcombeeperbeeperdesktopapigo.Int (10 ),
57- Type: githubcombeeperbeeperdesktopapigo.ChatFindParamsTypeSingle ,
57+ page , err := client.Chats .Search (context.TODO (), beeperdesktopapi.ChatSearchParams {
58+ IncludeMuted: beeperdesktopapi.Bool (true ),
59+ Limit: beeperdesktopapi.Int (3 ),
60+ Type: beeperdesktopapi.ChatSearchParamsTypeSingle ,
5861 })
5962 if err != nil {
6063 panic (err.Error ())
@@ -66,31 +69,31 @@ func main() {
6669
6770### Request fields
6871
69- The githubcombeeperbeeperdesktopapigo library uses the [ ` omitzero ` ] ( https://tip.golang.org/doc/go1.24#encodingjsonpkgencodingjson )
72+ The beeperdesktopapi library uses the [ ` omitzero ` ] ( https://tip.golang.org/doc/go1.24#encodingjsonpkgencodingjson )
7073semantics from the Go 1.24+ ` encoding/json ` release for request fields.
7174
7275Required primitive fields (` int64 ` , ` string ` , etc.) feature the tag <code >\` json:"...,required"\` </code >. These
7376fields are always serialized, even their zero values.
7477
75- Optional primitive types are wrapped in a ` param.Opt[T] ` . These fields can be set with the provided constructors, ` githubcombeeperbeeperdesktopapigo .String(string)` , ` githubcombeeperbeeperdesktopapigo .Int(int64)` , etc.
78+ 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.
7679
7780Any ` param.Opt[T] ` , map, slice, struct or string enum uses the
7881tag <code >\` json:"...,omitzero"\` </code >. Its zero value is considered omitted.
7982
8083The ` param.IsOmitted(any) ` function can confirm the presence of any ` omitzero ` field.
8184
8285``` go
83- p := githubcombeeperbeeperdesktopapigo .ExampleParams {
84- ID : " id_xxx" , // required property
85- Name : githubcombeeperbeeperdesktopapigo .String (" ..." ), // optional property
86+ p := beeperdesktopapi .ExampleParams {
87+ ID : " id_xxx" , // required property
88+ Name : beeperdesktopapi .String (" ..." ), // optional property
8689
87- Point : githubcombeeperbeeperdesktopapigo .Point {
88- X: 0 , // required field will serialize as 0
89- Y: githubcombeeperbeeperdesktopapigo .Int (1 ), // optional field will serialize as 1
90+ Point : beeperdesktopapi .Point {
91+ X: 0 , // required field will serialize as 0
92+ Y: beeperdesktopapi .Int (1 ), // optional field will serialize as 1
9093 // ... omitted non-required fields will not be serialized
9194 },
9295
93- Origin : githubcombeeperbeeperdesktopapigo .Origin {}, // the zero value of [Origin] is considered omitted
96+ Origin : beeperdesktopapi .Origin {}, // the zero value of [Origin] is considered omitted
9497}
9598```
9699
@@ -119,7 +122,7 @@ p.SetExtraFields(map[string]any{
119122})
120123
121124// Send a number instead of an object
122- custom := param.Override [githubcombeeperbeeperdesktopapigo .FooParams ](12 )
125+ custom := param.Override [beeperdesktopapi .FooParams ](12 )
123126```
124127
125128### Request unions
@@ -260,7 +263,7 @@ This library uses the functional options pattern. Functions defined in the
260263requests. For example:
261264
262265``` go
263- client := githubcombeeperbeeperdesktopapigo .NewClient (
266+ client := beeperdesktopapi .NewClient (
264267 // Adds a header to every request made by the client
265268 option.WithHeader (" X-Some-Header" , " custom_header_info" ),
266269)
@@ -275,7 +278,7 @@ client.Accounts.List(context.TODO(), ...,
275278
276279The request option ` option.WithDebugLog(nil) ` may be helpful while debugging.
277280
278- See the [ full list of request options] ( https://pkg.go.dev/github.com/beeper/beeper- desktop-api-go/option ) .
281+ See the [ full list of request options] ( https://pkg.go.dev/github.com/beeper/desktop-api-go/option ) .
279282
280283### Pagination
281284
@@ -284,9 +287,10 @@ This library provides some conveniences for working with paginated list endpoint
284287You can use ` .ListAutoPaging() ` methods to iterate through items across all pages:
285288
286289``` go
287- iter := client.Messages .SearchAutoPaging (context.TODO (), githubcombeeperbeeperdesktopapigo.MessageSearchParams {
288- Limit : githubcombeeperbeeperdesktopapigo.Int (20 ),
289- Query : githubcombeeperbeeperdesktopapigo.String (" meeting" ),
290+ iter := client.Messages .SearchAutoPaging (context.TODO (), beeperdesktopapi.MessageSearchParams {
291+ AccountIDs : []string {" local-telegram_ba_QFrb5lrLPhO3OT5MFBeTWv0x4BI" },
292+ Limit : beeperdesktopapi.Int (10 ),
293+ Query : beeperdesktopapi.String (" deployment" ),
290294})
291295// Automatically fetches more pages as needed.
292296for iter.Next () {
@@ -302,12 +306,13 @@ Or you can use simple `.List()` methods to fetch a single page and receive a sta
302306with additional helper methods like ` .GetNextPage() ` , e.g.:
303307
304308``` go
305- page , err := client.Messages .Search (context.TODO (), githubcombeeperbeeperdesktopapigo.MessageSearchParams {
306- Limit : githubcombeeperbeeperdesktopapigo.Int (20 ),
307- Query : githubcombeeperbeeperdesktopapigo.String (" meeting" ),
309+ page , err := client.Messages .Search (context.TODO (), beeperdesktopapi.MessageSearchParams {
310+ AccountIDs : []string {" local-telegram_ba_QFrb5lrLPhO3OT5MFBeTWv0x4BI" },
311+ Limit : beeperdesktopapi.Int (10 ),
312+ Query : beeperdesktopapi.String (" deployment" ),
308313})
309314for page != nil {
310- for _ , message := range page.Data {
315+ for _ , message := range page.Items {
311316 fmt.Printf (" %+v \n " , message)
312317 }
313318 page, err = page.GetNextPage ()
@@ -320,24 +325,21 @@ if err != nil {
320325### Errors
321326
322327When the API returns a non-success status code, we return an error with type
323- ` *githubcombeeperbeeperdesktopapigo .Error ` . This contains the ` StatusCode ` , ` *http.Request ` , and
328+ ` *beeperdesktopapi .Error ` . This contains the ` StatusCode ` , ` *http.Request ` , and
324329` *http.Response ` values of the request, as well as the JSON of the error body
325330(much like other response objects in the SDK).
326331
327332To handle errors, we recommend that you use the ` errors.As ` pattern:
328333
329334``` go
330- _ , err := client.Messages .Send (context.TODO (), githubcombeeperbeeperdesktopapigo.MessageSendParams {
331- ChatID : " !invalid-chat-id" ,
332- Text : githubcombeeperbeeperdesktopapigo.String (" Test message" ),
333- })
335+ _ , err := client.Accounts .List (context.TODO ())
334336if err != nil {
335- var apierr *githubcombeeperbeeperdesktopapigo .Error
337+ var apierr *beeperdesktopapi .Error
336338 if errors.As (err, &apierr) {
337339 println (string (apierr.DumpRequest (true ))) // Prints the serialized HTTP request
338340 println (string (apierr.DumpResponse (true ))) // Prints the serialized HTTP response
339341 }
340- panic (err.Error ()) // GET "/v0/send-message ": 400 Bad Request { ... }
342+ panic (err.Error ()) // GET "/v1/accounts ": 400 Bad Request { ... }
341343}
342344```
343345
@@ -372,20 +374,20 @@ The file name and content-type can be customized by implementing `Name() string`
372374string` on the run-time type of ` io.Reader` . Note that ` os.File` implements ` Name() string`, so a
373375file returned by ` os.Open ` will be sent with the file name on disk.
374376
375- We also provide a helper ` githubcombeeperbeeperdesktopapigo .File(reader io.Reader, filename string, contentType string)`
377+ We also provide a helper ` beeperdesktopapi .File(reader io.Reader, filename string, contentType string)`
376378which can be used to wrap any ` io.Reader ` with the appropriate file name and content type.
377379
378380### Retries
379381
380- Certain errors will be automatically retried 3 times by default, with a short exponential backoff.
382+ Certain errors will be automatically retried 2 times by default, with a short exponential backoff.
381383We retry by default all connection errors, 408 Request Timeout, 409 Conflict, 429 Rate Limit,
382384and >=500 Internal errors.
383385
384386You can use the ` WithMaxRetries ` option to configure or disable this:
385387
386388``` go
387389// Configure the default for all requests:
388- client := githubcombeeperbeeperdesktopapigo .NewClient (
390+ client := beeperdesktopapi .NewClient (
389391 option.WithMaxRetries (0 ), // default is 2
390392)
391393
@@ -401,11 +403,11 @@ you need to examine response headers, status codes, or other details.
401403``` go
402404// Create a variable to store the HTTP response
403405var response *http.Response
404- accountsResponse , err := client.Accounts .List (context.TODO (), option.WithResponseInto (&response))
406+ accounts , err := client.Accounts .List (context.TODO (), option.WithResponseInto (&response))
405407if err != nil {
406408 // handle error
407409}
408- fmt.Printf (" %+v \n " , accountsResponse )
410+ fmt.Printf (" %+v \n " , accounts )
409411
410412fmt.Printf (" Status Code: %d \n " , response.StatusCode )
411413fmt.Printf (" Headers: %+#v \n " , response.Header )
@@ -446,7 +448,7 @@ or the `option.WithJSONSet()` methods.
446448params := FooNewParams {
447449 ID : " id_xxxx" ,
448450 Data : FooNewParamsData {
449- FirstName: githubcombeeperbeeperdesktopapigo .String (" John" ),
451+ FirstName: beeperdesktopapi .String (" John" ),
450452 },
451453}
452454client.Foo .New (context.Background (), params, option.WithJSONSet (" data.last_name" , " Doe" ))
@@ -481,7 +483,7 @@ func Logger(req *http.Request, next option.MiddlewareNext) (res *http.Response,
481483 return res, err
482484}
483485
484- client := githubcombeeperbeeperdesktopapigo .NewClient (
486+ client := beeperdesktopapi .NewClient (
485487 option.WithMiddleware (Logger),
486488)
487489```
@@ -506,7 +508,7 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con
506508
507509We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
508510
509- We are keen for your feedback; please open an [ issue] ( https://www.github.com/beeper/beeper- desktop-api-go/issues ) with questions, bugs, or suggestions.
511+ We are keen for your feedback; please open an [ issue] ( https://www.github.com/beeper/desktop-api-go/issues ) with questions, bugs, or suggestions.
510512
511513## Contributing
512514
0 commit comments