Ejemplo n.º 1
0
        /// <summary>
        /// Builds list of subresrources to pass onto Api
        /// </summary>
        /// <param name="resources">subresources for api</param>
        /// <returns></returns>
        public static EndpointSubResourcesCollection BuildResourceList(params EndpointSubResources[] resources)
        {
            var collection = new EndpointSubResourcesCollection
            {
                Resources = resources.ToList()
            };

            return(collection);
        }
Ejemplo n.º 2
0
        private static string BuildSubResourcesList(EndpointSubResourcesCollection subresources)
        {
            string subs = "";

            if (subresources != null && subresources.Resources.Count > 0)
            {
                subs = $";out={ string.Join(",", subresources.Resources.Select(a => a.ToFriendlyString()))}";
            }
            return(subs);
        }
Ejemplo n.º 3
0
 internal static EndPoint TransactionsLeagueEndPoint(
     string leagueKey,
     EndpointSubResourcesCollection subresources = null
     )
 {
     return(new EndPoint
     {
         BaseUri = BaseApiUrl,
         Resource = $"/league/{leagueKey}/transactions{BuildSubResourcesList(subresources)}"
     });
 }
Ejemplo n.º 4
0
        internal static EndPoint GamesUserEndPoint(string[] gameKeys = null, EndpointSubResourcesCollection subresources = null, GameCollectionFilters filters = null)
        {
            string games = "";

            if (gameKeys != null && gameKeys.Length > 0)
            {
                games = $";game_keys={ string.Join(",", gameKeys)}";
            }

            return(new EndPoint
            {
                BaseUri = BaseApiUrl,
                Resource = $"/users{LoginString}/games{games}{BuildGameFiltersList(filters)}{BuildSubResourcesList(subresources)}"
            });
        }
Ejemplo n.º 5
0
        internal static EndPoint TransactionsEndPoint(string[] transactionKeys, EndpointSubResourcesCollection subresources = null)
        {
            string transactions = "";

            if (transactionKeys.Length > 0)
            {
                transactions = $";transaction_keys={ string.Join(",", transactionKeys)}";
            }

            return(new EndPoint
            {
                BaseUri = BaseApiUrl,
                Resource = $"/transactions{transactions}{BuildSubResourcesList(subresources)}"
            });
        }
Ejemplo n.º 6
0
        internal static EndPoint TransactionsLeagueEndPoint(string[] leagueKeys, EndpointSubResourcesCollection subresources = null)
        {
            string leagues = "";

            if (leagueKeys.Length > 0)
            {
                leagues = $";league_keys={ string.Join(",", leagueKeys)}";
            }

            return(new EndPoint
            {
                BaseUri = BaseApiUrl,
                Resource = $"/leagues{leagues}{BuildSubResourcesList(subresources)}"
            });
        }
Ejemplo n.º 7
0
        internal static EndPoint TeamsUserGamesEndPoint(string[] gameKeys, EndpointSubResourcesCollection subresources = null)
        {
            string games = "";

            if (gameKeys.Length > 0)
            {
                games = $";gameKeys={ string.Join(",", gameKeys)}";
            }

            return(new EndPoint
            {
                BaseUri = BaseApiUrl,
                Resource = $"/users{LoginString}/games{games}{BuildSubResourcesList(subresources)}"
            });
        }
Ejemplo n.º 8
0
        internal static EndPoint PlayersTeamEndPoint(string[] teamKeys, EndpointSubResourcesCollection subresources = null, PlayerCollectionFilters filters = null)
        {
            string teams = "";

            if (teamKeys.Length > 0)
            {
                teams = $";team_keys={ string.Join(",", teamKeys)}";
            }

            return(new EndPoint
            {
                BaseUri = BaseApiUrl,
                Resource = $"/teams{teams}/players{BuildSubResourcesList(subresources)}{BuildPlayersFiltersList(filters)}"
            });
        }
Ejemplo n.º 9
0
        internal static EndPoint PlayersEndPoint(string[] playerKeys, EndpointSubResourcesCollection subresources = null)
        {
            string players = "";

            if (playerKeys.Length > 0)
            {
                players = $";player_keys={ string.Join(",", playerKeys)}";
            }

            return(new EndPoint
            {
                BaseUri = BaseApiUrl,
                Resource = $"/players{players}{BuildSubResourcesList(subresources)}"
            });
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Gets Leagues Collection based on supplied Keys
 /// Attaches Requested SubResources
 /// </summary>
 /// <param name="leagueKeys">League Keys to return Resources for </param>
 /// <param name="subresources">SubResources to include with League Resource</param>
 /// <param name="AccessToken">Token for request</param>
 /// <returns>Leagues Collection (List of League Resources)</returns>
 public async Task <List <League> > GetLeagues(string AccessToken, string[] leagueKeys = null, EndpointSubResourcesCollection subresources = null)
 {
     return(await Utils.GetCollection <League>(ApiEndpoints.LeaguesEndPoint(leagueKeys, subresources), AccessToken, "game"));
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Gets Teams Collection based on supplied game Keys for logged in user
 /// Attaches Requested SubResources
 /// </summary>
 /// <param name="gameKeys">Game Keys to return Resources for </param>
 /// <param name="subresources">SubResources to include with Team Resource</param>
 /// <param name="AccessToken">Token for request</param>
 /// <returns>Team Collection (List of Team Resources)</returns>
 public async Task <List <Game> > GetUserGamesTeams(string AccessToken, string[] gameKeys = null, EndpointSubResourcesCollection subresources = null)
 {
     return(await Utils.GetCollection <Game>(ApiEndpoints.TeamsUserGamesEndPoint(gameKeys, subresources), AccessToken, "game"));
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Gets Teams Collection based on supplied Keys
 /// Attaches Requested SubResources
 /// </summary>
 /// <param name="teamKeys">Teams Keys to return Resources for </param>
 /// <param name="subresources">SubResources to include with Team Resource</param>
 /// <param name="AccessToken">Token for request</param>
 /// <returns>Team Collection (List of Team Resources)</returns>
 public async Task <List <Team> > GetTeams(string[] teamKeys, EndpointSubResourcesCollection subresources, string AccessToken)
 {
     return(await Utils.GetCollection <Team>(ApiEndpoints.TeamsEndPoint(teamKeys, subresources), AccessToken, "team"));
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Check if List of SubResources is null or empty
 /// </summary>
 /// <param name="subresources">List of SubResources</param>
 /// <returns>if it is empty or not</returns>
 public static bool IsNotEmpty(this EndpointSubResourcesCollection subresources)
 {
     return(subresources != null && subresources.Resources.Count > 0);
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Get User Resource with Game/Teams Subresource
 /// https://fantasysports.yahooapis.com/fantasy/v2/users;use_login=1/games{gameKeys}/leagues
 /// </summary>
 /// <param name="gameKeys">Game Keys to get Team Resource for</param>
 /// <param name="AccessToken">Access Token from Auth Api</param>
 /// <param name="subresources">SubResources to include with League Resource</param>
 /// <returns>User Resource</returns>
 public async Task <User> GetUserGamesTeamsEndPoint(string AccessToken, string[] gameKeys = null, EndpointSubResourcesCollection subresources = null)
 {
     return(await Utils.GetResource <User>(ApiEndpoints.UserGamesTeamsEndPoint(gameKeys, subresources), AccessToken, "user"));
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Gets Transactions Collection based on supplied league Keys
 /// Attaches Requested SubResources
 /// </summary>
 /// <param name="leagueKeys">League Keys to return Resources for </param>
 /// <param name="subresources">SubResources to include with Transaction Resource</param>
 /// <param name="AccessToken">Token for request</param>
 /// <returns>Transaction Collection (List of Transaction Resources)</returns>
 public async Task <List <Transaction> > GetTransactionsLeagues(string[] leagueKeys, EndpointSubResourcesCollection subresources, string AccessToken)
 {
     return(await Utils.GetCollection <Transaction>(ApiEndpoints.TransactionsLeagueEndPoint(leagueKeys, subresources), AccessToken, "transaction"));
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Gets Games Collection based on supplied Keys for logged in user
 /// Attaches Requested SubResources
 /// Applies Filters if included
 /// </summary>
 /// <param name="gameKeys">Game Keys to return Resources for </param>
 /// <param name="subresources">SubResources to include with Game Resource</param>
 /// <param name="AccessToken">Token for request</param>
 /// <param name="filters">Custom Filter Object on Game</param>
 /// <returns>Games Collection (List of Game Resources)</returns>
 public async Task <List <Game> > GetGamesUsers(string AccessToken, string[] gameKeys = null, EndpointSubResourcesCollection subresources = null, GameCollectionFilters filters = null)
 {
     return(await Utils.GetCollection <Game>(ApiEndpoints.GamesUserEndPoint(gameKeys, subresources, filters), AccessToken, "game"));
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Add/Drops Players
 /// TODO
 /// </summary>
 /// <param name="AccessToken"></param>
 /// <param name="gameKeys"></param>
 /// <param name="subresources"></param>
 /// <returns></returns>
 public async Task <List <Transaction> > AddDropPlayer(string AccessToken, string[] gameKeys = null, EndpointSubResourcesCollection subresources = null)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Gets Players Collection based on supplied Keys
 /// Attaches Requested SubResources
 /// </summary>
 /// <param name="playerKeys">Players Keys to return Resources for </param>
 /// <param name="subresources">SubResources to include with Player Resource</param>
 /// <param name="AccessToken">Token for request</param>
 /// <returns>Players Collection (List of Player Resources)</returns>
 public async Task <List <Player> > GetPlayers(string[] playerKeys, EndpointSubResourcesCollection subresources, string AccessToken)
 {
     return(await Utils.GetCollection <Player>(ApiEndpoints.PlayersEndPoint(playerKeys, subresources), AccessToken, "player"));
 }