Ejemplo n.º 1
0
        protected RomitRequestOptions SetupRequestOptions(RomitRequestOptions requestOptions)
        {
            if (requestOptions == null) requestOptions = new RomitRequestOptions();

            if (!String.IsNullOrEmpty(ApiKey))
                requestOptions.ApiKey = ApiKey;

            return requestOptions;
        }
Ejemplo n.º 2
0
        protected RomitRequestOptions SetupRequestOptions(RomitRequestOptions requestOptions)
        {
            if (requestOptions == null)
            {
                requestOptions = new RomitRequestOptions();
            }

            if (!String.IsNullOrEmpty(ApiKey))
            {
                requestOptions.ApiKey = ApiKey;
            }

            return(requestOptions);
        }
Ejemplo n.º 3
0
        internal static WebRequest GetWebRequest(string url, string method, RomitRequestOptions requestOptions, bool useBearer = false)
        {
            requestOptions.ApiKey = requestOptions.ApiKey ?? RomitConfiguration.GetApiKey();

            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;

            var request = (HttpWebRequest)WebRequest.Create(url);
            request.Method = method;

            request.Headers.Add("Content-Type", "application/json");
            if (!useBearer)
                request.Headers.Add("Authorization", GetAuthorizationHeaderValue(requestOptions.ApiKey));
            else
                request.Headers.Add("Authorization", GetAuthorizationHeaderValueBearer(requestOptions.ApiKey));
            return request;
        }
Ejemplo n.º 4
0
        internal static WebRequest GetWebRequest(string url, string method, RomitRequestOptions requestOptions, bool useBearer = false)
        {
            requestOptions.ApiKey = requestOptions.ApiKey ?? RomitConfiguration.GetApiKey();

            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;

            var request = (HttpWebRequest)WebRequest.Create(url);

            request.Method = method;

            request.Headers.Add("Content-Type", "application/json");
            if (!useBearer)
            {
                request.Headers.Add("Authorization", GetAuthorizationHeaderValue(requestOptions.ApiKey));
            }
            else
            {
                request.Headers.Add("Authorization", GetAuthorizationHeaderValueBearer(requestOptions.ApiKey));
            }
            return(request);
        }
Ejemplo n.º 5
0
        public static string GetString(string url, RomitRequestOptions requestOptions)
        {
            var wr = GetWebRequest(url, "GET", requestOptions);

            return ExecuteWebRequest(wr);
        }
Ejemplo n.º 6
0
        public static string PostStringBearer(string url, RomitRequestOptions requestOptions)
        {
            var wr = GetWebRequest(url, "POST", requestOptions, true);

            return ExecuteWebRequest(wr);
        }
Ejemplo n.º 7
0
        public static string Delete(string url, RomitRequestOptions requestOptions)
        {
            var wr = GetWebRequest(url, "DELETE", requestOptions);

            return ExecuteWebRequest(wr);
        }
Ejemplo n.º 8
0
        public static string GetString(string url, RomitRequestOptions requestOptions)
        {
            var wr = GetWebRequest(url, "GET", requestOptions);

            return(ExecuteWebRequest(wr));
        }
Ejemplo n.º 9
0
        public static string PostStringBearer(string url, RomitRequestOptions requestOptions)
        {
            var wr = GetWebRequest(url, "POST", requestOptions, true);

            return(ExecuteWebRequest(wr));
        }
Ejemplo n.º 10
0
        public static string Delete(string url, RomitRequestOptions requestOptions)
        {
            var wr = GetWebRequest(url, "DELETE", requestOptions);

            return(ExecuteWebRequest(wr));
        }