Exemplo n.º 1
0
        public void ExecuteUserAddService_v2()
        {
            UserAddServiceRequest request = new UserAddServiceRequest();
            request.app_key = this.app_key;
            request.user_key = this.user_key;
            request.code = "123";
            request.nick = "nickname";
            request.service = "abc";
            request.pwd = "9876";

            ServiceResponse rsp = api.PostRequest<UserAddServiceRequest, ServiceResponse>("user.addservice", request);

            Assert.AreEqual(rsp.status, "FAIL");
        }
Exemplo n.º 2
0
        /// <summary>
        /// Add/update a service to the given user
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>OK. Error message on failure.</returns>
        public ServiceResponse AddService(UserAddServiceRequest request)
        {
            using (var client = GetDefaultClient())
            {
                // build form data post
                HttpMultipartMimeForm form = new HttpMultipartMimeForm();
                form.Add("app_key", this.AppKey);
                form.Add("user_key", this.UserKey);
                form.Add("service", request.service);
                if (!String.IsNullOrWhiteSpace(request.code)) form.Add("code", request.code);
                form.Add("nick", request.nick);
                form.Add("pwd", request.pwd);

                // call method
                using (HttpResponseMessage response = client.Post("user.addservice", form.CreateHttpContent()))
                {
                    response.EnsureStatusIsSuccessful();
                    return response.Content.ReadAsXmlSerializable<ServiceResponse>();
                }
            }
        }
Exemplo n.º 3
0
        public void ExecuteUserAddService_v1()
        {
            UserAddServiceRequest request = new UserAddServiceRequest();
            request.code = "123";
            request.nick = "nickname";
            request.service = "abc";
            request.pwd = "9876";

            ServiceResponse rsp = api.AddService(request);

            Assert.AreEqual(rsp.status, "FAIL");
        }