yahoo-fantasy
Advanced tools
Comparing version 2.0.4 to 3.0.0
@@ -1,227 +0,249 @@ | ||
var _ = require('lodash'); | ||
var transactionHelper = require('../helpers/transactionHelper.js'); | ||
var transactionHelper = require("../helpers/transactionHelper.js"); | ||
module.exports = TransactionsCollection; | ||
function TransactionsCollection(yf) { | ||
this.yf = yf; | ||
} | ||
TransactionsCollection.prototype.fetch = function(transactionKeys, resources, filters, cb) { | ||
var url = 'https://fantasysports.yahooapis.com/fantasy/v2/transactions;transaction_keys=', | ||
apiCallback = this._fetch_callback.bind(this, cb); | ||
if ( _.isString(transactionKeys) ) { | ||
transactionKeys = [transactionKeys]; | ||
// TODO: https://fantasysports.yahooapis.com/fantasy/v2/league/{league_key}/transactions;types=waiver,pending_trade;team_key={team_key} | ||
// TODO: fetch multiple front end | ||
class TransactionsCollection { | ||
constructor(yf) { | ||
this.yf = yf; | ||
} | ||
url += transactionKeys.join(','); | ||
fetch(transactionKeys, resources, filters, cb) { | ||
var url = | ||
"https://fantasysports.yahooapis.com/fantasy/v2/transactions;transaction_keys=", | ||
apiCallback = this._fetch_callback.bind(this, cb); | ||
if ( !( _.isEmpty(resources) ) ) { | ||
if ( _.isString(resources) ) { | ||
resources = [resources]; | ||
if (_.isString(transactionKeys)) { | ||
transactionKeys = [transactionKeys]; | ||
} | ||
url += ';out=' + resources.join(','); | ||
} | ||
url += transactionKeys.join(","); | ||
if ( !( _.isEmpty(filters) ) ) { | ||
_.each(Object.keys(filters), function(key) { | ||
url += ';' + key + '=' + filters[key]; | ||
}); | ||
} | ||
if (!_.isEmpty(resources)) { | ||
if (_.isString(resources)) { | ||
resources = [resources]; | ||
} | ||
url += '?format=json'; | ||
url += ";out=" + resources.join(","); | ||
} | ||
this | ||
.yf | ||
.api( | ||
this.yf.GET, | ||
url, | ||
apiCallback | ||
); | ||
}; | ||
if (!_.isEmpty(filters)) { | ||
_.each(Object.keys(filters), function(key) { | ||
url += ";" + key + "=" + filters[key]; | ||
}); | ||
} | ||
TransactionsCollection.prototype._fetch_callback = function(cb, e, data) { | ||
if ( e ) return cb(e); | ||
var meta = data.fantasy_content; | ||
return cb(null, meta); | ||
}; | ||
url += "?format=json"; | ||
TransactionsCollection.prototype.leagueFetch = function(leagueKeys, resources, filters, cb) { | ||
var url = 'https://fantasysports.yahooapis.com/fantasy/v2/leagues;league_keys=', | ||
apiCallback = this._leagueFetch_callback.bind(this, cb); | ||
this.yf.api(this.yf.GET, url, (e, data) => { | ||
if (e) { | ||
return cb(e); | ||
} | ||
if ( _.isString(leagueKeys) ) { | ||
leagueKeys = [leagueKeys]; | ||
var meta = data.fantasy_content; | ||
return cb(null, meta); | ||
}); | ||
} | ||
url += leagueKeys.join(','); | ||
url += '/transactions'; | ||
leagueFetch = function(leagueKeys, resources, filters, cb) { | ||
var url = | ||
"https://fantasysports.yahooapis.com/fantasy/v2/leagues;league_keys=", | ||
apiCallback = this._leagueFetch_callback.bind(this, cb); | ||
if ( !( _.isEmpty(resources) ) ) { | ||
if ( _.isString(resources) ) { | ||
resources = [resources]; | ||
if (_.isString(leagueKeys)) { | ||
leagueKeys = [leagueKeys]; | ||
} | ||
url += ';out=' + resources.join(','); | ||
} | ||
url += leagueKeys.join(","); | ||
url += "/transactions"; | ||
if ( !( _.isEmpty(filters) ) ) { | ||
_.each(Object.keys(filters), function(key) { | ||
url += ';' + key + '=' + filters[key]; | ||
}); | ||
} | ||
if (!_.isEmpty(resources)) { | ||
if (_.isString(resources)) { | ||
resources = [resources]; | ||
} | ||
url += '?format=json'; | ||
url += ";out=" + resources.join(","); | ||
} | ||
this | ||
.yf | ||
.api( | ||
this.yf.GET, | ||
url, | ||
apiCallback | ||
); | ||
}; | ||
if (!_.isEmpty(filters)) { | ||
_.each(Object.keys(filters), function(key) { | ||
url += ";" + key + "=" + filters[key]; | ||
}); | ||
} | ||
TransactionsCollection.prototype._leagueFetch_callback = function(cb, e, data) { | ||
if ( e ) return cb(e); | ||
var meta = data.fantasy_content; | ||
return cb(null, meta); | ||
}; | ||
url += "?format=json"; | ||
// todo: https://fantasysports.yahooapis.com/fantasy/v2/league/{league_key}/transactions;types=waiver,pending_trade;team_key={team_key} | ||
this.yf.api(this.yf.GET, url, (e, data) => { | ||
if (e) { | ||
return cb(e); | ||
} | ||
TransactionsCollection.prototype.add_player = function(leagueKey, teamKey, playerKey, cb) { | ||
var url = 'https://fantasysports.yahooapis.com/fantasy/v2/league/' + leagueKey + '/transactions?format=json'; | ||
var apiCallback = this._add_player_callback.bind(this, cb); | ||
var xmlData = ' \ | ||
<fantasy_content> \ | ||
<transaction> \ | ||
<type>add</type> \ | ||
<player> \ | ||
<player_key>' + playerKey + '</player_key> \ | ||
<transaction_data> \ | ||
<type>add</type> \ | ||
<destination_team_key>' + teamKey + '</destination_team_key> \ | ||
</transaction_data> \ | ||
</player> \ | ||
</transaction> \ | ||
</fantasy_content>'; | ||
var meta = data.fantasy_content; | ||
return cb(null, meta); | ||
}); | ||
}; | ||
this | ||
.yf | ||
.api( | ||
this.yf.POST, | ||
url, | ||
xmlData, | ||
apiCallback | ||
); | ||
}; | ||
TransactionsCollection.prototype._add_player_callback = function(cb, e, data) { | ||
if ( e ) return cb(e); | ||
var transactions = data.fantasy_content.league[1].transactions; | ||
transactions = _.filter(transactions, function(p) { return typeof(p) === 'object'; }); | ||
transactions = _.map(transactions, function(p) { return p.transaction; }); | ||
var transaction = transactions[0]; | ||
var meta = transaction[0]; | ||
var players = transactionHelper.mapTransactionPlayers(transaction[1].players); | ||
meta.players = players; | ||
return cb(null, meta); | ||
}; | ||
TransactionsCollection.prototype.drop_player = function(leagueKey, teamKey, playerKey, cb) { | ||
var url = 'https://fantasysports.yahooapis.com/fantasy/v2/league/' + leagueKey + '/transactions?format=json'; | ||
var apiCallback = this._drop_player_callback.bind(this, cb); | ||
var xmlData = ' \ | ||
<fantasy_content> \ | ||
<transaction> \ | ||
<type>drop</type> \ | ||
<player> \ | ||
<player_key>' + playerKey + '</player_key> \ | ||
<transaction_data> \ | ||
<type>drop</type> \ | ||
<source_team_key>' + teamKey + '</source_team_key> \ | ||
</transaction_data> \ | ||
</player> \ | ||
</transaction> \ | ||
</fantasy_content>'; | ||
this | ||
.yf | ||
.api( | ||
this.yf.POST, | ||
url, | ||
xmlData, | ||
apiCallback | ||
); | ||
}; | ||
TransactionsCollection.prototype._drop_player_callback = function(cb, e, data) { | ||
if ( e ) return cb(e); | ||
var transactions = data.fantasy_content.league[1].transactions; | ||
transactions = _.filter(transactions, function(p) { return typeof(p) === 'object'; }); | ||
transactions = _.map(transactions, function(p) { return p.transaction; }); | ||
var transaction = transactions[0]; | ||
var meta = transaction[0]; | ||
var players = transactionHelper.mapTransactionPlayers(transaction[1].players); | ||
meta.players = players; | ||
return cb(null, meta); | ||
}; | ||
TransactionsCollection.prototype.adddrop_players = function(leagueKey, teamKey, addPlayerKey, dropPlayerKey, cb) { | ||
var url = 'https://fantasysports.yahooapis.com/fantasy/v2/league/' + leagueKey + '/transactions?format=json'; | ||
var apiCallback = this._adddrop_players_callback.bind(this, cb); | ||
var xmlData = ' \ | ||
<fantasy_content> \ | ||
<transaction> \ | ||
<type>add/drop</type> \ | ||
<players> \ | ||
add_player = function(leagueKey, teamKey, playerKey, cb) { | ||
var url = | ||
"https://fantasysports.yahooapis.com/fantasy/v2/league/" + | ||
leagueKey + | ||
"/transactions?format=json"; | ||
var apiCallback = this._add_player_callback.bind(this, cb); | ||
var xmlData = | ||
" \ | ||
<fantasy_content> \ | ||
<transaction> \ | ||
<type>add</type> \ | ||
<player> \ | ||
<player_key>' + addPlayerKey + '</player_key> \ | ||
<player_key>" + | ||
playerKey + | ||
"</player_key> \ | ||
<transaction_data> \ | ||
<type>add</type> \ | ||
<destination_team_key>' + teamKey + '</destination_team_key> \ | ||
<destination_team_key>" + | ||
teamKey + | ||
"</destination_team_key> \ | ||
</transaction_data> \ | ||
</player> \ | ||
</transaction> \ | ||
</fantasy_content>"; | ||
this.yf.api(this.yf.POST, url, xmlData, (e, data) => { | ||
if (e) { | ||
return cb(e); | ||
} | ||
var transactions = data.fantasy_content.league[1].transactions; | ||
transactions = _.filter(transactions, function(p) { | ||
return typeof p === "object"; | ||
}); | ||
transactions = _.map(transactions, function(p) { | ||
return p.transaction; | ||
}); | ||
var transaction = transactions[0]; | ||
var meta = transaction[0]; | ||
var players = transactionHelper.mapTransactionPlayers( | ||
transaction[1].players | ||
); | ||
meta.players = players; | ||
return cb(null, meta); | ||
}); | ||
}; | ||
drop_player = function(leagueKey, teamKey, playerKey, cb) { | ||
var url = | ||
"https://fantasysports.yahooapis.com/fantasy/v2/league/" + | ||
leagueKey + | ||
"/transactions?format=json"; | ||
var apiCallback = this._drop_player_callback.bind(this, cb); | ||
var xmlData = | ||
" \ | ||
<fantasy_content> \ | ||
<transaction> \ | ||
<type>drop</type> \ | ||
<player> \ | ||
<player_key>' + dropPlayerKey + '</player_key> \ | ||
<player_key>" + | ||
playerKey + | ||
"</player_key> \ | ||
<transaction_data> \ | ||
<type>drop</type> \ | ||
<source_team_key>' + teamKey + '</source_team_key> \ | ||
<source_team_key>" + | ||
teamKey + | ||
"</source_team_key> \ | ||
</transaction_data> \ | ||
</player> \ | ||
</players> \ | ||
</transaction> \ | ||
</fantasy_content>'; | ||
</transaction> \ | ||
</fantasy_content>"; | ||
this | ||
.yf | ||
.api( | ||
this.yf.POST, | ||
url, | ||
xmlData, | ||
apiCallback | ||
); | ||
}; | ||
this.yf.api(this.yf.POST, url, xmlData, (e, data) => { | ||
if (e) { | ||
return cb(e); | ||
} | ||
TransactionsCollection.prototype._adddrop_players_callback = function(cb, e, data) { | ||
if ( e ) return cb(e); | ||
var transactions = data.fantasy_content.league[1].transactions; | ||
transactions = _.filter(transactions, function(p) { | ||
return typeof p === "object"; | ||
}); | ||
transactions = _.map(transactions, function(p) { | ||
return p.transaction; | ||
}); | ||
var transaction = transactions[0]; | ||
var meta = transaction[0]; | ||
var players = transactionHelper.mapTransactionPlayers( | ||
transaction[1].players | ||
); | ||
meta.players = players; | ||
var transactions = data.fantasy_content.league[1].transactions; | ||
transactions = _.filter(transactions, function(p) { return typeof(p) === 'object'; }); | ||
transactions = _.map(transactions, function(p) { return p.transaction; }); | ||
var transaction = transactions[0]; | ||
var meta = transaction[0]; | ||
var players = transactionHelper.mapTransactionPlayers(transaction[1].players); | ||
meta.players = players; | ||
return cb(null, meta); | ||
}); | ||
}; | ||
return cb(null, meta); | ||
}; | ||
adddrop_players = function( | ||
leagueKey, | ||
teamKey, | ||
addPlayerKey, | ||
dropPlayerKey, | ||
cb | ||
) { | ||
var url = | ||
"https://fantasysports.yahooapis.com/fantasy/v2/league/" + | ||
leagueKey + | ||
"/transactions?format=json"; | ||
var apiCallback = this._adddrop_players_callback.bind(this, cb); | ||
var xmlData = | ||
" \ | ||
<fantasy_content> \ | ||
<transaction> \ | ||
<type>add/drop</type> \ | ||
<players> \ | ||
<player> \ | ||
<player_key>" + | ||
addPlayerKey + | ||
"</player_key> \ | ||
<transaction_data> \ | ||
<type>add</type> \ | ||
<destination_team_key>" + | ||
teamKey + | ||
"</destination_team_key> \ | ||
</transaction_data> \ | ||
</player> \ | ||
<player> \ | ||
<player_key>" + | ||
dropPlayerKey + | ||
"</player_key> \ | ||
<transaction_data> \ | ||
<type>drop</type> \ | ||
<source_team_key>" + | ||
teamKey + | ||
"</source_team_key> \ | ||
</transaction_data> \ | ||
</player> \ | ||
</players> \ | ||
</transaction> \ | ||
</fantasy_content>"; | ||
this.yf.api(this.yf.POST, url, xmlData, (e, data) => { | ||
if (e) { | ||
return cb(e); | ||
} | ||
var transactions = data.fantasy_content.league[1].transactions; | ||
transactions = _.filter(transactions, function(p) { | ||
return typeof p === "object"; | ||
}); | ||
transactions = _.map(transactions, function(p) { | ||
return p.transaction; | ||
}); | ||
var transaction = transactions[0]; | ||
var meta = transaction[0]; | ||
var players = transactionHelper.mapTransactionPlayers( | ||
transaction[1].players | ||
); | ||
meta.players = players; | ||
return cb(null, meta); | ||
}); | ||
}; | ||
} | ||
export default TransactionsCollection; |
78
index.js
/* global module, require */ | ||
require = require("esm")(module, true); | ||
module.exports = require("./YahooFantasy.mjs").default; | ||
'use strict'; | ||
module.exports = YahooFantasy; | ||
var request = require('request'), | ||
GameResource = require('./resources/gameResource.js'), | ||
LeagueResource = require('./resources/leagueResource.js'), | ||
PlayerResource = require('./resources/playerResource.js'), | ||
RosterResource = require('./resources/rosterResource.js'), | ||
TeamResource = require('./resources/teamResource.js'), | ||
TransactionResource = require('./resources/transactionResource.js'), | ||
UserResource = require('./resources/userResource.js'), | ||
PlayersCollection = require('./collections/playersCollection.js'), | ||
GamesCollection = require('./collections/gamesCollection.js'), | ||
TeamsCollection = require('./collections/teamsCollection.js'), | ||
LeaguesCollection = require('./collections/leaguesCollection.js'), | ||
TransactionsCollection = require('./collections/transactionsCollection.js'); | ||
// usersCollection = require('./collections/usersCollection.js'); | ||
function YahooFantasy(consumerKey, consumerSecret) { | ||
this.GET = 'GET'; | ||
this.POST = 'POST'; | ||
this.game = new GameResource(this); | ||
this.games = new GamesCollection(this); | ||
this.league = new LeagueResource(this); | ||
this.leagues = new LeaguesCollection(this); | ||
this.player = new PlayerResource(this); | ||
this.players = new PlayersCollection(this); | ||
this.team = new TeamResource(this); | ||
this.teams = new TeamsCollection(this); | ||
this.transaction = new TransactionResource(this); | ||
this.transactions = new TransactionsCollection(this); | ||
this.roster = new RosterResource(this); | ||
this.user = new UserResource(this); | ||
// this.users = new UsersCollection(); // TODO | ||
this.yahooUserToken = null; | ||
} | ||
YahooFantasy.prototype.setUserToken = function(token) { | ||
this.yahooUserToken = token; | ||
}; | ||
YahooFantasy.prototype.api = function(method, url, postData, cb) { | ||
if ( arguments.length == 3 ) { | ||
cb = postData; | ||
postData = null; | ||
} | ||
var callback = this.apiCallback.bind(this, method, url, postData, cb); | ||
var options = { | ||
url: url, | ||
method: method, | ||
json: true, | ||
auth: { | ||
'bearer': this.yahooUserToken | ||
} | ||
}; | ||
request(options, callback); | ||
}; | ||
YahooFantasy.prototype.apiCallback = function(method, url, postData, cb, e, resp, data) { | ||
if (e) { | ||
return cb(e); | ||
} else { | ||
if ( data.error ) { | ||
return cb(data.error); | ||
} | ||
return cb(null, data); | ||
} | ||
}; | ||
// TODO: league settings sample data | ||
// TODO: transactions sample data |
{ | ||
"name": "yahoo-fantasy", | ||
"version": "2.0.4", | ||
"description": "An API to help facilitate the use of the Yahoo! Fantasy Sports API in NodeJS projects.", | ||
"version": "3.0.0", | ||
"description": | ||
"An API to help facilitate the use of the Yahoo! Fantasy Sports API in NodeJS projects.", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "./node_modules/jasmine-node/bin/jasmine-node ./tests/", | ||
"test": "node -r @std/esm jasmine-runner.js", | ||
"istanbul": "istanbul cover --include-all-sources jasmine-node tests" | ||
@@ -12,10 +13,5 @@ }, | ||
"type": "git", | ||
"url": "https://github.com/whatadewitt/yfsapi" | ||
"url": "git+https://github.com/whatadewitt/yfsapi.git" | ||
}, | ||
"keywords": [ | ||
"yahoo", | ||
"fantasy sports", | ||
"sports", | ||
"fantasy" | ||
], | ||
"keywords": ["yahoo", "fantasy sports", "sports", "fantasy"], | ||
"author": "Luke DeWitt <dewittl@gmail.com> (http://www.whatadewitt.ca/)", | ||
@@ -28,3 +24,3 @@ "license": "MIT", | ||
"dependencies": { | ||
"lodash": "^4.16.6", | ||
"esm": "^3.0.14", | ||
"request": "^2.78.0" | ||
@@ -34,6 +30,11 @@ }, | ||
"istanbul": "^0.4.3", | ||
"jasmine": "^3.0.0", | ||
"jasmine-node": "^1.14.5", | ||
"jasmine-spec-reporter": "^4.2.1", | ||
"nock": "^3.3.2", | ||
"q": "^1.4.1", | ||
"jasmine-node": "^1.14.5" | ||
"q": "^1.4.1" | ||
}, | ||
"directories": { | ||
"test": "tests" | ||
} | ||
} |
@@ -1,12 +0,10 @@ | ||
var YahooFantasy = require('../index.js'); | ||
var nock = require('nock'); | ||
var q = require('q'); | ||
var YahooFantasy = require("../index.js"); | ||
var nock = require("nock"); | ||
var q = require("q"); | ||
describe ("resource : gameResource", function(){ | ||
var yf = new YahooFantasy( | ||
'Y!APPLICATION_KEY', | ||
'Y!APPLICATION_SECRET'), | ||
describe("resource : gameResource", function() { | ||
var yf = new YahooFantasy("Y!APPLICATION_KEY", "Y!APPLICATION_SECRET"), | ||
game = yf.game; | ||
it ("should be defined", function() { | ||
it("should be defined", function() { | ||
expect(game).not.toBe(null); | ||
@@ -16,27 +14,27 @@ }); | ||
// functions | ||
it ("should have a meta function", function() { | ||
it("should have a meta function", function() { | ||
expect(game.meta).not.toBe(null); | ||
}); | ||
it ("should have a leagues function", function() { | ||
it("should have a leagues function", function() { | ||
expect(game.leagues).not.toBe(null); | ||
}); | ||
it ("should have a players function", function() { | ||
it("should have a players function", function() { | ||
expect(game.players).not.toBe(null); | ||
}); | ||
it ("should have a game_weeks function", function() { | ||
it("should have a game_weeks function", function() { | ||
expect(game.game_weeks).not.toBe(null); | ||
}); | ||
it ("should have a stat_categories function", function() { | ||
it("should have a stat_categories function", function() { | ||
expect(game.stat_categories).not.toBe(null); | ||
}); | ||
it ("should have a position_types function", function() { | ||
it("should have a position_types function", function() { | ||
expect(game.position_types).not.toBe(null); | ||
}); | ||
it ("should have a roster_positions function", function() { | ||
it("should have a roster_positions function", function() { | ||
expect(game.roster_positions).not.toBe(null); | ||
@@ -47,6 +45,6 @@ }); | ||
describe(": meta", function() { | ||
var meta = require('./nock-data/gameMeta').meta; | ||
var meta = require("./nock-data/gameMeta").meta; | ||
it ("should build a proper url to retrieve metadata via a numeric game key", function(done) { | ||
nock('https://fantasysports.yahooapis.com') | ||
it("should build a proper url to retrieve metadata via a numeric game key", function(done) { | ||
nock("https://fantasysports.yahooapis.com") | ||
.get("/fantasy/v2/game/328/metadata?format=json") | ||
@@ -61,8 +59,8 @@ .reply(200, meta); | ||
it ("should build a proper url to retrieve metadata via a string game key", function(done) { | ||
nock('https://fantasysports.yahooapis.com') | ||
it("should build a proper url to retrieve metadata via a string game key", function(done) { | ||
nock("https://fantasysports.yahooapis.com") | ||
.get("/fantasy/v2/game/mlb/metadata?format=json") | ||
.reply(200, meta); | ||
game.meta('mlb', function(e, data) { | ||
game.meta("mlb", function(e, data) { | ||
expect(data).toEqual(meta.fantasy_content.game[0]); | ||
@@ -80,43 +78,60 @@ done(); | ||
describe(": leagues", function() { | ||
it("should build a proper url to retrieve league data for a single league using a numeric game key", function() { | ||
game.leagues(328, "328.l.34014", null); | ||
it ("should build a proper url to retrieve league data for a single league using a numeric game key", function() { | ||
game.leagues(328, '328.l.34014', null); | ||
expect(yf.api) | ||
.toHaveBeenCalledWith("GET", "https://fantasysports.yahooapis.com/fantasy/v2/game/328/leagues;league_keys=328.l.34014?format=json", jasmine.any(Function)); | ||
expect(yf.api).toHaveBeenCalledWith( | ||
"GET", | ||
"https://fantasysports.yahooapis.com/fantasy/v2/game/328/leagues;league_keys=328.l.34014?format=json", | ||
jasmine.any(Function) | ||
); | ||
}); | ||
it ("should build a proper url to retrieve league data for a single league using a string game key", function() { | ||
game.leagues('mlb', 'mlb.l.34014', null); | ||
it("should build a proper url to retrieve league data for a single league using a string game key", function() { | ||
game.leagues("mlb", "mlb.l.34014", null); | ||
expect(yf.api) | ||
.toHaveBeenCalledWith("GET", "https://fantasysports.yahooapis.com/fantasy/v2/game/mlb/leagues;league_keys=mlb.l.34014?format=json", jasmine.any(Function)); | ||
expect(yf.api).toHaveBeenCalledWith( | ||
"GET", | ||
"https://fantasysports.yahooapis.com/fantasy/v2/game/mlb/leagues;league_keys=mlb.l.34014?format=json", | ||
jasmine.any(Function) | ||
); | ||
}); | ||
it ("should build a proper url to retrieve league data for a single league using a numeric game key and league as an array", function() { | ||
game.leagues(328, ['328.l.34014'], null); | ||
it("should build a proper url to retrieve league data for a single league using a numeric game key and league as an array", function() { | ||
game.leagues(328, ["328.l.34014"], null); | ||
expect(yf.api) | ||
.toHaveBeenCalledWith("GET", "https://fantasysports.yahooapis.com/fantasy/v2/game/328/leagues;league_keys=328.l.34014?format=json", jasmine.any(Function)); | ||
expect(yf.api).toHaveBeenCalledWith( | ||
"GET", | ||
"https://fantasysports.yahooapis.com/fantasy/v2/game/328/leagues;league_keys=328.l.34014?format=json", | ||
jasmine.any(Function) | ||
); | ||
}); | ||
it ("should build a proper url to retrieve league data for a single league using a string game key and league as an array", function() { | ||
game.leagues('mlb', ['mlb.l.34014'], null); | ||
it("should build a proper url to retrieve league data for a single league using a string game key and league as an array", function() { | ||
game.leagues("mlb", ["mlb.l.34014"], null); | ||
expect(yf.api) | ||
.toHaveBeenCalledWith("GET", "https://fantasysports.yahooapis.com/fantasy/v2/game/mlb/leagues;league_keys=mlb.l.34014?format=json", jasmine.any(Function)); | ||
expect(yf.api).toHaveBeenCalledWith( | ||
"GET", | ||
"https://fantasysports.yahooapis.com/fantasy/v2/game/mlb/leagues;league_keys=mlb.l.34014?format=json", | ||
jasmine.any(Function) | ||
); | ||
}); | ||
it ("should build a proper url to retrieve league data for a multiple leagues using a numeric game key", function() { | ||
game.leagues(328, ['328.l.34014', '328.l.24281'], null); | ||
it("should build a proper url to retrieve league data for a multiple leagues using a numeric game key", function() { | ||
game.leagues(328, ["328.l.34014", "328.l.24281"], null); | ||
expect(yf.api) | ||
.toHaveBeenCalledWith("GET", "https://fantasysports.yahooapis.com/fantasy/v2/game/328/leagues;league_keys=328.l.34014,328.l.24281?format=json", jasmine.any(Function)); | ||
expect(yf.api).toHaveBeenCalledWith( | ||
"GET", | ||
"https://fantasysports.yahooapis.com/fantasy/v2/game/328/leagues;league_keys=328.l.34014,328.l.24281?format=json", | ||
jasmine.any(Function) | ||
); | ||
}); | ||
it ("should build a proper url to retrieve league data for a multiple leagues using a string game key", function() { | ||
game.leagues('mlb', ['mlb.l.34014', 'mlb.l.24281'], null); | ||
it("should build a proper url to retrieve league data for a multiple leagues using a string game key", function() { | ||
game.leagues("mlb", ["mlb.l.34014", "mlb.l.24281"], null); | ||
expect(yf.api) | ||
.toHaveBeenCalledWith("GET", "https://fantasysports.yahooapis.com/fantasy/v2/game/mlb/leagues;league_keys=mlb.l.34014,mlb.l.24281?format=json", jasmine.any(Function)); | ||
expect(yf.api).toHaveBeenCalledWith( | ||
"GET", | ||
"https://fantasysports.yahooapis.com/fantasy/v2/game/mlb/leagues;league_keys=mlb.l.34014,mlb.l.24281?format=json", | ||
jasmine.any(Function) | ||
); | ||
}); | ||
@@ -126,103 +141,145 @@ }); | ||
// players | ||
it ("should build a proper url to retrieve player data for a single player using a numeric game key", function() { | ||
game.players(328, '328.p.6619', null); | ||
it("should build a proper url to retrieve player data for a single player using a numeric game key", function() { | ||
game.players(328, "328.p.6619", null); | ||
expect(yf.api) | ||
.toHaveBeenCalledWith("GET", "https://fantasysports.yahooapis.com/fantasy/v2/game/328/players;player_keys=328.p.6619?format=json", jasmine.any(Function)); | ||
expect(yf.api).toHaveBeenCalledWith( | ||
"GET", | ||
"https://fantasysports.yahooapis.com/fantasy/v2/game/328/players;player_keys=328.p.6619?format=json", | ||
jasmine.any(Function) | ||
); | ||
}); | ||
it ("should build a proper url to retrieve player data for a single player using a string game key", function() { | ||
game.players('mlb', 'mlb.p.6619', null); | ||
it("should build a proper url to retrieve player data for a single player using a string game key", function() { | ||
game.players("mlb", "mlb.p.6619", null); | ||
expect(yf.api) | ||
.toHaveBeenCalledWith("GET", "https://fantasysports.yahooapis.com/fantasy/v2/game/mlb/players;player_keys=mlb.p.6619?format=json", jasmine.any(Function)); | ||
expect(yf.api).toHaveBeenCalledWith( | ||
"GET", | ||
"https://fantasysports.yahooapis.com/fantasy/v2/game/mlb/players;player_keys=mlb.p.6619?format=json", | ||
jasmine.any(Function) | ||
); | ||
}); | ||
it ("should build a proper url to retrieve player data for a single player using a numeric game key and player as an array", function() { | ||
game.players(328, ['328.p.6619'], null); | ||
it("should build a proper url to retrieve player data for a single player using a numeric game key and player as an array", function() { | ||
game.players(328, ["328.p.6619"], null); | ||
expect(yf.api) | ||
.toHaveBeenCalledWith("GET", "https://fantasysports.yahooapis.com/fantasy/v2/game/328/players;player_keys=328.p.6619?format=json", jasmine.any(Function)); | ||
expect(yf.api).toHaveBeenCalledWith( | ||
"GET", | ||
"https://fantasysports.yahooapis.com/fantasy/v2/game/328/players;player_keys=328.p.6619?format=json", | ||
jasmine.any(Function) | ||
); | ||
}); | ||
it ("should build a proper url to retrieve player data for a single player using a string game key and player as an array", function() { | ||
game.players('mlb', ['mlb.p.6619'], null); | ||
it("should build a proper url to retrieve player data for a single player using a string game key and player as an array", function() { | ||
game.players("mlb", ["mlb.p.6619"], null); | ||
expect(yf.api) | ||
.toHaveBeenCalledWith("GET", "https://fantasysports.yahooapis.com/fantasy/v2/game/mlb/players;player_keys=mlb.p.6619?format=json", jasmine.any(Function)); | ||
expect(yf.api).toHaveBeenCalledWith( | ||
"GET", | ||
"https://fantasysports.yahooapis.com/fantasy/v2/game/mlb/players;player_keys=mlb.p.6619?format=json", | ||
jasmine.any(Function) | ||
); | ||
}); | ||
it ("should build a proper url to retrieve player data for a multiple players using a numeric game key", function() { | ||
game.players(328, ['328.p.6619', '328.p.8172'], null); | ||
it("should build a proper url to retrieve player data for a multiple players using a numeric game key", function() { | ||
game.players(328, ["328.p.6619", "328.p.8172"], null); | ||
expect(yf.api) | ||
.toHaveBeenCalledWith("GET", "https://fantasysports.yahooapis.com/fantasy/v2/game/328/players;player_keys=328.p.6619,328.p.8172?format=json", jasmine.any(Function)); | ||
expect(yf.api).toHaveBeenCalledWith( | ||
"GET", | ||
"https://fantasysports.yahooapis.com/fantasy/v2/game/328/players;player_keys=328.p.6619,328.p.8172?format=json", | ||
jasmine.any(Function) | ||
); | ||
}); | ||
it ("should build a proper url to retrieve player data for a multiple players using a string game key", function() { | ||
game.players('mlb', ['mlb.p.6619', 'mlb.p.8172'], null); | ||
it("should build a proper url to retrieve player data for a multiple players using a string game key", function() { | ||
game.players("mlb", ["mlb.p.6619", "mlb.p.8172"], null); | ||
expect(yf.api) | ||
.toHaveBeenCalledWith("GET", "https://fantasysports.yahooapis.com/fantasy/v2/game/mlb/players;player_keys=mlb.p.6619,mlb.p.8172?format=json", jasmine.any(Function)); | ||
expect(yf.api).toHaveBeenCalledWith( | ||
"GET", | ||
"https://fantasysports.yahooapis.com/fantasy/v2/game/mlb/players;player_keys=mlb.p.6619,mlb.p.8172?format=json", | ||
jasmine.any(Function) | ||
); | ||
}); | ||
// game_weeks | ||
it ("should build a proper url to retrieve game weeks using a numeric game key", function() { | ||
it("should build a proper url to retrieve game weeks using a numeric game key", function() { | ||
game.game_weeks(328, null); | ||
expect(yf.api) | ||
.toHaveBeenCalledWith("GET", "https://fantasysports.yahooapis.com/fantasy/v2/game/328/game_weeks?format=json", jasmine.any(Function)); | ||
expect(yf.api).toHaveBeenCalledWith( | ||
"GET", | ||
"https://fantasysports.yahooapis.com/fantasy/v2/game/328/game_weeks?format=json", | ||
jasmine.any(Function) | ||
); | ||
}); | ||
it ("should build a proper url to retrieve game weeks using a string game key", function() { | ||
game.game_weeks('nfl', null); | ||
it("should build a proper url to retrieve game weeks using a string game key", function() { | ||
game.game_weeks("nfl", null); | ||
expect(yf.api) | ||
.toHaveBeenCalledWith("GET", "https://fantasysports.yahooapis.com/fantasy/v2/game/nfl/game_weeks?format=json", jasmine.any(Function)); | ||
expect(yf.api).toHaveBeenCalledWith( | ||
"GET", | ||
"https://fantasysports.yahooapis.com/fantasy/v2/game/nfl/game_weeks?format=json", | ||
jasmine.any(Function) | ||
); | ||
}); | ||
// stat_categories | ||
it ("should build a proper url to retrieve stat categories using a numeric game key", function() { | ||
it("should build a proper url to retrieve stat categories using a numeric game key", function() { | ||
game.stat_categories(328, null); | ||
expect(yf.api) | ||
.toHaveBeenCalledWith("GET", "https://fantasysports.yahooapis.com/fantasy/v2/game/328/stat_categories?format=json", jasmine.any(Function)); | ||
expect(yf.api).toHaveBeenCalledWith( | ||
"GET", | ||
"https://fantasysports.yahooapis.com/fantasy/v2/game/328/stat_categories?format=json", | ||
jasmine.any(Function) | ||
); | ||
}); | ||
it ("should build a proper url to retrieve stat categories using a string game key", function() { | ||
game.stat_categories('nfl', null); | ||
it("should build a proper url to retrieve stat categories using a string game key", function() { | ||
game.stat_categories("nfl", null); | ||
expect(yf.api) | ||
.toHaveBeenCalledWith("GET", "https://fantasysports.yahooapis.com/fantasy/v2/game/nfl/stat_categories?format=json", jasmine.any(Function)); | ||
expect(yf.api).toHaveBeenCalledWith( | ||
"GET", | ||
"https://fantasysports.yahooapis.com/fantasy/v2/game/nfl/stat_categories?format=json", | ||
jasmine.any(Function) | ||
); | ||
}); | ||
// position_types | ||
it ("should build a proper url to retrieve position types using a numeric game key", function() { | ||
it("should build a proper url to retrieve position types using a numeric game key", function() { | ||
game.position_types(328, null); | ||
expect(yf.api) | ||
.toHaveBeenCalledWith("GET", "https://fantasysports.yahooapis.com/fantasy/v2/game/328/position_types?format=json", jasmine.any(Function)); | ||
expect(yf.api).toHaveBeenCalledWith( | ||
"GET", | ||
"https://fantasysports.yahooapis.com/fantasy/v2/game/328/position_types?format=json", | ||
jasmine.any(Function) | ||
); | ||
}); | ||
it ("should build a proper url to retrieve position types using a string game key", function() { | ||
game.position_types('nfl', null); | ||
it("should build a proper url to retrieve position types using a string game key", function() { | ||
game.position_types("nfl", null); | ||
expect(yf.api) | ||
.toHaveBeenCalledWith("GET", "https://fantasysports.yahooapis.com/fantasy/v2/game/nfl/position_types?format=json", jasmine.any(Function)); | ||
expect(yf.api).toHaveBeenCalledWith( | ||
"GET", | ||
"https://fantasysports.yahooapis.com/fantasy/v2/game/nfl/position_types?format=json", | ||
jasmine.any(Function) | ||
); | ||
}); | ||
// roster_positions | ||
it ("should build a proper url to retrieve roster positions using a numeric game key", function() { | ||
it("should build a proper url to retrieve roster positions using a numeric game key", function() { | ||
game.roster_positions(328, null); | ||
expect(yf.api) | ||
.toHaveBeenCalledWith("GET", "https://fantasysports.yahooapis.com/fantasy/v2/game/328/roster_positions?format=json", jasmine.any(Function)); | ||
expect(yf.api).toHaveBeenCalledWith( | ||
"GET", | ||
"https://fantasysports.yahooapis.com/fantasy/v2/game/328/roster_positions?format=json", | ||
jasmine.any(Function) | ||
); | ||
}); | ||
it ("should build a proper url to retrieve roster positions using a string game key", function() { | ||
game.roster_positions('nfl', null); | ||
it("should build a proper url to retrieve roster positions using a string game key", function() { | ||
game.roster_positions("nfl", null); | ||
expect(yf.api) | ||
.toHaveBeenCalledWith("GET", "https://fantasysports.yahooapis.com/fantasy/v2/game/nfl/roster_positions?format=json", jasmine.any(Function)); | ||
expect(yf.api).toHaveBeenCalledWith( | ||
"GET", | ||
"https://fantasysports.yahooapis.com/fantasy/v2/game/nfl/roster_positions?format=json", | ||
jasmine.any(Function) | ||
); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
79
5304
0
725114
6
+ Addedesm@^3.0.14
+ Addedesm@3.2.25(transitive)
- Removedlodash@^4.16.6
- Removedlodash@4.17.21(transitive)