예제 #1
0
        /// <summary>
        /// legacy method for getting url from wirecard
        /// </summary>
        /// <param name="uri">The URI.</param>
        /// <param name="username">The username.</param>
        /// <param name="password">The password.</param>
        /// <param name="payload">The payload.</param>
        /// <param name="requestType">Type of the request.</param>
        /// <returns>Task&lt;IActionResult&gt;.</returns>
        private async Task <IActionResult> GetRedirectUrlFromWirecard(Uri uri, string username, string password, string payload, RequestFormat requestType)
        {
            var client = new HttpClient();

            client.DefaultRequestHeaders.Authorization = CreateAuthenticationHeader(username, password);

            var contentType = $"application/{requestType.ToString().ToLower()}";

            var response = await client.PostAsync(uri, new StringContent(payload, Encoding.UTF8, contentType));

            if (!response.IsSuccessStatusCode)
            {
                return(Content(await response.Content.ReadAsStringAsync()));
            }


            if (requestType == RequestFormat.Json)
            {
                return(await CreateRedirectUrl(response));
            }
            else
            {
                return(await CreateRedirectUrlXml(response));
            }
        }
예제 #2
0
        public static RestRequest CreateCountriesRequest(int page, int countriesPerPage, RequestFormat format)
        {
            var restReq = new RestRequest(HttpMethod.Get);

            restReq.AddQueryParameter("format", format.ToString());
            restReq.AddQueryParameter("page", page);
            restReq.AddQueryParameter("per_page", countriesPerPage);

            return restReq;
        }
예제 #3
0
        public RequestResult Request(string exportName, RequestFormat format, string savedSearch = null)
        {
            var nvc = new NameValueCollection();
            nvc["export"] = exportName;
            nvc["format"] = format.ToString().ToLower();

            if (!String.IsNullOrEmpty(savedSearch))
            {
                nvc["ss"] = savedSearch;
            }

            return client.GetExpectedJSONResult<RequestResult>("export/request", nvc);
        }
예제 #4
0
        public RequestResult Request(string exportName, RequestFormat format, string savedSearch = null)
        {
            var nvc = new NameValueCollection();

            nvc["export"] = exportName;
            nvc["format"] = format.ToString().ToLower();

            if (!String.IsNullOrEmpty(savedSearch))
            {
                nvc["ss"] = savedSearch;
            }

            return(client.GetExpectedJSONResult <RequestResult>("export/request", nvc));
        }
예제 #5
0
        private void SetRequestData(ref HttpRequestMessage request)
        {
            RequestFormat requestFormat = TestConfig.RequestFormat;

            switch (requestFormat)
            {
            case RequestFormat.Body:
                BuildBodyData(ref request);
                break;

            case RequestFormat.FormData:
                BuildFromData(ref request);
                break;

            default:
                throw new ArgumentOutOfRangeException($"RequestFormat {requestFormat.ToString()} not supported");
            }
        }
예제 #6
0
        public RequestResult Request(string exportName, RequestFormat format, string savedSearch = null, DateTime? since = null, Pool? pool = null)
        {
            var nvc = new NameValueCollection();
            nvc["export"] = exportName;
            nvc["format"] = format.ToString().ToLower();

            if (!String.IsNullOrEmpty(savedSearch))
            {
                nvc["ss"] = savedSearch;
            }

            if (since.HasValue)
            {
                var sinceVal = (long)((TimeSpan)(since.Value.ToUniversalTime() - new DateTime(1970, 1, 1, 0, 0, 0, 0))).TotalSeconds;
                nvc["since"] = sinceVal.ToString();
            }

            if (pool.HasValue)
            {
                nvc["pool"] = pool.Value.ToString().ToLower();
            }

            return client.GetExpectedJSONResult<RequestResult>("export/request", nvc);
        }