Skip to content

Commit b5a1ff4

Browse files
feat(api): update via SDK Studio
1 parent d2b16a5 commit b5a1ff4

22 files changed

+1249
-1095
lines changed

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 13
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/beeper%2Fbeeper-desktop-api-75447a6b19c812a016a6c45e1476b1de96b920ddce034ebaa7475445001b950f.yml
3-
openapi_spec_hash: 79e81d6d22079cc96dc079cade4f5584
4-
config_hash: bb65707bab3f0f379c5b19da035d3def
1+
configured_endpoints: 12
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/beeper%2Fbeeper-desktop-api-0e822b2bf1c6e9913f5ef95f9feb25ee9c76aa38d9b927ad181165c6a6ad6588.yml
3+
openapi_spec_hash: 2ec51cfeccf119e5fca24930aed25113
4+
config_hash: c94b6329bfcab27d3a6a65bbfb737e4a

README.md

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,11 @@ func main() {
5252
client := githubcombeeperdesktopapigo.NewClient(
5353
option.WithAccessToken("My Access Token"), // defaults to os.LookupEnv("BEEPER_ACCESS_TOKEN")
5454
)
55-
page, err := client.V0.FindChats(context.TODO(), githubcombeeperdesktopapigo.V0FindChatsParams{
56-
Limit: githubcombeeperdesktopapigo.Int(10),
57-
Type: githubcombeeperdesktopapigo.V0FindChatsParamsTypeSingle,
58-
})
55+
accounts, err := client.Accounts.List(context.TODO())
5956
if err != nil {
6057
panic(err.Error())
6158
}
62-
fmt.Printf("%+v\n", page)
59+
fmt.Printf("%+v\n", accounts.Accounts)
6360
}
6461

6562
```
@@ -265,7 +262,7 @@ client := githubcombeeperdesktopapigo.NewClient(
265262
option.WithHeader("X-Some-Header", "custom_header_info"),
266263
)
267264

268-
client.V0.GetAccounts(context.TODO(), ...,
265+
client.Accounts.List(context.TODO(), ...,
269266
// Override the header
270267
option.WithHeader("X-Some-Header", "some_other_custom_header_info"),
271268
// Add an undocumented field to the request body, using sjson syntax
@@ -284,7 +281,7 @@ This library provides some conveniences for working with paginated list endpoint
284281
You can use `.ListAutoPaging()` methods to iterate through items across all pages:
285282

286283
```go
287-
iter := client.V0.SearchMessagesAutoPaging(context.TODO(), githubcombeeperdesktopapigo.V0SearchMessagesParams{
284+
iter := client.Messages.SearchAutoPaging(context.TODO(), githubcombeeperdesktopapigo.MessageSearchParams{
288285
Limit: githubcombeeperdesktopapigo.Int(20),
289286
Query: githubcombeeperdesktopapigo.String("meeting"),
290287
})
@@ -302,13 +299,13 @@ Or you can use simple `.List()` methods to fetch a single page and receive a sta
302299
with additional helper methods like `.GetNextPage()`, e.g.:
303300

304301
```go
305-
page, err := client.V0.SearchMessages(context.TODO(), githubcombeeperdesktopapigo.V0SearchMessagesParams{
302+
page, err := client.Messages.Search(context.TODO(), githubcombeeperdesktopapigo.MessageSearchParams{
306303
Limit: githubcombeeperdesktopapigo.Int(20),
307304
Query: githubcombeeperdesktopapigo.String("meeting"),
308305
})
309306
for page != nil {
310-
for _, v0 := range page.Data {
311-
fmt.Printf("%+v\n", v0)
307+
for _, message := range page.Data {
308+
fmt.Printf("%+v\n", message)
312309
}
313310
page, err = page.GetNextPage()
314311
}
@@ -327,7 +324,7 @@ When the API returns a non-success status code, we return an error with type
327324
To handle errors, we recommend that you use the `errors.As` pattern:
328325

329326
```go
330-
_, err := client.V0.SendMessage(context.TODO(), githubcombeeperdesktopapigo.V0SendMessageParams{
327+
_, err := client.Messages.Send(context.TODO(), githubcombeeperdesktopapigo.MessageSendParams{
331328
ChatID: "!invalid-chat-id",
332329
Text: githubcombeeperdesktopapigo.String("Test message"),
333330
})
@@ -355,7 +352,7 @@ To set a per-retry timeout, use `option.WithRequestTimeout()`.
355352
// This sets the timeout for the request, including all the retries.
356353
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
357354
defer cancel()
358-
client.V0.GetAccounts(
355+
client.Accounts.List(
359356
ctx,
360357
// This sets the per-retry timeout
361358
option.WithRequestTimeout(20*time.Second),
@@ -390,7 +387,7 @@ client := githubcombeeperdesktopapigo.NewClient(
390387
)
391388

392389
// Override per-request:
393-
client.V0.GetAccounts(context.TODO(), option.WithMaxRetries(5))
390+
client.Accounts.List(context.TODO(), option.WithMaxRetries(5))
394391
```
395392

396393
### Accessing raw response data (e.g. response headers)
@@ -401,11 +398,11 @@ you need to examine response headers, status codes, or other details.
401398
```go
402399
// Create a variable to store the HTTP response
403400
var response *http.Response
404-
accountsResponse, err := client.V0.GetAccounts(context.TODO(), option.WithResponseInto(&response))
401+
accounts, err := client.Accounts.List(context.TODO(), option.WithResponseInto(&response))
405402
if err != nil {
406403
// handle error
407404
}
408-
fmt.Printf("%+v\n", accountsResponse)
405+
fmt.Printf("%+v\n", accounts)
409406

410407
fmt.Printf("Status Code: %d\n", response.StatusCode)
411408
fmt.Printf("Headers: %+#v\n", response.Header)

account.go

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
package githubcombeeperdesktopapigo
4+
5+
import (
6+
"context"
7+
"net/http"
8+
9+
"github.com/beeper/desktop-api-go/internal/apijson"
10+
"github.com/beeper/desktop-api-go/internal/requestconfig"
11+
"github.com/beeper/desktop-api-go/option"
12+
"github.com/beeper/desktop-api-go/packages/respjson"
13+
"github.com/beeper/desktop-api-go/shared"
14+
)
15+
16+
// Accounts operations
17+
//
18+
// AccountService contains methods and other services that help with interacting
19+
// with the beeperdesktop API.
20+
//
21+
// Note, unlike clients, this service does not read variables from the environment
22+
// automatically. You should not instantiate this service directly, and instead use
23+
// the [NewAccountService] method instead.
24+
type AccountService struct {
25+
Options []option.RequestOption
26+
}
27+
28+
// NewAccountService generates a new service that applies the given options to each
29+
// request. These options are applied after the parent client's options (if there
30+
// is one), and before any request-specific options.
31+
func NewAccountService(opts ...option.RequestOption) (r AccountService) {
32+
r = AccountService{}
33+
r.Options = opts
34+
return
35+
}
36+
37+
// List connected Beeper accounts available on this device
38+
func (r *AccountService) List(ctx context.Context, opts ...option.RequestOption) (res *AccountListResponse, err error) {
39+
opts = append(r.Options[:], opts...)
40+
path := "v0/get-accounts"
41+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
42+
return
43+
}
44+
45+
// Response payload for listing connected Beeper accounts.
46+
type AccountListResponse struct {
47+
// Connected accounts the user can act through. Includes accountID, network, and
48+
// user identity.
49+
Accounts []shared.Account `json:"accounts,required"`
50+
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
51+
JSON struct {
52+
Accounts respjson.Field
53+
ExtraFields map[string]respjson.Field
54+
raw string
55+
} `json:"-"`
56+
}
57+
58+
// Returns the unmodified JSON received from the API
59+
func (r AccountListResponse) RawJSON() string { return r.JSON.raw }
60+
func (r *AccountListResponse) UnmarshalJSON(data []byte) error {
61+
return apijson.UnmarshalRoot(data, r)
62+
}

account_test.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
package githubcombeeperdesktopapigo_test
4+
5+
import (
6+
"context"
7+
"errors"
8+
"os"
9+
"testing"
10+
11+
"github.com/beeper/desktop-api-go"
12+
"github.com/beeper/desktop-api-go/internal/testutil"
13+
"github.com/beeper/desktop-api-go/option"
14+
)
15+
16+
func TestAccountList(t *testing.T) {
17+
baseURL := "http://localhost:4010"
18+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
19+
baseURL = envURL
20+
}
21+
if !testutil.CheckTestServer(t, baseURL) {
22+
return
23+
}
24+
client := githubcombeeperdesktopapigo.NewClient(
25+
option.WithBaseURL(baseURL),
26+
option.WithAccessToken("My Access Token"),
27+
)
28+
_, err := client.Accounts.List(context.TODO())
29+
if err != nil {
30+
var apierr *githubcombeeperdesktopapigo.Error
31+
if errors.As(err, &apierr) {
32+
t.Log(string(apierr.DumpRequest(true)))
33+
}
34+
t.Fatalf("err should be nil: %s", err.Error())
35+
}
36+
}

0 commit comments

Comments
 (0)