예제 #1
0
        private async void OnLoaded(object sender, RoutedEventArgs e)
        {
            await LoadEventOfTheDay();

            var request = new EventListRequest();

            request.Lang   = "ru";
            request.Expand = string.Format("{0},{1}", EventListRequest.ExpandNames.IMAGES, EventListRequest.ExpandNames.PLACE);

            var fieldBuilder = new FieldsBuilder();

            request.Fields = fieldBuilder
                             .WithField(EventListRequest.FieldNames.BODY_TEXT)
                             .WithField(EventListRequest.FieldNames.COMMENTS_COUNT)
                             .WithField(EventListRequest.FieldNames.DESCRIPTION)
                             .WithField(EventListRequest.FieldNames.ID)
                             .WithField(EventListRequest.FieldNames.IMAGES)
                             .WithField(EventListRequest.FieldNames.PLACE)
                             .WithField(EventListRequest.FieldNames.PUBLICATION_DATE)
                             .WithField(EventListRequest.FieldNames.PRICE)
                             .WithField(EventListRequest.FieldNames.TITLE)
                             .WithField(EventListRequest.FieldNames.SITE_URL)
                             .WithField(EventListRequest.FieldNames.SLUG).Build();
            request.ActualSince = DateTime.Today;
            request.Location    = Location.Spb;

            var res = await request.ExecuteAsync();

            foreach (var result in res.Results)
            {
                Items.Add(new EventViewModel(result.Images.First().Thumbnail.Small, result.Title, result.Place));
            }
        }
        public async Task should_get_newslist()
        {
            var fieldsBuilder = new FieldsBuilder();
            var request       = new NewsListRequest();

            request.Lang   = "ru";
            request.Expand = NewsListRequest.ExpandNames.IMAGES + "," + NewsListRequest.ExpandNames.PLACE;
            request.Fields = fieldsBuilder.WithField(NewsListRequest.FieldNames.TITLE)
                             .WithField(NewsListRequest.FieldNames.IMAGES)
                             .WithField(NewsListRequest.FieldNames.ID)
                             .WithField(NewsListRequest.FieldNames.SLUG)
                             .WithField(NewsListRequest.FieldNames.PUBLICATION_DATE)
                             .WithField(NewsListRequest.FieldNames.PLACE)
                             .Build();

            var res = await request.ExecuteAsync();

            Assert.IsNotNull(res);
            Assert.IsTrue(res.Count > 0);
            Assert.IsNotNull(res.Next);
            Assert.IsTrue(res.Results.Any());

            var first = res.Results.First();

            Assert.IsNotNull(first.Id);
            Assert.IsNotNull(first.Place);
            Assert.IsNotNull(first.Images);
        }
        public async Task should_get_place_comments()
        {
            var request = new PlaceListRequest();

            request.Lang = "ru";

            var res = await request.ExecuteAsync();

            Assert.IsNotNull(res);
            Assert.IsTrue(res.Count > 0);

            var first           = res.Results.First();
            var commentsRequest = new PlaceCommentsRequest();

            commentsRequest.PlaceId = first.Id;
            var fieldBuilder = new FieldsBuilder();

            commentsRequest.Fields = fieldBuilder.WithField(CommentFields.USER)
                                     .WithField(CommentFields.ID)
                                     .WithField(CommentFields.IS_DELETED)
                                     .WithField(CommentFields.DATE_POSTED)
                                     .WithField(CommentFields.REPLIES_COUNT)
                                     .WithField(CommentFields.REPLY_TO)
                                     .WithField(CommentFields.TEXT)
                                     .WithField(CommentFields.THREAD)
                                     .Build();

            var commentsResponse = await commentsRequest.ExecuteAsync();

            Assert.IsNotNull(commentsResponse);
        }
        public async Task should_get_event_details()
        {
            var request = new EventListRequest();

            request.Lang = "ru";

            var fieldBuilder = new FieldsBuilder();

            request.Fields      = fieldBuilder.WithField(EventListRequest.FieldNames.ID).Build();
            request.ActualSince = DateTime.Today;
            request.Location    = Location.Spb;

            //then
            var res = await request.ExecuteAsync();

            var first = res.Results.First();

            var detailsRequest = new EventDetailsRequest();

            detailsRequest.EventId = first.Id;
            var actual = await detailsRequest.ExecuteAsync();

            Assert.IsNotNull(actual);
            Assert.AreEqual(actual.Id, first.Id);
        }
예제 #5
0
        public async Task <IMovieListResponse> GetMovies(string next)
        {
            var request = new MovieListRequest();

            request.Lang       = _culture;
            request.TextFormat = TextFormatEnum.Plain;
            request.Next       = next;
            request.Expand     = MovieListRequest.ExpandNames.POSTER;

            var fieldBuilder = new FieldsBuilder();

            request.Fields = fieldBuilder
                             .WithField(MovieListRequest.FieldNames.ID)
                             .WithField(MovieListRequest.FieldNames.POSTER)
                             .WithField(MovieListRequest.FieldNames.IMAGES)
                             .WithField(MovieListRequest.FieldNames.AGE_RESTRICTION)
                             .WithField(MovieListRequest.FieldNames.YEAR)
                             .WithField(MovieListRequest.FieldNames.COUNTRY)
                             .WithField(MovieListRequest.FieldNames.RUNNING_TIME)
                             .WithField(MovieListRequest.FieldNames.TITLE).Build();
            request.Location = _location;

            var res = await request.ExecuteAsync();

            return(res);
        }
예제 #6
0
        public async Task should_get_something()
        {
            var request = new MovieListRequest();

            request.Lang = "ru";
            var fieldBuilder = new FieldsBuilder();

            request.Fields = fieldBuilder
                             .WithField(MovieListRequest.FieldNames.ID)
                             .WithField(MovieListRequest.FieldNames.SITE_URL)
                             .WithField(MovieListRequest.FieldNames.PUBLICATION_DATE)
                             .WithField(MovieListRequest.FieldNames.SLUG)
                             .WithField(MovieListRequest.FieldNames.TITLE)
                             .WithField(MovieListRequest.FieldNames.DESCRIPTION)
                             .WithField(MovieListRequest.FieldNames.BODY_TEXT)
                             .WithField(MovieListRequest.FieldNames.IS_EDITORS_CHOICE)
                             .WithField(MovieListRequest.FieldNames.FAVORITES_COUNT)
                             .WithField(MovieListRequest.FieldNames.GENRES)
                             .WithField(MovieListRequest.FieldNames.COMMENTS_COUNT)
                             .WithField(MovieListRequest.FieldNames.ORIGINAL_TITLE)
                             .WithField(MovieListRequest.FieldNames.LOCALE)
                             .WithField(MovieListRequest.FieldNames.COUNTRY)
                             .WithField(MovieListRequest.FieldNames.YEAR)
                             .WithField(MovieListRequest.FieldNames.LANGUAGE)
                             .WithField(MovieListRequest.FieldNames.RUNNING_TIME)
                             .WithField(MovieListRequest.FieldNames.BUDGET_CURRENCY)
                             //.WithField(MovieListRequest.FieldNames.BUDGET) Пока не работает ((
                             .WithField(MovieListRequest.FieldNames.MPAA_RATING)
                             .WithField(MovieListRequest.FieldNames.AGE_RESTRICTION)
                             .WithField(MovieListRequest.FieldNames.STARS)
                             .WithField(MovieListRequest.FieldNames.DIRECTOR)
                             .WithField(MovieListRequest.FieldNames.WRITER)
                             .WithField(MovieListRequest.FieldNames.AWARDS)
                             .WithField(MovieListRequest.FieldNames.TRAILER)
                             .WithField(MovieListRequest.FieldNames.IMAGES)
                             .WithField(MovieListRequest.FieldNames.POSTER)
                             .WithField(MovieListRequest.FieldNames.URL)
                             .WithField(MovieListRequest.FieldNames.IMDB_URL)
                             .WithField(MovieListRequest.FieldNames.IMDB_RATING).Build();

            request.Expand = MovieListRequest.ExpandNames.IMAGES + "," + MovieListRequest.ExpandNames.POSTER;

            var res = await request.ExecuteAsync();

            Assert.IsNotNull(res);
            Assert.IsTrue(res.Count > 0);
            Assert.IsNotNull(res.Next);
            Assert.IsTrue(res.Results.Any());
        }
        public async Task should_get_events_with_fields_2()
        {
            var request = new EventListRequest();

            request.Lang   = "ru";
            request.Expand = string.Format("{0},{1},{2},{3},{4}",
                                           EventListRequest.ExpandNames.IMAGES,
                                           EventListRequest.ExpandNames.PLACE,
                                           EventListRequest.ExpandNames.LOCATION,
                                           EventListRequest.ExpandNames.DATES,
                                           EventListRequest.ExpandNames.PARTICIPANTS);

            var fieldBuilder = new FieldsBuilder();

            request.Fields = fieldBuilder
                             .WithField(EventListRequest.FieldNames.BODY_TEXT)
                             .WithField(EventListRequest.FieldNames.COMMENTS_COUNT)
                             .WithField(EventListRequest.FieldNames.CATEGORIES)
                             .WithField(EventListRequest.FieldNames.DESCRIPTION)
                             .WithField(EventListRequest.FieldNames.DATES)
                             .WithField(EventListRequest.FieldNames.FAVORITES_COUNT)
                             .WithField(EventListRequest.FieldNames.AGE_RESTRICTION)
                             .WithField(EventListRequest.FieldNames.ID)
                             .WithField(EventListRequest.FieldNames.IMAGES)
                             .WithField(EventListRequest.FieldNames.IS_FREE)
                             .WithField(EventListRequest.FieldNames.BODY_TEXT)
                             .WithField(EventListRequest.FieldNames.LOCATION)
                             .WithField(EventListRequest.FieldNames.PARTICIPANTS)
                             .WithField(EventListRequest.FieldNames.PLACE)
                             .WithField(EventListRequest.FieldNames.PUBLICATION_DATE)
                             .WithField(EventListRequest.FieldNames.PRICE)
                             .WithField(EventListRequest.FieldNames.SHORT_TITLE)
                             .WithField(EventListRequest.FieldNames.SITE_URL)
                             .WithField(EventListRequest.FieldNames.SLUG).Build();
            request.ActualSince = DateTime.Today;
            request.Location    = Location.Spb;

            var res = await request.ExecuteAsync();

            Assert.IsNotNull(res);
            Assert.IsTrue(res.Count > 0);
            Assert.IsNotNull(res.Next);
            Assert.IsTrue(res.Results.Any());

            var first = res.Results.First();

            Assert.IsNotNull(first.BodyText);
            Assert.IsNotNull(first.CommentsCount);
        }
예제 #8
0
        public async Task <IEventsOfTheDayResponse> GetEventOfTheDay(string next)
        {
            var request = new EventsOfTheDayRequest();

            request.Lang       = _culture;
            request.TextFormat = TextFormatEnum.Plain;
            request.Next       = next;

            var fieldBuilder = new FieldsBuilder();

            request.Fields = fieldBuilder
                             .WithField(EventsOfTheDayRequest.FieldsNames.DATE)
                             .WithField(EventsOfTheDayRequest.FieldsNames.EVENT)
                             .WithField(EventsOfTheDayRequest.FieldsNames.LOCATION)
                             .Build();
            request.Location = _location;

            var res = await request.ExecuteAsync();

            return(res);
        }
예제 #9
0
        public async Task <ISelectionListResponse> GetSelections(string next)
        {
            var request = new SelectionListRequest();

            request.Lang       = _culture;
            request.TextFormat = TextFormatEnum.Plain;
            request.Next       = next;
            request.Expand     = SelectionListRequest.ExpandNames.IMAGES;

            var fieldBuilder = new FieldsBuilder();

            request.Fields = fieldBuilder
                             .WithField(SelectionListRequest.FieldNames.ID)
                             .WithField(SelectionListRequest.FieldNames.PUBLICATION_DATE)
                             .WithField(SelectionListRequest.FieldNames.TITLE).Build();
            request.Location = _location;

            var res = await request.ExecuteAsync();

            return(res);
        }
예제 #10
0
        public async Task <IEventListResponse> GetEvents(string next, FilterDefinition filterDefinition)
        {
            if (filterDefinition == null)
            {
                throw new ArgumentNullException(nameof(filterDefinition));
            }

            var request = new EventListRequest();

            request.Lang        = _culture;
            request.TextFormat  = TextFormatEnum.Plain;
            request.Next        = next;
            request.IsFree      = filterDefinition.IsFree;
            request.Categories  = filterDefinition.Categories;
            request.ActualSince = filterDefinition.ActualSince;
            request.ActualUntil = filterDefinition.ActualUntil;
            request.Expand      = string.Format("{0},{1}", EventListRequest.ExpandNames.IMAGES, EventListRequest.ExpandNames.PLACE);

            var fieldBuilder = new FieldsBuilder();

            request.Fields = fieldBuilder
                             .WithField(EventListRequest.FieldNames.DESCRIPTION)
                             .WithField(EventListRequest.FieldNames.ID)
                             .WithField(EventListRequest.FieldNames.IMAGES)
                             .WithField(EventListRequest.FieldNames.PLACE)
                             .WithField(EventListRequest.FieldNames.IS_FREE)
                             .WithField(EventListRequest.FieldNames.PRICE)
                             .WithField(EventListRequest.FieldNames.TITLE)
                             .WithField(EventListRequest.FieldNames.DATES)
                             .WithField(EventListRequest.FieldNames.CATEGORIES)
                             .WithField(EventListRequest.FieldNames.AGE_RESTRICTION).Build();
            request.ActualSince = DateTime.Today;
            request.Location    = _location;

            var res = await request.ExecuteAsync();

            return(res);
        }
예제 #11
0
        public async Task should_get_movie_details()
        {
            var request = new MovieListRequest();

            request.Lang = "ru";

            var fieldBuilder = new FieldsBuilder();

            request.Fields   = fieldBuilder.WithField(MovieListRequest.FieldNames.ID).Build();
            request.Location = Location.Spb;

            //then
            var res = await request.ExecuteAsync();

            var first = res.Results.First();

            var detailsRequest = new MovieDetailsRequest();

            detailsRequest.MovieId = first.Id;
            var actual = await detailsRequest.ExecuteAsync();

            Assert.IsNotNull(actual);
            Assert.AreEqual(actual.Id, first.Id);
        }
예제 #12
0
        public async Task <INewsListResponse> GetNews(string next)
        {
            var request = new NewsListRequest();

            request.Lang       = _culture;
            request.TextFormat = TextFormatEnum.Plain;
            request.Next       = next;
            request.Expand     = string.Format("{0},{1}", NewsListRequest.ExpandNames.IMAGES, EventListRequest.ExpandNames.PLACE);

            var fieldBuilder = new FieldsBuilder();

            request.Fields = fieldBuilder
                             .WithField(NewsListRequest.FieldNames.DESCRIPTION)
                             .WithField(NewsListRequest.FieldNames.ID)
                             .WithField(NewsListRequest.FieldNames.IMAGES)
                             .WithField(NewsListRequest.FieldNames.PLACE)
                             .WithField(NewsListRequest.FieldNames.PUBLICATION_DATE)
                             .WithField(NewsListRequest.FieldNames.TITLE).Build();
            request.Location = _location;

            var res = await request.ExecuteAsync();

            return(res);
        }