account.go
changeset 202 30bea35361cf
parent 193 f4ac09bc2964
child 204 5cf1e0b45073
equal deleted inserted replaced
201:e14485f0d6a5 202:30bea35361cf
   370 
   370 
   371 // UpdateAccount updates the connected user's account data
   371 // UpdateAccount updates the connected user's account data
   372 // The fields avatar & headerImage can contain base64-encoded images; if
   372 // The fields avatar & headerImage can contain base64-encoded images; if
   373 // they do not (that is; if they don't contain ";base64,"), they are considered
   373 // they do not (that is; if they don't contain ";base64,"), they are considered
   374 // as file paths and their content will be encoded.
   374 // as file paths and their content will be encoded.
       
   375 // Setting 'locked' to true means all followers should be approved.
   375 // All fields can be nil, in which case they are not updated.
   376 // All fields can be nil, in which case they are not updated.
   376 // displayName and note can be set to "" to delete previous values;
   377 // displayName and note can be set to "" to delete previous values;
   377 // I'm not sure images can be deleted -- only replaced AFAICS.
   378 // I'm not sure images can be deleted -- only replaced AFAICS.
   378 func (mc *Client) UpdateAccount(displayName, note, avatar, headerImage *string) (*Account, error) {
   379 func (mc *Client) UpdateAccount(displayName, note, avatar, headerImage *string, locked *bool) (*Account, error) {
   379 	const endPoint = "accounts/update_credentials"
   380 	const endPoint = "accounts/update_credentials"
   380 	params := make(apiCallParams)
   381 	params := make(apiCallParams)
   381 
   382 
   382 	if displayName != nil {
   383 	if displayName != nil {
   383 		params["display_name"] = *displayName
   384 		params["display_name"] = *displayName
   384 	}
   385 	}
   385 	if note != nil {
   386 	if note != nil {
   386 		params["note"] = *note
   387 		params["note"] = *note
       
   388 	}
       
   389 	if locked != nil {
       
   390 		if *locked {
       
   391 			params["locked"] = "true"
       
   392 		} else {
       
   393 			params["locked"] = "false"
       
   394 		}
   387 	}
   395 	}
   388 
   396 
   389 	var err error
   397 	var err error
   390 	avatar, err = fileToBase64(avatar, nil)
   398 	avatar, err = fileToBase64(avatar, nil)
   391 	if err != nil {
   399 	if err != nil {