public Result <Reseller> UpdateReseller(long resellerId, ResellerUpdateRequest resellerUpdateRequest) { IList <string> validationErrs = ValidateUpdate(resellerId, resellerUpdateRequest, new ResellerUpdateValidator(), "resellerIdInvalid", "resellerUpdateRequestIsNull"); if (validationErrs.Count > 0) { return(new Result <Reseller>(validationErrs)); } RestRequest request = new RestRequest(UPDATE_RESELLER_URL, Method.PUT); var resellerJson = JsonConvert.SerializeObject(resellerUpdateRequest); request.AddParameter(Constants.CONTENT_TYPE_JSON, resellerJson, ParameterType.RequestBody); request.AddUrlSegment("resellerId", resellerId); var responseContent = Execute(request); ResellerResponse resellerResponse = JsonConvert.DeserializeObject <ResellerResponse>(responseContent); Result <Reseller> result = new Result <Reseller>(resellerResponse); return(result); }
public void TestCreateUpdateActivateDisableDelete() { ResellerCreateRequest request = new ResellerCreateRequest(); request.Name = "Reseller For Test5"; request.Address = "suzhou"; request.Email = "*****@*****.**"; request.Country = "CN"; request.Contact = "ZhangSan"; request.Phone = "88889999"; Result <Reseller> createResult = API.CreateReseller(request); _logger.DebugFormat("Result=\n{0}", JsonConvert.SerializeObject(createResult)); Assert.AreEqual(createResult.BusinessCode, 0); Result <PagedReseller> searchResultAfterCreate = API.SearchReseller(1, 10, ResellerSearchOrderBy.Name, "Reseller For Test", ResellerStatus.All); _logger.DebugFormat("Search Result After Create=\n{0}", JsonConvert.SerializeObject(searchResultAfterCreate)); Assert.IsTrue(searchResultAfterCreate.BusinessCode == 0); Assert.IsTrue(searchResultAfterCreate.PageInfo.TotalCount > 0); long resellerId = createResult.Data.ID; ResellerUpdateRequest updateRequest = new ResellerUpdateRequest(); updateRequest.Name = "Reseller For Test5"; updateRequest.Address = "suzhou2"; updateRequest.Email = "*****@*****.**"; updateRequest.Country = "CN"; updateRequest.Contact = "ZhangSan2"; updateRequest.Phone = "44445555"; updateRequest.ParentResellerName = "GLOBAL"; Result <Reseller> updateResult = API.UpdateReseller(resellerId, updateRequest); _logger.DebugFormat("Update Result=\n{0}", JsonConvert.SerializeObject(updateResult)); Assert.AreEqual(updateResult.BusinessCode, 0); Assert.AreEqual("suzhou2", updateResult.Data.Address); Assert.AreEqual("ZhangSan2", updateResult.Data.Contact); Assert.AreEqual("44445555", updateResult.Data.Phone); Result <string> activateResult = API.ActivateReseller(resellerId); _logger.DebugFormat("Activate Result=\n{0}", JsonConvert.SerializeObject(activateResult)); Assert.AreEqual(activateResult.BusinessCode, 0); Result <string> replaceEmailResult = API.ReplaceResellerEmail(resellerId, "*****@*****.**"); _logger.DebugFormat("Replace Email Result=\n{0}", JsonConvert.SerializeObject(replaceEmailResult)); Assert.AreEqual(replaceEmailResult.BusinessCode, 0); Result <string> disableResult = API.DisableReseller(resellerId); _logger.DebugFormat("Disable Result=\n{0}", JsonConvert.SerializeObject(disableResult)); Assert.AreEqual(disableResult.BusinessCode, 0); Result <string> deleteResult = API.DeleteReseller(resellerId); _logger.DebugFormat("Delete Result=\n{0}", JsonConvert.SerializeObject(deleteResult)); Assert.AreEqual(deleteResult.BusinessCode, 0); Result <PagedReseller> searchResult = API.SearchReseller(1, 10, ResellerSearchOrderBy.Name, "Reseller For Test5", ResellerStatus.All); _logger.DebugFormat("Search Result After Delete=\n{0}", JsonConvert.SerializeObject(searchResult)); Assert.IsTrue(searchResult.BusinessCode == 0); Assert.IsTrue(searchResult.PageInfo.TotalCount == 0); }
public void TestCreateResellerSuccess() { ResellerCreateRequest request = new ResellerCreateRequest(); request.Name = "TestResellerToDelete3"; request.Address = "suzhou"; request.Email = "*****@*****.**"; request.Country = "CN"; request.Contact = "ZhangSan"; request.Phone = "22323"; request.ParentResellerName = "reseller test"; request.setActivateWhenCreate(false); Result <Reseller> result = API.CreateReseller(request); _logger.DebugFormat("Result=\n{0}", JsonConvert.SerializeObject(result)); Assert.AreEqual(result.BusinessCode, 0); //Test get reseller by id long resellerId = result.Data.ID; ResellerUpdateRequest updateRequest = new ResellerUpdateRequest(); updateRequest.Name = "TestResellerToDelete4"; updateRequest.Address = "suzhou2"; updateRequest.Email = "*****@*****.**"; updateRequest.Country = "CN"; updateRequest.Contact = "ZhangSan2"; updateRequest.Phone = "44445555"; updateRequest.ParentResellerName = "reseller test"; Result <Reseller> updateResult = API.UpdateReseller(resellerId, updateRequest); _logger.DebugFormat("Update Result=\n{0}", JsonConvert.SerializeObject(updateResult)); Assert.AreEqual(updateResult.BusinessCode, 0); Assert.AreEqual("suzhou2", updateResult.Data.Address); Assert.AreEqual("ZhangSan2", updateResult.Data.Contact); Assert.AreEqual("44445555", updateResult.Data.Phone); Result <Reseller> getResellerResult = API.GetReseller(resellerId); _logger.DebugFormat("Result=\n{0}", JsonConvert.SerializeObject(getResellerResult)); Assert.AreEqual(0, getResellerResult.BusinessCode); //Test activate reseller Result <string> activateResellerResult = API.ActivateReseller(resellerId); _logger.DebugFormat("Result=\n{0}", JsonConvert.SerializeObject(activateResellerResult)); Assert.AreEqual(activateResellerResult.BusinessCode, 0); Result <string> replaceEmailResult = API.ReplaceResellerEmail(resellerId, "*****@*****.**"); _logger.DebugFormat("Result=\n{0}", JsonConvert.SerializeObject(replaceEmailResult)); Assert.AreEqual(replaceEmailResult.BusinessCode, 0); //Test activate reseller already active Result <string> activateResellerResult2 = API.ActivateReseller(resellerId); _logger.DebugFormat("Result=\n{0}", JsonConvert.SerializeObject(activateResellerResult2)); Assert.AreEqual(activateResellerResult2.BusinessCode, 1891); //Test disable reseller Result <string> disableResellerResult = API.DisableReseller(resellerId); _logger.DebugFormat("Result=\n{0}", JsonConvert.SerializeObject(disableResellerResult)); Assert.AreEqual(disableResellerResult.BusinessCode, 0); //Test delete Result <string> deleteResellerResult = API.DeleteReseller(resellerId); _logger.DebugFormat("Result=\n{0}", JsonConvert.SerializeObject(deleteResellerResult)); Assert.AreEqual(deleteResellerResult.BusinessCode, 0); }