Beispiel #1
0
        public static ResultState DeleteUser(this DiscourseApi api, string username, string apiUserName = DefaultUsername)
        {
            var path = String.Format("/users/{0}.json", username);
            var data = new UpdateUsername(username);

            var result = api.ExecuteRequest<RestResponse>(path, Method.DELETE, true, apiUserName, null, data);

            switch (result.StatusCode)
            {
                case (HttpStatusCode) 422:
                    return ResultState.Unchanged;
                case HttpStatusCode.OK:
                    return ResultState.Deleted;
                default:
                    return ResultState.Error;
            }
        }
Beispiel #2
0
        public static ResultState UpdateUsername(this DiscourseApi api, string username, string newUsername,
			string apiUserName = DefaultUsername)
        {
            var path = String.Format("/users/{0}/preferences/username", username);
            var data = new UpdateUsername(newUsername);

            var result = api.ExecuteRequest<RestResponse>(path, Method.PUT, true, apiUserName, null, data);

            switch (result.StatusCode)
            {
                case (HttpStatusCode) 422:
                    return ResultState.Unchanged;
                case HttpStatusCode.OK:
                    return ResultState.Modified;
                default:
                    return ResultState.Error;
            }
        }