Syncano.Net.Api.UserSyncanoClient.Update C# (CSharp) Method

Update() public method

Updates a specified user. User API key usage permitted. In this case, it can only be used to update currently associated user's data. User_id is automatically filled with current user's id. The user_id/user_name parameter means that one can use either one of them - user_id or user_name.
public Update ( string userId = null, string userName = null, string nick = null, string avatar = null, string newPassword = null, string currentPassword = null ) : Task
userId string User id defining user. If both id and name are specified, will use id for getting user while user_name will be updated with provided new value. User_id is automatically filled when used with User API key.
userName string User name defining user. If both id and name are specified, will use id for getting user while user_name will be updated with provided new value.
nick string New user nickname.
avatar string User avatar. If specified as empty string - will instead delete current avatar.
newPassword string New user password.
currentPassword string Current password for confirmation. Required only when used with User API key and new_password is specified.
return Task
        public Task<User> Update(string userId = null, string userName = null, string nick = null,
            string avatar = null, string newPassword = null, string currentPassword = null)
        {
            return _syncanoClient.PostAsync<User>("user.update",
                new
                {
                    user_id = userId,
                    user_name = userName,
                    nick,
                    avatar,
                    new_password = newPassword,
                    current_password = currentPassword
                }, "user");
        }

Usage Example

        public async Task Update_DeleteAvatar_UpdatesUserObject(UserSyncanoClient client)
        {
            //given
            string name = "newUserName" + Guid.NewGuid().GetHashCode();
            const string password = "******";
            var user = await client.New(name, password, avatar: TestData.ImageToBase64("smallSampleImage.png"));

            //when
            var updatedUser = await client.Update(user.Id, avatar: "", currentPassword: password);

            //then
            updatedUser.ShouldNotBeNull();
            updatedUser.Id.ShouldEqual(user.Id);
            updatedUser.Avatar.ShouldBeNull();

            //cleanup
            await client.Delete(user.Id);
        }
All Usage Examples Of Syncano.Net.Api.UserSyncanoClient::Update