public void Test() { try { List <Record> rowList = new List <Record>(); 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 Record(user_fields, postalCode: "11368")); List <user_field> user_fieldsample = new List <user_field>(); rowList.Add(new Record(null, postalCode: "11208")); options op = new options(); input input = new input(); input.RecordList = rowList; GetCityStateProvinceAPIRequest request = new GetCityStateProvinceAPIRequest(input, op); GetCityStateProvinceAPIResponse response = identifyAddressService.GetCityStateProvince(request); Assert.IsInstanceOfType(response, typeof(GetCityStateProvinceAPIResponse)); string output = Utility.ObjectToJson <GetCityStateProvinceAPIResponse>(response); Debug.WriteLine(output); } catch (Exception e) { Assert.Fail("Unexpected Exception"); } }
/// <summary> /// Retrieves response for the input records request. /// Accepts the postal code records request as input and returns city and state province /// </summary> /// <param name="request">Required - GetCityStateProvinceAPIRequest request (object filled with input and option) </param> /// <returns>GetCityStateProvinceAPIResponse</returns> public GetCityStateProvinceAPIResponse GetCityStateProvince(GetCityStateProvinceAPIRequest request) { UrlMaker urlMaker = UrlMaker.getInstance(); StringBuilder urlBuilder = new StringBuilder(urlMaker.getAbsoluteUrl(identifyAddressUrl)); string url = urlBuilder.ToString() + getCityStateProvinceUrl; String requestString = Utility.ObjectToJson <GetCityStateProvinceAPIRequest>(request); return(Utility.processAPIRequest <GetCityStateProvinceAPIResponse>(url, requestString)); }
/// <summary> /// Retrieves response for the input records request in asynchronous mode. /// Response can be retrieved by subscribing to event GetCityStateProvinceFinishedEvent. /// Accepts the postal code records request as input and returns city and state province /// </summary> /// <param name="request">Required - GetCityStateProvinceAPIRequest request (object filled with input and option) </param> public void GetCityStateProvinceAsync(GetCityStateProvinceAPIRequest request) { UrlMaker urlMaker = UrlMaker.getInstance(); StringBuilder urlBuilder = new StringBuilder(urlMaker.getAbsoluteUrl(identifyAddressUrl)); string url = urlBuilder.ToString() + getCityStateProvinceUrl; String requestString = Utility.ObjectToJson <GetCityStateProvinceAPIRequest>(request); processAPIRequestDelegate <GetCityStateProvinceAPIResponse> delegateApiRequest = new processAPIRequestDelegate <GetCityStateProvinceAPIResponse>(Utility.processAPIRequest <GetCityStateProvinceAPIResponse>); delegateApiRequest.BeginInvoke(url, requestString, new AsyncCallback(WorkflowCompletedCallbackGetCityStateProvince), null); }
public void TestAsync() { try { Boolean failFlag = false; this.TriggerTest = new AutoResetEvent(false); identifyAddressService.GetCityStateProvinceFinishedEvent += (object sender, WebResponseEventArgs <GetCityStateProvinceAPIResponse> eventArgs) => { try { Assert.IsTrue(eventArgs.ResponseObject != null); this.TriggerTest.Set(); } catch (Exception) { failFlag = true; this.TriggerTest.Set(); } }; List <Record> rowList = new List <Record>(); List <user_field> user_fieldsample = new List <user_field>(); rowList.Add(new Record(user_fieldsample, postalCode: "11368")); rowList.Add(new Record(user_fieldsample, postalCode: "11208")); options op = new options(); input input = new input(); input.RecordList = rowList; GetCityStateProvinceAPIRequest request = new GetCityStateProvinceAPIRequest(input, op); identifyAddressService.GetCityStateProvinceAsync(request); this.TriggerTest.WaitOne(10000); if (failFlag) { Assert.Fail("Test Case Failed"); } } catch (Exception e) { Assert.Fail("Unexpected Exception"); } }
public void getRecordjsonTestAndCompareSDKResponseTest() { try { String inputjsonRecords = "{\"Input\": {" + "\"Row\":[{" + "\"PostalCode\": \"11368\"" + "}," + "{" + "\"PostalCode\": \"11208\"" + "}]}}"; List <Record> rowList = new List <Record>(); 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 Record(null, postalCode: "11368")); List <user_field> user_fieldsample = new List <user_field>(); rowList.Add(new Record(null, postalCode: "11208")); options op = new options(); input input = new input(); input.RecordList = rowList; GetCityStateProvinceAPIRequest request = new GetCityStateProvinceAPIRequest(input, op); GetCityStateProvinceAPIResponse response = identifyAddressService.GetCityStateProvince(request); string sdkResponse = Utility.ObjectToJson <GetCityStateProvinceAPIResponse>(response); String apiResponse = TestUtility.ValidateFromAPI(TEST_URL, "/identifyaddress/v1/rest/getcitystateprovince/", TEST_TOKEN, inputjsonRecords, com.pb.identify.utils.Utility.contentType.json); Assert.AreEqual(sdkResponse, apiResponse); } catch (Exception e) { Assert.Fail("Unexpected Exception"); } }