public SearchImageResponse SearchImages(SearchForImages2RequestBody searchBody, string token)
        {
            var requestHeader = new RequestHeader();
            requestHeader.Token = token ?? string.Empty;

            var requestBody = new { RequestHeader = requestHeader, SearchForImages2RequestBody = searchBody };
            var postData = JsonConvert.SerializeObject(requestBody);

            var responseBody = PostData("http://connect.gettyimages.com/v1/search/SearchForImages", postData);
            return JsonConvert.DeserializeObject<SearchImageResponse>(responseBody);
        }
예제 #2
0
        public void ImageDetail_Test()
        {
            var session = operations.CreateSession();

            var searchQuery = new SearchForImages2RequestBody();
            searchQuery.Query = new Query();
            searchQuery.Query.SpecificPersons = new List<string> { "Jennifer Lopez" };
            searchQuery.ResultOptions = new ResultOptions();
            searchQuery.ResultOptions.ItemCount = 5;

            var searchResponse = operations.SearchImages(searchQuery, session.TokenResponse.Token);

            var imageIds = searchResponse.SearchForImagesResult.Images.Select(s => s.ImageId).ToList();

            var imageDetailRequest = new GetImageDetailsRequestBody();
            imageDetailRequest.ImageIds = imageIds;

            var imgDetailSrchResponse = operations.GetImageDetail(imageDetailRequest, session.TokenResponse.Token);

            Assert.IsTrue(imgDetailSrchResponse != null && imgDetailSrchResponse.ResponseHeader.Status.Equals("success"));
            Assert.IsTrue(imgDetailSrchResponse.GetImageDetailsResult.Images.Count == 5);
        }
예제 #3
0
        public void GetEvent_Test()
        {
            var session = operations.CreateSession();

            var searchQuery = new SearchForImages2RequestBody();
            searchQuery.Filter = new Filter();
            searchQuery.Query = new Query();
            searchQuery.Query.SpecificPersons = new List<string> { "Jennifer Lopez" };
            searchQuery.ResultOptions = new ResultOptions();
            searchQuery.ResultOptions.ItemCount = 75;

            var searchResponse = operations.SearchImages(searchQuery, session.TokenResponse.Token);
            var eventId = searchResponse.SearchForImagesResult.Images.Where(s => s.EventIds != null && s.EventIds.Count > 0).First().EventIds.First();

            var geteventRequest = new GetEventsRequestBody();
            geteventRequest.EventIds = new List<int>() { eventId };

            var eventResponse = operations.GetEventInfo(geteventRequest, session.TokenResponse.Token);

            Assert.IsTrue(eventResponse != null && eventResponse.ResponseHeader.Status.Equals("success"));
            Assert.IsTrue(eventResponse.GetEventsResult.Events.First().EventId == eventId);
            Assert.IsTrue(!string.IsNullOrEmpty(eventResponse.GetEventsResult.Events.First().EventName));
        }
예제 #4
0
        public void SearchImages_Test()
        {
            var session = operations.CreateSession();

            var searchQuery = new SearchForImages2RequestBody();
            searchQuery.Filter = new Filter();
            searchQuery.Filter.Orientations = new List<string> { "Vertical" };
            searchQuery.Query = new Query();
            searchQuery.Query.SpecificPersons = new List<string> { "Jennifer Lopez" };
            searchQuery.ResultOptions = new ResultOptions();
            searchQuery.ResultOptions.ItemCount = 75;

            var searchResponse = operations.SearchImages(searchQuery, session.TokenResponse.Token);

            Assert.IsTrue(searchResponse != null && searchResponse.ResponseHeader.Status.Equals("success"));
            Assert.IsTrue(searchResponse.SearchForImagesResult.Images.Count == 75);
        }