Пример #1
0
        public VatLookupResponse VatLookup(VatLookupRequest lookup)
        {
            using (WebClient client = new WebClient())
            {
                HttpClient httpClient         = new HttpClient();
                MultipartFormDataContent form = new MultipartFormDataContent();

                //form.Add(new ByteArrayContent(inputBytes, 0, inputBytes.Length), "inputFile", fileName);


                httpClient.DefaultRequestHeaders.Add("Apikey", Apikey);

                string stringPayload = JsonConvert.SerializeObject(lookup);

                var httpContent = new StringContent(stringPayload, Encoding.UTF8, "application/json");

                HttpResponseMessage response = httpClient.PostAsync(
                    "https://api.cloudmersive.com/validate/vat/lookup", httpContent).Result;

                response.EnsureSuccessStatusCode();
                httpClient.Dispose();
                var sd = response.Content.ReadAsStringAsync().Result;// ReadAsStringAsync().Result;



                return(JsonConvert.DeserializeObject <VatLookupResponse>(sd));
            }
        }
        private void btnVATLookup_Click(object sender, RoutedEventArgs e)
        {
            CloudmersiveValidationApiClient client = new CloudmersiveValidationApiClient();

            VatLookupRequest req = new VatLookupRequest();

            req.VatCode = txtVAT.Text;

            VatLookupResponse response = client.VatLookup(req);

            txtOutput.Text = JsonConvert.SerializeObject(response);
        }
Пример #3
0
        /// <summary>
        /// Validate a VAT number Checks if a VAT code is valid, and if it is, returns more information about it.  The first two letters of the VAT number must be letters that indicate the country, such as LU20260743.  Possible country codes include Austria (AT), Belgium (BE), Bulgaria (BG), Cyprus (CY), Czech Republic (CZ), Germany (DE), Denmark (DK), Estonia (EE), Greece (EL), Spain (ES), Finland (FI), France (FR), United Kingdom (GB), Croatia (HR), Hungary (HU), Ireland (IE), Italy (IT), Lithuania (LT), Luxembourg (LU), Latvia (LV), Malta (MT), The Netherlands (NL), Poland (PL), Portugal (PT), Romania (RO), Sweden (SE), Slovenia (SI), Slovakia (SK).
        /// </summary>
        /// <exception cref="Cloudmersive.APIClient.NETCore.Validate.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="input">Input VAT code</param>
        /// <returns>Task of ApiResponse (VatLookupResponse)</returns>
        public async System.Threading.Tasks.Task <ApiResponse <VatLookupResponse> > VatVatLookupAsyncWithHttpInfo(VatLookupRequest input)
        {
            // verify the required parameter 'input' is set
            if (input == null)
            {
                throw new ApiException(400, "Missing required parameter 'input' when calling VatApi->VatVatLookup");
            }

            var    localVarPath         = "./validate/vat/lookup";
            var    localVarPathParams   = new Dictionary <String, String>();
            var    localVarQueryParams  = new List <KeyValuePair <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",
                "text/json"
            };
            String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

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

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

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

            // authentication (Apikey) required
            if (!String.IsNullOrEmpty(this.Configuration.GetApiKeyWithPrefix("Apikey")))
            {
                localVarHeaderParams["Apikey"] = this.Configuration.GetApiKeyWithPrefix("Apikey");
            }

            // 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("VatVatLookup", localVarResponse);
                if (exception != null)
                {
                    throw exception;
                }
            }

            return(new ApiResponse <VatLookupResponse>(localVarStatusCode,
                                                       localVarResponse.Headers.ToDictionary(x => x.Key, x => x.Value.ToString()),
                                                       (VatLookupResponse)this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(VatLookupResponse))));
        }
Пример #4
0
        /// <summary>
        /// Validate a VAT number Checks if a VAT code is valid, and if it is, returns more information about it.  The first two letters of the VAT number must be letters that indicate the country, such as LU20260743.  Possible country codes include Austria (AT), Belgium (BE), Bulgaria (BG), Cyprus (CY), Czech Republic (CZ), Germany (DE), Denmark (DK), Estonia (EE), Greece (EL), Spain (ES), Finland (FI), France (FR), United Kingdom (GB), Croatia (HR), Hungary (HU), Ireland (IE), Italy (IT), Lithuania (LT), Luxembourg (LU), Latvia (LV), Malta (MT), The Netherlands (NL), Poland (PL), Portugal (PT), Romania (RO), Sweden (SE), Slovenia (SI), Slovakia (SK).
        /// </summary>
        /// <exception cref="Cloudmersive.APIClient.NETCore.Validate.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="input">Input VAT code</param>
        /// <returns>Task of VatLookupResponse</returns>
        public async System.Threading.Tasks.Task <VatLookupResponse> VatVatLookupAsync(VatLookupRequest input)
        {
            ApiResponse <VatLookupResponse> localVarResponse = await VatVatLookupAsyncWithHttpInfo(input);

            return(localVarResponse.Data);
        }
Пример #5
0
        /// <summary>
        /// Validate a VAT number Checks if a VAT code is valid, and if it is, returns more information about it.  The first two letters of the VAT number must be letters that indicate the country, such as LU20260743.  Possible country codes include Austria (AT), Belgium (BE), Bulgaria (BG), Cyprus (CY), Czech Republic (CZ), Germany (DE), Denmark (DK), Estonia (EE), Greece (EL), Spain (ES), Finland (FI), France (FR), United Kingdom (GB), Croatia (HR), Hungary (HU), Ireland (IE), Italy (IT), Lithuania (LT), Luxembourg (LU), Latvia (LV), Malta (MT), The Netherlands (NL), Poland (PL), Portugal (PT), Romania (RO), Sweden (SE), Slovenia (SI), Slovakia (SK).
        /// </summary>
        /// <exception cref="Cloudmersive.APIClient.NETCore.Validate.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="input">Input VAT code</param>
        /// <returns>VatLookupResponse</returns>
        public VatLookupResponse VatVatLookup(VatLookupRequest input)
        {
            ApiResponse <VatLookupResponse> localVarResponse = VatVatLookupWithHttpInfo(input);

            return(localVarResponse.Data);
        }