Skip to content

Commit f095e04

Browse files
authored
fix(api): fix device name update endpoint & usage (#42)
1 parent 963cab2 commit f095e04

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

cloudflare/api.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ func (w *WarpAPI) UpdateAccount(authToken, deviceID, license string) (model.Iden
321321
}
322322

323323
func (w *WarpAPI) UpdateBoundDevice(authToken, deviceID, otherDeviceID, name string, active bool) (model.IdentityDevice, error) {
324-
reqUrl := fmt.Sprintf("%s/reg/%s/account/reg/%s", apiBase, deviceID, otherDeviceID)
324+
reqUrl := fmt.Sprintf("%s/reg/%s/account/devices/%s", apiBase, deviceID, otherDeviceID)
325325
method := "PATCH"
326326

327327
data := map[string]interface{}{
@@ -370,11 +370,11 @@ func (w *WarpAPI) UpdateBoundDevice(authToken, deviceID, otherDeviceID, name str
370370
return rspData, nil
371371
}
372372

373-
func (w *WarpAPI) UpdateSourceDevice(authToken, deviceID, publicKey string) (model.Identity, error) {
373+
func (w *WarpAPI) UpdateSourceDevice(authToken, deviceID string, data map[string]interface{}) (model.Identity, error) {
374374
reqUrl := fmt.Sprintf("%s/reg/%s", apiBase, deviceID)
375375
method := "PATCH"
376376

377-
jsonBody, err := json.Marshal(map[string]interface{}{"key": publicKey})
377+
jsonBody, err := json.Marshal(data)
378378
if err != nil {
379379
return model.Identity{}, err
380380
}

cmd/update.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func runUpdate() error {
5454

5555
// Update device name if provided
5656
if name != "" {
57-
_, err = warpAPI.UpdateBoundDevice(identity.Token, identity.ID, identity.ID, name, true)
57+
_, err = warpAPI.UpdateSourceDevice(identity.Token, identity.ID, map[string]interface{}{"name": name})
5858
if err != nil {
5959
return fmt.Errorf("failed to update device name: %w", err)
6060
}

0 commit comments

Comments
 (0)