Ejemplo n.º 1
0
        public async Task <string> DownloadAndExtractAsync()
        {
            var req = RequestEngine.CreateClient(_AccessConfig);

            var gzipFilePath = await RequestEngine.DownloadFileAsync(req, XmlFileUrl, _AccessConfig.DownloadDirectory);

            var unzipFilePath = await GZipUtils.DecompressAsync(new FileInfo(gzipFilePath));

            return(unzipFilePath);
        }
Ejemplo n.º 2
0
        public async Task <IceCatProduct> GetAsync(long productId)
        {
            var req = RequestEngine.CreateClient(_AccessConfig);

            var productXmlUrl = BuildXmlFileUrl($"{productId}.xml");

            var productXml = await RequestEngine.GetAsStringAsync(req, productXmlUrl);

            return(CustomXmlParser.Parse <IceCatProduct>(productXml, "Product"));
        }
Ejemplo n.º 3
0
        protected virtual TEntity MakeRequest <TEntity>(string path, Method method, string rootElement = null, object payload = null, List <Parameter> parameters = null)
        {
            var request = CreateRestRequest(path, method, rootElement, payload, parameters);

            var client = RequestEngine.CreateClient(_AccessInfo);

            var response = RequestEngine.ExecuteRequest <TEntity>(client, request);

            return(response);
        }
Ejemplo n.º 4
0
        public async Task <string> DownloadAsync(string xmlUrlPath, string saveFilePath = null)
        {
            var req = RequestEngine.CreateClient(_AccessConfig);

            if (string.IsNullOrEmpty(saveFilePath))
            {
                saveFilePath = _AccessConfig.DownloadDirectory + xmlUrlPath.Split('/').Last();
            }

            return(await RequestEngine.DownloadFileAsync(req, xmlUrlPath, saveFilePath));
        }
Ejemplo n.º 5
0
        public async Task <string> GetAsync(string xmlUrlPath, string nodeName = null)
        {
            var req = RequestEngine.CreateClient(_AccessConfig);

            var xmlBody = await RequestEngine.GetAsStringAsync(req, xmlUrlPath);

            if (string.IsNullOrEmpty(nodeName))
            {
                return(xmlBody);
            }

            return(await CustomXmlParser.ParseAsync(nodeName, xmlBody));
        }
Ejemplo n.º 6
0
        public async Task <string> DownloadAndExtractAsync(string xmlUrlPath, string saveFilePath = null)
        {
            var req = RequestEngine.CreateClient(_AccessConfig);

            var saveDirectoryPath = _AccessConfig.DownloadDirectory;

            if (!string.IsNullOrEmpty(saveFilePath))
            {
                saveDirectoryPath = Path.GetDirectoryName(saveFilePath);
            }

            var gzipFilePath = await RequestEngine.DownloadFileToDirectoryAsync(req, xmlUrlPath, saveDirectoryPath);

            var unzipFilePath = await GZipUtils.DecompressAsync(new FileInfo(gzipFilePath), saveFilePath);

            return(unzipFilePath);
        }
Ejemplo n.º 7
0
 protected BaseService(IceCatAccessConfig config)
 {
     _AccessConfig = config;
     _Client       = RequestEngine.CreateClient(config);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Creates a new instance of <see cref="ConvertKitService" />.
 /// </summary>
 /// <param name="apiKey">The API or secret key for the ConvertKit account.</param>
 protected ConvertKitService(string apiKey)
 {
     _RestClient = RequestEngine.CreateClient(apiKey);
 }