public void Test() { try { List <Address> rowList = new List <Address>(); user_field userfield = new user_field { name = "email", value = "*****@*****.**" }; List <user_field> user_fields = new List <user_field>(); user_fields.Add(userfield); rowList.Add(new Address(user_fields, addressline1: "101 cherry st")); List <user_field> user_fieldsample = new List <user_field>(); rowList.Add(new Address(null, addressline1: "12 yonge st", country: "ca", stateorprovince: "on")); options op = new options(); input input = new input(); input.AddressList = rowList; ValidateMailingAddressAPIRequest request = new ValidateMailingAddressAPIRequest(input, op); ValidateMailingAddressAPIResponse response = identifyAddressService.ValidateMailingAddress(request); Assert.IsInstanceOfType(response, typeof(ValidateMailingAddressAPIResponse)); string output = Utility.ObjectToJson <ValidateMailingAddressAPIResponse>(response); Debug.WriteLine(output); } catch (Exception e) { Assert.Fail("Unexpected Exception"); } }
/// <summary> /// Validates the input address request in asynchronous mode. /// Response can be retrieved by subscribing to event IdentifyAPIRequestFinishedEvent. /// Accepts the address request as input and returns validated addresses /// </summary> /// <param name="request">Required - ValidateMailingAddressAPIRequest request (object filled with input and option) </param> public void ValidateMailingAddressAsync(ValidateMailingAddressAPIRequest request) { UrlMaker urlMaker = UrlMaker.getInstance(); StringBuilder urlBuilder = new StringBuilder(urlMaker.getAbsoluteUrl(identifyAddressUrl)); string url = urlBuilder.ToString() + validateMailingAddressUrl; String requestString = Utility.ObjectToJson <ValidateMailingAddressAPIRequest>(request); processAPIRequestDelegate <ValidateMailingAddressAPIResponse> delegateApiRequest = new processAPIRequestDelegate <ValidateMailingAddressAPIResponse>(Utility.processAPIRequest <ValidateMailingAddressAPIResponse>); delegateApiRequest.BeginInvoke(url, requestString, new AsyncCallback(WorkflowCompletedCallbackValidateAddress), null); }
/// <summary> /// Validates the input address request. /// Accepts the address request as input and returns validated addresses /// </summary> /// <param name="request">Required - ValidateMailingAddressAPIRequest request (object filled with input and option) </param> /// <returns>ValidateMailingAddressAPIResponse</returns> public ValidateMailingAddressAPIResponse ValidateMailingAddress(ValidateMailingAddressAPIRequest request) { UrlMaker urlMaker = UrlMaker.getInstance(); StringBuilder urlBuilder = new StringBuilder(urlMaker.getAbsoluteUrl(identifyAddressUrl)); string url = urlBuilder.ToString() + validateMailingAddressUrl; String requestString = Utility.ObjectToJson <ValidateMailingAddressAPIRequest>(request); return(Utility.processAPIRequest <ValidateMailingAddressAPIResponse>(url, requestString)); }
public void getAddressjsonTestAndCompareSDKResponseTest() { try { String inputjsonAddresses = "{\"Input\": {" + "\"Row\":[{" + "\"AddressLine1\": \"101 cherry st\"," + "\"Country\": \"us\"," + "\"PostalCode\": \"\"" + "}," + "{" + "\"AddressLine1\": \"12 yonge st\"," + "\"City\": \"toronto\"," + "\"Country\": \"ca\"," + "\"StateProvince\": \"on\"," + "\"PostalCode\": \"\"" + "}]}}"; List <Address> rowList = new List <Address>(); user_field userfield = new user_field { name = "email", value = "*****@*****.**" }; List <user_field> user_fields = new List <user_field>(); user_fields.Add(userfield); rowList.Add(new Address(null, addressline1: "101 cherry st", country: "us")); List <user_field> user_fieldsample = new List <user_field>(); rowList.Add(new Address(null, addressline1: "12 yonge st", country: "ca", stateorprovince: "on", city: "toronto")); options op = new options(); input input = new input(); input.AddressList = rowList; ValidateMailingAddressAPIRequest request = new ValidateMailingAddressAPIRequest(input, op); ValidateMailingAddressAPIResponse response = identifyAddressService.ValidateMailingAddress(request); string sdkResponse = Utility.ObjectToJson <ValidateMailingAddressAPIResponse>(response); String apiResponse = TestUtility.ValidateFromAPI(TEST_URL, "/identifyaddress/v1/rest/validatemailingaddress/", TEST_TOKEN, inputjsonAddresses, com.pb.identify.utils.Utility.contentType.json); Assert.AreEqual(sdkResponse, apiResponse); } catch (Exception e) { Assert.Fail("Unexpected Exception"); } }
public void TestAsync() { try { Boolean failFlag = false; this.TriggerTest = new AutoResetEvent(false); identifyAddressService.IdentifyAPIRequestFinishedEvent += (object sender, WebResponseEventArgs <ValidateMailingAddressAPIResponse> eventArgs) => { try { Assert.IsTrue(eventArgs.ResponseObject != null); this.TriggerTest.Set(); } catch (Exception) { failFlag = true; this.TriggerTest.Set(); } }; List <Address> rowList = new List <Address>(); List <user_field> user_fieldsample = new List <user_field>(); rowList.Add(new Address(user_fieldsample, addressline1: "101 cherry st")); rowList.Add(new Address(user_fieldsample, addressline1: "12 yonge st", country: "ca", stateorprovince: "on")); options op = new options(); input input = new input(); input.AddressList = rowList; ValidateMailingAddressAPIRequest request = new ValidateMailingAddressAPIRequest(input, op); identifyAddressService.ValidateMailingAddressAsync(request); this.TriggerTest.WaitOne(10000); if (failFlag) { Assert.Fail("Test Case Failed"); } } catch (Exception e) { Assert.Fail("Unexpected Exception"); } }