Esempio n. 1
0
        public async Task <Playlist> GetPlaylistAsync(string part, string playlistId)
        {
            var client     = CreateHttpClient();
            var parameters = new Dictionary <string, string>();

            parameters.Add("part", part);
            parameters.Add("id", playlistId);
            var uri      = GoogleClient.BuildUri(ApiServiceUri + "playlists", parameters: parameters);
            var response = await client.GetAsync(uri);

            if (response.IsSuccessStatusCode)
            {
                return((await response.Content.ReadJsonAsync <GoogleList <Playlist> >()).Items.FirstOrDefault());
            }
            else
            {
                throw await ProcessException(response.Content);
            }
        }
Esempio n. 2
0
        public async Task <GoogleList <PlaylistItem> > GetPlaylistItemsAsync(string playlistId, string part, string fields = null, string pageToken = null, int?maxResults = null, string orderby = null)
        {
            var client     = CreateHttpClient();
            var parameters = new Dictionary <string, string>
            {
                { "part", part },
                { "playlistId", playlistId },
            };
            var uri      = GoogleClient.BuildUri(ApiServiceUri + "playlistItems", fields: fields, pageToken: pageToken, maxResults: maxResults, orderby: orderby, parameters: parameters);
            var response = await client.GetAsync(uri);

            if (response.IsSuccessStatusCode)
            {
                return(await response.Content.ReadJsonAsync <GoogleList <PlaylistItem> >());
            }
            else
            {
                throw await ProcessException(response.Content);
            }
        }
Esempio n. 3
0
        public async Task <GoogleList <Subscription> > GetSubscriptionsAsync(string part, bool mine, string fields = null, string pageToken = null, int?maxResults = null, string orderby = null)
        {
            var client     = CreateHttpClient();
            var parameters = new Dictionary <string, string>();

            parameters.Add("part", part);
            if (mine)
            {
                parameters.Add("mine", "true");
            }
            var uri      = GoogleClient.BuildUri(ApiServiceUri + "subscriptions", fields: fields, pageToken: pageToken, maxResults: maxResults, orderby: orderby, parameters: parameters);
            var response = await client.GetAsync(uri);

            if (response.IsSuccessStatusCode)
            {
                return(await response.Content.ReadJsonAsync <GoogleList <Subscription> >());
            }
            else
            {
                throw await ProcessException(response.Content);
            }
        }