Beispiel #1
0
        public HttpWebRequest CreateDistimoRequest(SupportedDistimoApis supportedApi, string queryString)
        {
            var apiAddress = GetDistimoAPIAddress(supportedApi);

            // Format QueryString
            if (queryString != String.Empty)
                queryString = queryString + "&" + QueryFormat;
            else
                queryString = queryString + QueryFormat;

            var authToken = CreateAuthToken(queryString);

            string url = apiAddress + "?" + queryString + "&apikey=" + DistimoAuthService.DistimoPublicKey + "&hash=" + authToken.AuthHash + "&t=" + authToken.Time;
            var request = HttpWebRequest.Create(url) as HttpWebRequest;
            request.Headers["Authorization"] = String.Concat("Basic ", authToken.Base64Login);

            return request;
        }
Beispiel #2
0
        public string GetDistimoAPIAddress(SupportedDistimoApis supportedApi)
        {
            var apiAddress = DistimoAPIBaseAddress;

            switch (supportedApi)
            {
                case SupportedDistimoApis.Revenues:
                    apiAddress = apiAddress + "revenues";
                    break;
                case SupportedDistimoApis.FilterAssetRevenues:
                    apiAddress = apiAddress + "filters/assets/revenues";
                    break;
                case SupportedDistimoApis.Assets:
                    apiAddress = apiAddress + "assets/app";
                    break;
                default:
                    throw new ArgumentOutOfRangeException("Unexpected API value");

            }

            return apiAddress;
        }
Beispiel #3
0
        public string GetDistimoData(SupportedDistimoApis supportedApi, string queryString)
        {
            var request = CreateDistimoRequest(supportedApi, queryString);

            // Execute request
            var requestData = WebRequestService.GetWebRequest(request);

            return requestData;
        }