-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbeeperdesktopapi.go
More file actions
135 lines (120 loc) · 4.78 KB
/
Copy pathbeeperdesktopapi.go
File metadata and controls
135 lines (120 loc) · 4.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package beeperdesktopapi
import (
"net/url"
"github.com/beeper/desktop-api-go/v5/internal/apijson"
"github.com/beeper/desktop-api-go/v5/internal/apiquery"
"github.com/beeper/desktop-api-go/v5/packages/param"
"github.com/beeper/desktop-api-go/v5/packages/respjson"
"github.com/beeper/desktop-api-go/v5/shared"
)
// Response indicating successful app focus action.
type FocusResponse struct {
// Whether the app was successfully opened/focused.
Success bool `json:"success" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Success respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r FocusResponse) RawJSON() string { return r.JSON.raw }
func (r *FocusResponse) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type SearchResponse struct {
Results SearchResponseResults `json:"results" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Results respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r SearchResponse) RawJSON() string { return r.JSON.raw }
func (r *SearchResponse) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type SearchResponseResults struct {
// Top chat results.
Chats []Chat `json:"chats" api:"required"`
// Top group results by participant matches.
InGroups []Chat `json:"in_groups" api:"required"`
Messages SearchResponseResultsMessages `json:"messages" api:"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
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r SearchResponseResults) RawJSON() string { return r.JSON.raw }
func (r *SearchResponseResults) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type SearchResponseResultsMessages struct {
// Map of chatID -> chat details for chats referenced in items.
Chats map[string]Chat `json:"chats" api:"required"`
// True if additional results can be fetched using the provided cursors.
HasMore bool `json:"hasMore" api:"required"`
// Messages matching the query and filters.
Items []shared.Message `json:"items" api:"required"`
// Cursor for fetching newer results (use with direction='after'). Opaque string;
// do not inspect.
NewestCursor string `json:"newestCursor" api:"required"`
// Cursor for fetching older results (use with direction='before'). Opaque string;
// do not inspect.
OldestCursor string `json:"oldestCursor" api:"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
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r SearchResponseResultsMessages) RawJSON() string { return r.JSON.raw }
func (r *SearchResponseResultsMessages) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
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 local image path to populate in the message input field.
DraftAttachmentPath param.Opt[string] `json:"draftAttachmentPath,omitzero"`
// Optional plain 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"`
paramObj
}
func (r FocusParams) MarshalJSON() (data []byte, err error) {
type shadow FocusParams
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *FocusParams) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type SearchParams struct {
// User-typed search text. Uses literal word matching.
Query string `query:"query" api:"required" json:"-"`
paramObj
}
// URLQuery serializes [SearchParams]'s query parameters as `url.Values`.
func (r SearchParams) URLQuery() (v url.Values, err error) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatRepeat,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}