public MetaModel(IAPIConnector connector, bool hookup)
		{
			_connector = connector;

			if ( hookup )
				Hookup();
		}
 public V1Configuration(IAPIConnector connector)
 {
     if (connector == null)
         throw new ArgumentNullException("connector");
     
     _connector = connector;
 }
Ejemplo n.º 3
0
        public async IAsyncEnumerable <T> Paginate <T>(
            IPaginatable <T> firstPage,
            IAPIConnector connector,
            [EnumeratorCancellation] CancellationToken cancel = default)
        {
            Ensure.ArgumentNotNull(firstPage, nameof(firstPage));
            Ensure.ArgumentNotNull(connector, nameof(connector));

            var page = firstPage;

            foreach (var item in page.Items)
            {
                yield return(item);
            }
            while (page.Next != null)
            {
                page = await connector.Get <Paging <T> >(new Uri(page.Next, UriKind.Absolute)).ConfigureAwait(false);

                foreach (var item in page.Items)
                {
                    yield return(item);
                }
            }
        }
Ejemplo n.º 4
0
        public SpotifyClient(SpotifyClientConfig config)
        {
            Ensure.ArgumentNotNull(config, nameof(config));
            if (config.Authenticator == null)
            {
                throw new NullReferenceException("Authenticator in config is null. Please supply it via `WithAuthenticator` or `WithToken`");
            }

            _apiConnector = new APIConnector(
                config.BaseAddress,
                config.Authenticator,
                config.JSONSerializer,
                config.HTTPClient,
                config.RetryHandler,
                config.HTTPLogger
                );
            _apiConnector.ResponseReceived += (sender, response) =>
            {
                LastResponse = response;
            };

            DefaultPaginator = config.DefaultPaginator;
            UserProfile      = new UserProfileClient(_apiConnector);
            Browse           = new BrowseClient(_apiConnector);
            Shows            = new ShowsClient(_apiConnector);
            Playlists        = new PlaylistsClient(_apiConnector);
            Search           = new SearchClient(_apiConnector);
            Follow           = new FollowClient(_apiConnector);
            Tracks           = new TracksClient(_apiConnector);
            Player           = new PlayerClient(_apiConnector);
            Albums           = new AlbumsClient(_apiConnector);
            Artists          = new ArtistsClient(_apiConnector);
            Personalization  = new PersonalizationClient(_apiConnector);
            Episodes         = new EpisodesClient(_apiConnector);
            Library          = new LibraryClient(_apiConnector);
        }
Ejemplo n.º 5
0
        public async Task <IList <T> > PaginateAll <T>(IPaginatable <T> firstPage, IAPIConnector connector)
        {
            Ensure.ArgumentNotNull(firstPage, nameof(firstPage));
            Ensure.ArgumentNotNull(connector, nameof(connector));

            var page    = firstPage;
            var results = new List <T>();

            if (page.Items != null)
            {
                results.AddRange(page.Items);
            }
            while (page.Next != null && await ShouldContinue(results, page).ConfigureAwait(false))
            {
                page = await connector.Get <Paging <T> >(new Uri(page.Next, UriKind.Absolute)).ConfigureAwait(false);

                if (page.Items != null)
                {
                    results.AddRange(page.Items);
                }
            }

            return(results);
        }
Ejemplo n.º 6
0
 public PlayerClient(IAPIConnector apiConnector) : base(apiConnector)
 {
 }
Ejemplo n.º 7
0
        public static Task <PKCETokenResponse> RequestToken(PKCETokenRefreshRequest request, IAPIConnector apiConnector)
        {
            Ensure.ArgumentNotNull(request, nameof(request));
            Ensure.ArgumentNotNull(apiConnector, nameof(apiConnector));

            var form = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("client_id", request.ClientId),
                new KeyValuePair <string, string>("grant_type", "refresh_token"),
                new KeyValuePair <string, string>("refresh_token", request.RefreshToken),
            };

            return(SendOAuthRequest <PKCETokenResponse>(apiConnector, form, null, null));
        }
Ejemplo n.º 8
0
 public FollowClient(IAPIConnector apiConnector) : base(apiConnector)
 {
 }
Ejemplo n.º 9
0
 public TracksClient(IAPIConnector apiConnector) : base(apiConnector)
 {
 }
 public PersonalizationClient(IAPIConnector apiConnector) : base(apiConnector)
 {
 }
Ejemplo n.º 11
0
 public LibraryClient(IAPIConnector apiConnector) : base(apiConnector)
 {
 }
 public Attachments(IAPIConnector connector)
 {
     _connector = connector;
 }
 private IAPIConnector PopulateHeaders(IAPIConnector connector)
 {
     IDictionary<string, string> dict = connector.CustomHttpHeaders;
     foreach (KeyValuePair<string, string> pair in _customHttpHeaders)
     {
         dict.Add(pair.Key, pair.Value);
     }
     return connector;
 }
Ejemplo n.º 14
0
 public EpisodesClient(IAPIConnector apiConnector) : base(apiConnector)
 {
 }
Ejemplo n.º 15
0
 public V1Configuration(IAPIConnector connector)
 {
     this.connector = connector;
 }
Ejemplo n.º 16
0
 public AlbumsClient(IAPIConnector apiConnector) : base(apiConnector)
 {
 }
 public Services(IMetaModel metaModel, IAPIConnector connector) {
     this.metaModel = metaModel;
     this.connector = connector;
 }
 public UserProfileClient(IAPIConnector apiConnector) : base(apiConnector)
 {
 }
Ejemplo n.º 19
0
        public async Task <IList <T> > PaginateAll <T, TNext>(
            IPaginatable <T, TNext> firstPage, Func <TNext, IPaginatable <T, TNext> > mapper, IAPIConnector connector
            )
        {
            Ensure.ArgumentNotNull(firstPage, nameof(firstPage));
            Ensure.ArgumentNotNull(mapper, nameof(mapper));
            Ensure.ArgumentNotNull(connector, nameof(connector));

            var page    = firstPage;
            var results = new List <T>();

            results.AddRange(firstPage.Items);
            while (page.Next != null && await ShouldContinue(results, page).ConfigureAwait(false))
            {
                var next = await connector.Get <TNext>(new Uri(page.Next, UriKind.Absolute)).ConfigureAwait(false);

                page = mapper(next);
                results.AddRange(page.Items);
            }

            return(results);
        }
Ejemplo n.º 20
0
 public ArtistsClient(IAPIConnector apiConnector) : base(apiConnector)
 {
 }
		public Localizer(IAPIConnector connector)
		{
			_connector = connector;
		}
 public Attachments(IAPIConnector connector)
 {
     this.connector = connector;
 }
 public Attachments(IAPIConnector connector)
 {
     _connector = connector;
 }
 public Localizer(IAPIConnector connector)
 {
     _connector = connector;
 }
Ejemplo n.º 25
0
 public PlaylistsClient(IAPIConnector connector) : base(connector)
 {
 }
 public V1Configuration(IAPIConnector connector) {
     this.connector = connector;
 }
 public Services(IMetaModel metaModel, IAPIConnector connector)
 {
     this.metaModel = metaModel;
     this.connector = connector;
 }
Ejemplo n.º 28
0
 public MetaModel(IAPIConnector connector) : this(connector, false)
 {
 }
Ejemplo n.º 29
0
 public ShowsClient(IAPIConnector connector) : base(connector)
 {
 }
		public MetaModel(IAPIConnector connector) : this(connector, false)
		{
		}
Ejemplo n.º 31
0
        public APIClient(IAPIConnector apiConnector)
        {
            Ensure.ArgumentNotNull(apiConnector, nameof(apiConnector));

            API = apiConnector;
        }
Ejemplo n.º 32
0
 public BrowseClient(IAPIConnector apiConnector) : base(apiConnector)
 {
 }
 public Attachments(IAPIConnector connector) {
     this.connector = connector;
 }
Ejemplo n.º 34
0
        public static Task <PKCETokenResponse> RequestToken(PKCETokenRequest request, IAPIConnector apiConnector)
        {
            Ensure.ArgumentNotNull(request, nameof(request));
            Ensure.ArgumentNotNull(apiConnector, nameof(apiConnector));

            var form = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("client_id", request.ClientId),
                new KeyValuePair <string, string>("grant_type", "authorization_code"),
                new KeyValuePair <string, string>("code", request.Code),
                new KeyValuePair <string, string>("redirect_uri", request.RedirectUri.ToString()),
                new KeyValuePair <string, string>("code_verifier", request.CodeVerifier),
            };

            return(SendOAuthRequest <PKCETokenResponse>(apiConnector, form, null, null));
        }
Ejemplo n.º 35
0
 public SearchClient(IAPIConnector apiConnector) : base(apiConnector)
 {
 }
Ejemplo n.º 36
0
 public OAuthClient(IAPIConnector apiConnector) : base(apiConnector)
 {
 }
Ejemplo n.º 37
0
        public async Task <IList <T> > PaginateAll <T, TNext>(
            IPaginatable <T, TNext> firstPage, Func <TNext, IPaginatable <T, TNext> > mapper, IAPIConnector connector
            )
        {
            var page    = firstPage;
            var results = new List <T>();

            results.AddRange(firstPage.Items);

            while (page.Next != null && await this.ShouldContinue(results, page).ConfigureAwait(false))
            {
                var next = await connector.Get <TNext>(new Uri(page.Next, UriKind.Absolute)).ConfigureAwait(false);

                page = mapper(next);
                results.AddRange(page.Items);
                Thread.Sleep(this.delay);
            }

            return(results);
        }