Exemplo n.º 1
0
        /// <summary>
        /// Create a new user.
        /// </summary>
        /// <param name="userData"> user data to create </param>
        /// <param name="password"> pass </param>
        /// <returns>NoContentStatus</returns>
        public NoContentStatus Create(UserModel userData, string password)
        {
            EnsureHelper.NotNull("UserData", userData);
            EnsureHelper.NotNull("password", password);

            var request = new RestRequest();
            request.Resource = "/user/create";
            request.Method = Method.POST;
            object obj = new { profile = userData, credentials = new { password = password } };
            string output = JsonConvert.SerializeObject(obj);
            request.AddParameter("application/json", output, ParameterType.RequestBody);
            var resp = this.client.Execute(request);
            return ReturnHelper.NoContentReturn(resp.Content, resp.StatusCode);
        }
Exemplo n.º 2
0
        public NoContentStatus Update(UserModel updatedData)
        {
            EnsureHelper.NotNull("UserId", this.model.id);
            EnsureHelper.NotNull("UserData", updatedData);

            var request = new RestRequest();
            request.Resource = "/user/" + this.model.id + "/profile";
            request.Method = Method.PUT;
            string output = JsonConvert.SerializeObject(updatedData);
            request.AddParameter("application/json", output, ParameterType.RequestBody);
            var resp = this.client.Execute(request);
            return ReturnHelper.NoContentReturn(resp.Content, resp.StatusCode);
        }