@@ -249,17 +249,17 @@ func (client *Client) UpdateAccount(account *Account) (*Account, error) {
249
249
return nil , errors .New ("[ERROR] Account ID is empty" )
250
250
}
251
251
252
- existingAccount , err := client .GetAccountByID (id )
252
+ accountToUpdate , err := client .GetAccountByID (id )
253
253
if err != nil {
254
254
return nil , err
255
255
}
256
256
257
- err = mergo .Merge ( account , existingAccount )
257
+ err = mergo .MergeWithOverwrite ( accountToUpdate , account )
258
258
if err != nil {
259
259
return nil , err
260
260
}
261
261
262
- putAccount := AccountDetails {* account }
262
+ putAccount := AccountDetails {* accountToUpdate }
263
263
264
264
body , err := EncodeToJSON (putAccount )
265
265
if err != nil {
@@ -285,20 +285,17 @@ func (client *Client) UpdateAccount(account *Account) (*Account, error) {
285
285
}
286
286
287
287
// Update Features
288
- var featureUpdatePath string
289
- for k , v := range account .Features {
290
- //body
288
+ requestOptions := & RequestOptions {}
289
+ for k , v := range account .Features {
290
+ requestOptions . Body = [] byte ( fmt . Sprintf ( "{ \" feature \" : \" %s \" }" , k ))
291
291
if v {
292
- featureUpdatePath = fmt .Sprintf ("/features/%s" , id )
292
+ requestOptions .Path = fmt .Sprintf ("/features/%s" , id )
293
+ requestOptions .Method = "POST"
293
294
} else {
294
- featureUpdatePath = fmt .Sprintf ("/features/switchOff/%s" , id )
295
- }
296
- bodyFeatures := []byte (fmt .Sprintf ("{\" feature\" : \" %s\" }" , k ))
297
- _ , err = client .RequestAPI (& RequestOptions {
298
- Path : featureUpdatePath ,
299
- Method : "POST" ,
300
- Body : bodyFeatures ,
301
- })
295
+ requestOptions .Path = fmt .Sprintf ("/features/switchOff/%s" , id )
296
+ requestOptions .Method = "PUT"
297
+ }
298
+ _ , err = client .RequestAPI (requestOptions )
302
299
if err != nil {
303
300
return nil , err
304
301
}
0 commit comments