Exemplo n.º 1
0
        public ContentfulService(IHostingEnvironment hostingEnvironment, ICacheService cacheService, IOptions <ContentfulConfig> contentfulConfig, IBaseClient baseClient)
        {
            _hostingEnvironment = hostingEnvironment;
            _cacheService       = cacheService;
            _contentfulConfig   = contentfulConfig.Value;

            _imageDBPath = _hostingEnvironment.WebRootPath + "/data/header-images.json";

            // Build Contentful client
            var options = new ContentfulOptions()
            {
                UsePreviewApi  = false,
                DeliveryApiKey = _contentfulConfig.DeliveryApiKey,
                SpaceId        = _contentfulConfig.SpaceId
            };

            _client = new ContentfulClient(baseClient.GetHttpClient(), options);

            // Build Contentful preview client
            var previewOptions = new ContentfulOptions()
            {
                UsePreviewApi = true,
                PreviewApiKey = _contentfulConfig.PreviewApiKey,
                SpaceId       = _contentfulConfig.SpaceId
            };

            _previewClient = new ContentfulClient(baseClient.GetHttpClient(), previewOptions);
        }
Exemplo n.º 2
0
        // Trading API
        public async Task <List <Item> > GetUserListings(string userID)
        {
            return(await _cacheService.GetAsync("GetEbayUserListings", async() =>
            {
                var client = _baseClient.GetHttpClient();
                var request = BuildGetUserListingsRequest(userID);
                var task = await client.SendAsync(request);
                var responseContent = await task.Content.ReadAsStringAsync();

                var results = DeserializeResult(responseContent);

                return await ProcessResults(results);
            }, 1440).Unwrap());
        }
Exemplo n.º 3
0
 protected APIClient(IBaseClient baseClient)
 {
     _client = baseClient.GetHttpClient();
 }