public void Test()
        {
            try
            {
                List <Record> rowList = new List <Record>();

                List <user_field> user_fields = new List <user_field>();
                user_field        userfield   = new user_field {
                    name = "name1", value = "value1"
                };
                user_fields.Add(userfield);

                rowList.Add(new Record(user_fields, emailaddress: "*****@*****.**"));

                rowList.Add(new Record(null, bogus: "true", emailaddress: "*****@*****.**"));

                input input = new input();
                input.RecordList = rowList;

                ValidateEmailAddressAPIRequest request = new ValidateEmailAddressAPIRequest(input);

                ValidateEmailAddressAPIResponse response = identifyEmailService.ValidateEmailAddress(request);

                Assert.IsInstanceOfType(response, typeof(ValidateEmailAddressAPIResponse));
                string output = Utility.ObjectToJson <ValidateEmailAddressAPIResponse>(response);
                Debug.WriteLine(output);
            }
            catch (Exception e)
            {
                Assert.Fail("Unexpected exception");
            }
        }
        public void getAddressjsonTestAndCompareSDKResponseTest()
        {
            try
            {
                String inputjsonAddresses = "{\"Input\": {" + "\"Row\":[{" + "\"emailAddress\": \"[email protected]\"" + "}]}}";

                List <Record> rowList = new List <Record>();

                rowList.Add(new Record(null, emailaddress: "*****@*****.**"));

                input input = new input();
                input.RecordList = rowList;

                ValidateEmailAddressAPIRequest request = new ValidateEmailAddressAPIRequest(input);

                ValidateEmailAddressAPIResponse response = identifyEmailService.ValidateEmailAddress(request);
                string sdkResponse = Utility.ObjectToJson <ValidateEmailAddressAPIResponse>(response);

                String apiResponse = TestUtility.ValidateFromAPI(TEST_URL, "/identifyemail/v1/rest/validateemailaddress/", TEST_TOKEN, inputjsonAddresses, com.pb.identify.utils.Utility.contentType.json);

                apiResponse = apiResponse.Replace("\r\n    ", "");
                apiResponse = apiResponse.Replace("{\r\n", "{");

                apiResponse = string.Join("", apiResponse.Split(default(string[]), StringSplitOptions.RemoveEmptyEntries));
                sdkResponse = string.Join("", sdkResponse.Split(default(string[]), StringSplitOptions.RemoveEmptyEntries));
                Assert.AreEqual(sdkResponse, apiResponse);
            }
            catch (Exception e)
            {
                Assert.Fail("Unexpected Exception: " + e);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Matches the input record request.
        /// Accepts the record request as input and returns matched records
        /// </summary>
        /// <param name="request">Required - ValidateEmailAddressAPIRequest request (object filled with input and option) </param>
        /// <returns>ValidateEmailAddressAPIResponse</returns>
        public ValidateEmailAddressAPIResponse ValidateEmailAddress(ValidateEmailAddressAPIRequest request)
        {
            UrlMaker      urlMaker   = UrlMaker.getInstance();
            StringBuilder urlBuilder = new StringBuilder(urlMaker.getAbsoluteUrl(IdentifyEmailUrl));
            string        url        = urlBuilder.ToString() + ValidateEmailAddressUrl;

            String requestString = Utility.ObjectToJson <ValidateEmailAddressAPIRequest>(request);

            return(Utility.processAPIRequest <ValidateEmailAddressAPIResponse>(url, requestString));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Matches the input record request in asynchronous mode.
        /// Response can be retrieved by subscribing to event ValidateEmailAddressFinishedEvent.
        /// Accepts the record request as input and returns matched records
        /// </summary>
        /// <param name="request">Required - ValidateEmailAddressAPIRequest request (object filled with input and option) </param>
        public void ValidateEmailAddressAsync(ValidateEmailAddressAPIRequest request)
        {
            UrlMaker      urlMaker   = UrlMaker.getInstance();
            StringBuilder urlBuilder = new StringBuilder(urlMaker.getAbsoluteUrl(IdentifyEmailUrl));
            string        url        = urlBuilder.ToString() + ValidateEmailAddressUrl;

            String requestString = Utility.ObjectToJson <ValidateEmailAddressAPIRequest>(request);
            processAPIRequestDelegate <ValidateEmailAddressAPIResponse> delegateApiRequest = new processAPIRequestDelegate <ValidateEmailAddressAPIResponse>(Utility.processAPIRequest <ValidateEmailAddressAPIResponse>);

            delegateApiRequest.BeginInvoke(url, requestString, new AsyncCallback(WorkflowCompletedCallbackValidateEmailAddress), null);
        }
        public void TestAsync()
        {
            try
            {
                Boolean failFlag = false;
                this.TriggerTest = new AutoResetEvent(false);
                identifyEmailService.IdentifyAPIRequestFinishedEvent += (object sender, WebResponseEventArgs <ValidateEmailAddressAPIResponse> 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_fields = new List <user_field>();
                user_field        userfield   = new user_field {
                    name = "name1", value = "value1"
                };
                user_fields.Add(userfield);

                rowList.Add(new Record(user_fields, emailaddress: "*****@*****.**"));

                List <user_field> user_fieldsample = new List <user_field>();
                rowList.Add(new Record(null, bogus: "true", emailaddress: "*****@*****.**"));

                input input = new input();
                input.RecordList = rowList;

                ValidateEmailAddressAPIRequest request = new ValidateEmailAddressAPIRequest(input);

                identifyEmailService.ValidateEmailAddressAsync(request);

                this.TriggerTest.WaitOne(10000);
                if (failFlag)
                {
                    Assert.Fail("Test Case Failed");
                }
            }
            catch (Exception e)
            {
                Assert.Fail("Unexpected Exception");
            }
        }
        /// <summary>
        /// ValidateEmailAddress Confirm that your customer’s mailing address exists and that mail and packages can be delivered to it.
        /// </summary>
        /// <exception cref="com.precisely.apis.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="inputEmailAddress"></param>
        /// <param name="cancellationToken">Cancellation Token to cancel request (optional) </param>
        /// <returns>Task of ApiResponse (ValidateEmailAddressAPIResponse)</returns>
        public async System.Threading.Tasks.Task <ApiResponse <ValidateEmailAddressAPIResponse> > ValidateEmailAddressWithHttpInfoAsync(ValidateEmailAddressAPIRequest inputEmailAddress, CancellationToken cancellationToken = default(CancellationToken))
        {
            // verify the required parameter 'inputEmailAddress' is set
            if (inputEmailAddress == null)
            {
                throw new ApiException(400, "Missing required parameter 'inputEmailAddress' when calling EmailVerificationServiceApi->ValidateEmailAddress");
            }

            var    localVarPath         = "/emailverification/v1/validateemailaddress/results.json";
            var    localVarPathParams   = new Dictionary <String, String>();
            var    localVarQueryParams  = new Dictionary <String, String>();
            var    localVarHeaderParams = new Dictionary <String, String>(this.Configuration.DefaultHeader);
            var    localVarFormParams   = new Dictionary <String, String>();
            var    localVarFileParams   = new Dictionary <String, FileParameter>();
            Object localVarPostBody     = null;

            // to determine the Content-Type header
            String[] localVarHttpContentTypes = new String[] {
                "application/json"
            };
            String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            String[] localVarHttpHeaderAccepts = new String[] {
                "application/json",
                "application/xml"
            };
            String localVarHttpHeaderAccept = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);

            if (localVarHttpHeaderAccept != null)
            {
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
            }

            if (inputEmailAddress != null && inputEmailAddress.GetType() != typeof(byte[]))
            {
                localVarPostBody = this.Configuration.ApiClient.Serialize(inputEmailAddress); // http body (model) parameter
            }
            else
            {
                localVarPostBody = inputEmailAddress; // byte array
            }

            // authentication (oAuth2Password) required
            // oauth required
            if (!String.IsNullOrEmpty(this.Configuration.AccessToken))
            {
                localVarHeaderParams["Authorization"] = "Bearer " + this.Configuration.AccessToken;
            }
            else if (!String.IsNullOrEmpty(Configuration.OAuthApiKey) && !String.IsNullOrEmpty(Configuration.OAuthSecret))
            {
                Configuration.ApiClient.GenerateAndSetAccessToken(Configuration.OAuthApiKey, Configuration.OAuthSecret);
                localVarHeaderParams["Authorization"] = "Bearer " + Configuration.AccessToken;
            }

            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse)await this.Configuration.ApiClient.CallApiAsync(localVarPath,
                                                                                                            Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                                                                                                            localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            if (ExceptionFactory != null)
            {
                Exception exception = ExceptionFactory("ValidateEmailAddress", localVarResponse);
                if (exception != null)
                {
                    throw exception;
                }
            }

            return(new ApiResponse <ValidateEmailAddressAPIResponse>(localVarStatusCode,
                                                                     localVarResponse.Headers.ToDictionary(x1 => x1.Name, x1 => x1.Value.ToString()),
                                                                     (ValidateEmailAddressAPIResponse)Configuration.ApiClient.Deserialize(localVarResponse, typeof(ValidateEmailAddressAPIResponse))));
        }
        /// <summary>
        /// ValidateEmailAddress Confirm that your customer’s mailing address exists and that mail and packages can be delivered to it.
        /// </summary>
        /// <exception cref="com.precisely.apis.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="inputEmailAddress"></param>
        /// <param name="cancellationToken">Cancellation Token to cancel request (optional) </param>
        /// <returns>Task of ValidateEmailAddressAPIResponse</returns>
        public async System.Threading.Tasks.Task <ValidateEmailAddressAPIResponse> ValidateEmailAddressAsync(ValidateEmailAddressAPIRequest inputEmailAddress, CancellationToken cancellationToken = default(CancellationToken))
        {
            ApiResponse <ValidateEmailAddressAPIResponse> localVarResponse = await ValidateEmailAddressWithHttpInfoAsync(inputEmailAddress, cancellationToken);

            return(localVarResponse.Data);
        }
        /// <summary>
        /// ValidateEmailAddress Confirm that your customer’s mailing address exists and that mail and packages can be delivered to it.
        /// </summary>
        /// <exception cref="com.precisely.apis.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="inputEmailAddress"></param>
        /// <returns>ValidateEmailAddressAPIResponse</returns>
        public ValidateEmailAddressAPIResponse ValidateEmailAddress(ValidateEmailAddressAPIRequest inputEmailAddress)
        {
            ApiResponse <ValidateEmailAddressAPIResponse> localVarResponse = ValidateEmailAddressWithHttpInfo(inputEmailAddress);

            return(localVarResponse.Data);
        }