Skip to content

Commit ce4f065

Browse files
chore(internal): use explicit returns
1 parent 9504a61 commit ce4f065

File tree

9 files changed

+32
-32
lines changed

9 files changed

+32
-32
lines changed

account.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func (r *AccountService) List(ctx context.Context, opts ...option.RequestOption)
4444
opts = slices.Concat(r.Options, opts)
4545
path := "v1/accounts"
4646
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
47-
return
47+
return res, err
4848
}
4949

5050
// A chat account added to Beeper

accountcontact.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func (r *AccountContactService) List(ctx context.Context, accountID string, quer
4848
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
4949
if accountID == "" {
5050
err = errors.New("missing required accountID parameter")
51-
return
51+
return nil, err
5252
}
5353
path := fmt.Sprintf("v1/accounts/%s/contacts/list", accountID)
5454
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
@@ -74,11 +74,11 @@ func (r *AccountContactService) Search(ctx context.Context, accountID string, qu
7474
opts = slices.Concat(r.Options, opts)
7575
if accountID == "" {
7676
err = errors.New("missing required accountID parameter")
77-
return
77+
return nil, err
7878
}
7979
path := fmt.Sprintf("v1/accounts/%s/contacts", accountID)
8080
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
81-
return
81+
return res, err
8282
}
8383

8484
type AccountContactSearchResponse struct {

asset.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func (r *AssetService) Download(ctx context.Context, body AssetDownloadParams, o
4747
opts = slices.Concat(r.Options, opts)
4848
path := "v1/assets/download"
4949
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
50-
return
50+
return res, err
5151
}
5252

5353
// Stream a file given an mxc://, localmxc://, or file:// URL. Downloads first if
@@ -57,7 +57,7 @@ func (r *AssetService) Serve(ctx context.Context, query AssetServeParams, opts .
5757
opts = append([]option.RequestOption{option.WithHeader("Accept", "*/*")}, opts...)
5858
path := "v1/assets/serve"
5959
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, nil, opts...)
60-
return
60+
return err
6161
}
6262

6363
// Upload a file to a temporary location using multipart/form-data. Returns an
@@ -66,7 +66,7 @@ func (r *AssetService) Upload(ctx context.Context, body AssetUploadParams, opts
6666
opts = slices.Concat(r.Options, opts)
6767
path := "v1/assets/upload"
6868
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
69-
return
69+
return res, err
7070
}
7171

7272
// Upload a file using a JSON body with base64-encoded content. Returns an uploadID
@@ -76,7 +76,7 @@ func (r *AssetService) UploadBase64(ctx context.Context, body AssetUploadBase64P
7676
opts = slices.Concat(r.Options, opts)
7777
path := "v1/assets/upload/base64"
7878
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
79-
return
79+
return res, err
8080
}
8181

8282
type AssetDownloadResponse struct {

chat.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,19 @@ func (r *ChatService) New(ctx context.Context, body ChatNewParams, opts ...optio
5454
opts = slices.Concat(r.Options, opts)
5555
path := "v1/chats"
5656
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
57-
return
57+
return res, err
5858
}
5959

6060
// Retrieve chat details including metadata, participants, and latest message
6161
func (r *ChatService) Get(ctx context.Context, chatID string, query ChatGetParams, opts ...option.RequestOption) (res *Chat, err error) {
6262
opts = slices.Concat(r.Options, opts)
6363
if chatID == "" {
6464
err = errors.New("missing required chatID parameter")
65-
return
65+
return nil, err
6666
}
6767
path := fmt.Sprintf("v1/chats/%s", chatID)
6868
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
69-
return
69+
return res, err
7070
}
7171

7272
// List all chats sorted by last activity (most recent first). Combines all
@@ -101,11 +101,11 @@ func (r *ChatService) Archive(ctx context.Context, chatID string, body ChatArchi
101101
opts = append([]option.RequestOption{option.WithHeader("Accept", "*/*")}, opts...)
102102
if chatID == "" {
103103
err = errors.New("missing required chatID parameter")
104-
return
104+
return err
105105
}
106106
path := fmt.Sprintf("v1/chats/%s/archive", chatID)
107107
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, nil, opts...)
108-
return
108+
return err
109109
}
110110

111111
// Search chats by title/network or participants using Beeper Desktop's renderer

chatmessagereaction.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,31 +44,31 @@ func (r *ChatMessageReactionService) Delete(ctx context.Context, messageID strin
4444
opts = slices.Concat(r.Options, opts)
4545
if params.ChatID == "" {
4646
err = errors.New("missing required chatID parameter")
47-
return
47+
return nil, err
4848
}
4949
if messageID == "" {
5050
err = errors.New("missing required messageID parameter")
51-
return
51+
return nil, err
5252
}
5353
path := fmt.Sprintf("v1/chats/%s/messages/%s/reactions", params.ChatID, messageID)
5454
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, params, &res, opts...)
55-
return
55+
return res, err
5656
}
5757

5858
// Add a reaction to an existing message.
5959
func (r *ChatMessageReactionService) Add(ctx context.Context, messageID string, params ChatMessageReactionAddParams, opts ...option.RequestOption) (res *ChatMessageReactionAddResponse, err error) {
6060
opts = slices.Concat(r.Options, opts)
6161
if params.ChatID == "" {
6262
err = errors.New("missing required chatID parameter")
63-
return
63+
return nil, err
6464
}
6565
if messageID == "" {
6666
err = errors.New("missing required messageID parameter")
67-
return
67+
return nil, err
6868
}
6969
path := fmt.Sprintf("v1/chats/%s/messages/%s/reactions", params.ChatID, messageID)
7070
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...)
71-
return
71+
return res, err
7272
}
7373

7474
type ChatMessageReactionDeleteResponse struct {

chatreminder.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ func (r *ChatReminderService) New(ctx context.Context, chatID string, body ChatR
4242
opts = append([]option.RequestOption{option.WithHeader("Accept", "*/*")}, opts...)
4343
if chatID == "" {
4444
err = errors.New("missing required chatID parameter")
45-
return
45+
return err
4646
}
4747
path := fmt.Sprintf("v1/chats/%s/reminders", chatID)
4848
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, nil, opts...)
49-
return
49+
return err
5050
}
5151

5252
// Clear an existing reminder from a chat
@@ -55,11 +55,11 @@ func (r *ChatReminderService) Delete(ctx context.Context, chatID string, opts ..
5555
opts = append([]option.RequestOption{option.WithHeader("Accept", "*/*")}, opts...)
5656
if chatID == "" {
5757
err = errors.New("missing required chatID parameter")
58-
return
58+
return err
5959
}
6060
path := fmt.Sprintf("v1/chats/%s/reminders", chatID)
6161
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, nil, opts...)
62-
return
62+
return err
6363
}
6464

6565
type ChatReminderNewParams struct {

client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ func (r *Client) Focus(ctx context.Context, body FocusParams, opts ...option.Req
135135
opts = slices.Concat(r.Options, opts)
136136
path := "v1/focus"
137137
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
138-
return
138+
return res, err
139139
}
140140

141141
// Returns matching chats, participant name matches in groups, and the first page
@@ -145,5 +145,5 @@ func (r *Client) Search(ctx context.Context, query SearchParams, opts ...option.
145145
opts = slices.Concat(r.Options, opts)
146146
path := "v1/search"
147147
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
148-
return
148+
return res, err
149149
}

info.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func (r *InfoService) Get(ctx context.Context, opts ...option.RequestOption) (re
4040
opts = slices.Concat(r.Options, opts)
4141
path := "v1/info"
4242
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
43-
return
43+
return res, err
4444
}
4545

4646
type InfoGetResponse struct {

message.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ func (r *MessageService) Update(ctx context.Context, messageID string, params Me
4848
opts = slices.Concat(r.Options, opts)
4949
if params.ChatID == "" {
5050
err = errors.New("missing required chatID parameter")
51-
return
51+
return nil, err
5252
}
5353
if messageID == "" {
5454
err = errors.New("missing required messageID parameter")
55-
return
55+
return nil, err
5656
}
5757
path := fmt.Sprintf("v1/chats/%s/messages/%s", params.ChatID, messageID)
5858
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &res, opts...)
59-
return
59+
return res, err
6060
}
6161

6262
// List all messages in a chat with cursor-based pagination. Sorted by timestamp.
@@ -66,7 +66,7 @@ func (r *MessageService) List(ctx context.Context, chatID string, query MessageL
6666
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
6767
if chatID == "" {
6868
err = errors.New("missing required chatID parameter")
69-
return
69+
return nil, err
7070
}
7171
path := fmt.Sprintf("v1/chats/%s/messages", chatID)
7272
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
@@ -115,11 +115,11 @@ func (r *MessageService) Send(ctx context.Context, chatID string, body MessageSe
115115
opts = slices.Concat(r.Options, opts)
116116
if chatID == "" {
117117
err = errors.New("missing required chatID parameter")
118-
return
118+
return nil, err
119119
}
120120
path := fmt.Sprintf("v1/chats/%s/messages", chatID)
121121
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
122-
return
122+
return res, err
123123
}
124124

125125
type MessageUpdateResponse struct {

0 commit comments

Comments
 (0)