Skip to content

Commit 7af4cc5

Browse files
Update Desktop API SDKs
1 parent 6dcf101 commit 7af4cc5

45 files changed

Lines changed: 9990 additions & 4 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 30
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/beeper/beeper-desktop-api-371238be116b1748e82f213ba35b85b0cd574f24e9d9815f73bc743478f23c99.yml
3-
openapi_spec_hash: a10246aaf7cdc33b682fc245bd5f893b
4-
config_hash: 9a5611f899a0fe46abb2a1e463e0ee60
1+
configured_endpoints: 72
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/beeper/beeper-desktop-api-de1370e6a3183044fa135a886d2ee8f779d5e86228cdbd503d553b4c13cc7cbe.yml
3+
openapi_spec_hash: 30b435d7585d8b6951610e7147369779
4+
config_hash: 683b13ea6fb6aa9d6b1b8814cca24f1c

api.md

Lines changed: 243 additions & 0 deletions
Large diffs are not rendered by default.

app.go

Lines changed: 285 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,285 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
package beeperdesktopapi
4+
5+
import (
6+
"context"
7+
"net/http"
8+
"slices"
9+
10+
"github.com/beeper/desktop-api-go/v5/internal/apijson"
11+
"github.com/beeper/desktop-api-go/v5/internal/requestconfig"
12+
"github.com/beeper/desktop-api-go/v5/option"
13+
"github.com/beeper/desktop-api-go/v5/packages/respjson"
14+
)
15+
16+
// Manage Beeper app login and encrypted messaging setup
17+
//
18+
// AppService contains methods and other services that help with interacting with
19+
// 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 [NewAppService] method instead.
24+
type AppService struct {
25+
Options []option.RequestOption
26+
// Complete first-party Beeper app login
27+
Login AppLoginService
28+
// Manage encrypted messaging setup
29+
E2ee AppE2eeService
30+
}
31+
32+
// NewAppService generates a new service that applies the given options to each
33+
// request. These options are applied after the parent client's options (if there
34+
// is one), and before any request-specific options.
35+
func NewAppService(opts ...option.RequestOption) (r AppService) {
36+
r = AppService{}
37+
r.Options = opts
38+
r.Login = NewAppLoginService(opts...)
39+
r.E2ee = NewAppE2eeService(opts...)
40+
return
41+
}
42+
43+
// Return the current Beeper Desktop sign-in and encrypted messaging setup state.
44+
// This endpoint is public before sign-in so apps can discover that login is
45+
// needed; after sign-in, pass a read token.
46+
func (r *AppService) Status(ctx context.Context, opts ...option.RequestOption) (res *AppStatusResponse, err error) {
47+
opts = slices.Concat(r.Options, opts)
48+
path := "v1/app/status"
49+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
50+
return res, err
51+
}
52+
53+
type AppStatusResponse struct {
54+
// Encrypted messaging setup status.
55+
E2ee AppStatusResponseE2ee `json:"e2ee" api:"required"`
56+
// Current onboarding state for Beeper Desktop.
57+
//
58+
// Any of "needs-login", "initializing", "needs-cross-signing-setup",
59+
// "needs-verification", "needs-secrets", "needs-first-sync", "ready".
60+
State AppStatusResponseState `json:"state" api:"required"`
61+
// Signed-in account details. Omitted until sign-in is complete.
62+
Matrix AppStatusResponseMatrix `json:"matrix"`
63+
// Trusted-device verification progress.
64+
Verification AppStatusResponseVerification `json:"verification"`
65+
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
66+
JSON struct {
67+
E2ee respjson.Field
68+
State respjson.Field
69+
Matrix respjson.Field
70+
Verification respjson.Field
71+
ExtraFields map[string]respjson.Field
72+
raw string
73+
} `json:"-"`
74+
}
75+
76+
// Returns the unmodified JSON received from the API
77+
func (r AppStatusResponse) RawJSON() string { return r.JSON.raw }
78+
func (r *AppStatusResponse) UnmarshalJSON(data []byte) error {
79+
return apijson.UnmarshalRoot(data, r)
80+
}
81+
82+
// Encrypted messaging setup status.
83+
type AppStatusResponseE2ee struct {
84+
// Whether this account can verify trusted devices.
85+
CrossSigning bool `json:"crossSigning" api:"required"`
86+
// Whether the first encrypted message sync is complete.
87+
FirstSyncDone bool `json:"firstSyncDone" api:"required"`
88+
// Whether the user confirmed that they saved their recovery key.
89+
HasBackedUpCode bool `json:"hasBackedUpCode" api:"required"`
90+
// Whether encrypted messaging setup has started.
91+
Initialized bool `json:"initialized" api:"required"`
92+
// Whether encrypted message backup is available.
93+
KeyBackup bool `json:"keyBackup" api:"required"`
94+
// Encrypted messaging keys available on this device.
95+
Secrets AppStatusResponseE2eeSecrets `json:"secrets" api:"required"`
96+
// Whether secure key storage is available.
97+
SecretStorage bool `json:"secretStorage" api:"required"`
98+
// Whether this device is trusted for encrypted messages.
99+
Verified bool `json:"verified" api:"required"`
100+
// Unix timestamp for when the recovery key was created.
101+
RecoveryCodeGeneratedAt float64 `json:"recoveryCodeGeneratedAt"`
102+
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
103+
JSON struct {
104+
CrossSigning respjson.Field
105+
FirstSyncDone respjson.Field
106+
HasBackedUpCode respjson.Field
107+
Initialized respjson.Field
108+
KeyBackup respjson.Field
109+
Secrets respjson.Field
110+
SecretStorage respjson.Field
111+
Verified respjson.Field
112+
RecoveryCodeGeneratedAt respjson.Field
113+
ExtraFields map[string]respjson.Field
114+
raw string
115+
} `json:"-"`
116+
}
117+
118+
// Returns the unmodified JSON received from the API
119+
func (r AppStatusResponseE2ee) RawJSON() string { return r.JSON.raw }
120+
func (r *AppStatusResponseE2ee) UnmarshalJSON(data []byte) error {
121+
return apijson.UnmarshalRoot(data, r)
122+
}
123+
124+
// Encrypted messaging keys available on this device.
125+
type AppStatusResponseE2eeSecrets struct {
126+
// Whether the account identity key is available.
127+
MasterKey bool `json:"masterKey" api:"required"`
128+
// Whether the encrypted message backup key is available.
129+
MegolmBackupKey bool `json:"megolmBackupKey" api:"required"`
130+
// Whether a recovery key is available.
131+
RecoveryCode bool `json:"recoveryCode" api:"required"`
132+
// Whether the device trust key is available.
133+
SelfSigningKey bool `json:"selfSigningKey" api:"required"`
134+
// Whether the user trust key is available.
135+
UserSigningKey bool `json:"userSigningKey" api:"required"`
136+
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
137+
JSON struct {
138+
MasterKey respjson.Field
139+
MegolmBackupKey respjson.Field
140+
RecoveryCode respjson.Field
141+
SelfSigningKey respjson.Field
142+
UserSigningKey respjson.Field
143+
ExtraFields map[string]respjson.Field
144+
raw string
145+
} `json:"-"`
146+
}
147+
148+
// Returns the unmodified JSON received from the API
149+
func (r AppStatusResponseE2eeSecrets) RawJSON() string { return r.JSON.raw }
150+
func (r *AppStatusResponseE2eeSecrets) UnmarshalJSON(data []byte) error {
151+
return apijson.UnmarshalRoot(data, r)
152+
}
153+
154+
// Current onboarding state for Beeper Desktop.
155+
type AppStatusResponseState string
156+
157+
const (
158+
AppStatusResponseStateNeedsLogin AppStatusResponseState = "needs-login"
159+
AppStatusResponseStateInitializing AppStatusResponseState = "initializing"
160+
AppStatusResponseStateNeedsCrossSigningSetup AppStatusResponseState = "needs-cross-signing-setup"
161+
AppStatusResponseStateNeedsVerification AppStatusResponseState = "needs-verification"
162+
AppStatusResponseStateNeedsSecrets AppStatusResponseState = "needs-secrets"
163+
AppStatusResponseStateNeedsFirstSync AppStatusResponseState = "needs-first-sync"
164+
AppStatusResponseStateReady AppStatusResponseState = "ready"
165+
)
166+
167+
// Signed-in account details. Omitted until sign-in is complete.
168+
type AppStatusResponseMatrix struct {
169+
// Current device ID.
170+
DeviceID string `json:"deviceID" api:"required"`
171+
// Beeper server URL for this account.
172+
Homeserver string `json:"homeserver" api:"required"`
173+
// Signed-in Beeper user ID.
174+
UserID string `json:"userID" api:"required"`
175+
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
176+
JSON struct {
177+
DeviceID respjson.Field
178+
Homeserver respjson.Field
179+
UserID respjson.Field
180+
ExtraFields map[string]respjson.Field
181+
raw string
182+
} `json:"-"`
183+
}
184+
185+
// Returns the unmodified JSON received from the API
186+
func (r AppStatusResponseMatrix) RawJSON() string { return r.JSON.raw }
187+
func (r *AppStatusResponseMatrix) UnmarshalJSON(data []byte) error {
188+
return apijson.UnmarshalRoot(data, r)
189+
}
190+
191+
// Trusted-device verification progress.
192+
type AppStatusResponseVerification struct {
193+
// Verification actions that are valid for the current state.
194+
//
195+
// Any of "create", "qr.scan", "accept", "cancel", "qr.confirmScanned",
196+
// "sas.start", "sas.confirm".
197+
AvailableActions []string `json:"availableActions" api:"required"`
198+
// Current trusted-device verification state.
199+
//
200+
// Any of "idle", "requested", "ready", "sas_ready", "qr_scanned", "done",
201+
// "cancelled", "error".
202+
State string `json:"state" api:"required"`
203+
// Verification error details, if verification stopped.
204+
Error AppStatusResponseVerificationError `json:"error"`
205+
// User ID that started verification.
206+
From string `json:"from"`
207+
// Device that started verification.
208+
FromDevice string `json:"fromDevice"`
209+
// Other device participating in verification.
210+
OtherDevice string `json:"otherDevice"`
211+
// QR code payload to display for verification.
212+
QrData string `json:"qrData"`
213+
// Emoji or number comparison data for verification.
214+
Sas AppStatusResponseVerificationSas `json:"sas"`
215+
// Whether emoji comparison is available.
216+
SupportsSas bool `json:"supportsSAS"`
217+
// Whether QR code verification is available.
218+
SupportsScanQrCode bool `json:"supportsScanQRCode"`
219+
// Verification ID to pass in verification action paths.
220+
VerificationID string `json:"verificationID"`
221+
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
222+
JSON struct {
223+
AvailableActions respjson.Field
224+
State respjson.Field
225+
Error respjson.Field
226+
From respjson.Field
227+
FromDevice respjson.Field
228+
OtherDevice respjson.Field
229+
QrData respjson.Field
230+
Sas respjson.Field
231+
SupportsSas respjson.Field
232+
SupportsScanQrCode respjson.Field
233+
VerificationID respjson.Field
234+
ExtraFields map[string]respjson.Field
235+
raw string
236+
} `json:"-"`
237+
}
238+
239+
// Returns the unmodified JSON received from the API
240+
func (r AppStatusResponseVerification) RawJSON() string { return r.JSON.raw }
241+
func (r *AppStatusResponseVerification) UnmarshalJSON(data []byte) error {
242+
return apijson.UnmarshalRoot(data, r)
243+
}
244+
245+
// Verification error details, if verification stopped.
246+
type AppStatusResponseVerificationError struct {
247+
// Verification error code.
248+
Code string `json:"code" api:"required"`
249+
// User-facing verification error message.
250+
Reason string `json:"reason" api:"required"`
251+
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
252+
JSON struct {
253+
Code respjson.Field
254+
Reason respjson.Field
255+
ExtraFields map[string]respjson.Field
256+
raw string
257+
} `json:"-"`
258+
}
259+
260+
// Returns the unmodified JSON received from the API
261+
func (r AppStatusResponseVerificationError) RawJSON() string { return r.JSON.raw }
262+
func (r *AppStatusResponseVerificationError) UnmarshalJSON(data []byte) error {
263+
return apijson.UnmarshalRoot(data, r)
264+
}
265+
266+
// Emoji or number comparison data for verification.
267+
type AppStatusResponseVerificationSas struct {
268+
// Number sequence to compare on both devices.
269+
Decimals string `json:"decimals" api:"required"`
270+
// Emoji sequence to compare on both devices.
271+
Emojis string `json:"emojis" api:"required"`
272+
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
273+
JSON struct {
274+
Decimals respjson.Field
275+
Emojis respjson.Field
276+
ExtraFields map[string]respjson.Field
277+
raw string
278+
} `json:"-"`
279+
}
280+
281+
// Returns the unmodified JSON received from the API
282+
func (r AppStatusResponseVerificationSas) RawJSON() string { return r.JSON.raw }
283+
func (r *AppStatusResponseVerificationSas) UnmarshalJSON(data []byte) error {
284+
return apijson.UnmarshalRoot(data, r)
285+
}

app_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 beeperdesktopapi_test
4+
5+
import (
6+
"context"
7+
"errors"
8+
"os"
9+
"testing"
10+
11+
"github.com/beeper/desktop-api-go/v5"
12+
"github.com/beeper/desktop-api-go/v5/internal/testutil"
13+
"github.com/beeper/desktop-api-go/v5/option"
14+
)
15+
16+
func TestAppStatus(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 := beeperdesktopapi.NewClient(
25+
option.WithBaseURL(baseURL),
26+
option.WithAccessToken("My Access Token"),
27+
)
28+
_, err := client.App.Status(context.TODO())
29+
if err != nil {
30+
var apierr *beeperdesktopapi.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+
}

appe2ee.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
package beeperdesktopapi
4+
5+
import (
6+
"github.com/beeper/desktop-api-go/v5/option"
7+
)
8+
9+
// Manage encrypted messaging setup
10+
//
11+
// AppE2eeService contains methods and other services that help with interacting
12+
// with the beeperdesktop API.
13+
//
14+
// Note, unlike clients, this service does not read variables from the environment
15+
// automatically. You should not instantiate this service directly, and instead use
16+
// the [NewAppE2eeService] method instead.
17+
type AppE2eeService struct {
18+
Options []option.RequestOption
19+
// First-party sign-in and encrypted messaging setup for Beeper Desktop.
20+
RecoveryCode AppE2eeRecoveryCodeService
21+
// First-party sign-in and encrypted messaging setup for Beeper Desktop.
22+
Verification AppE2eeVerificationService
23+
}
24+
25+
// NewAppE2eeService generates a new service that applies the given options to each
26+
// request. These options are applied after the parent client's options (if there
27+
// is one), and before any request-specific options.
28+
func NewAppE2eeService(opts ...option.RequestOption) (r AppE2eeService) {
29+
r = AppE2eeService{}
30+
r.Options = opts
31+
r.RecoveryCode = NewAppE2eeRecoveryCodeService(opts...)
32+
r.Verification = NewAppE2eeVerificationService(opts...)
33+
return
34+
}

0 commit comments

Comments
 (0)