yahoo-fantasy
Advanced tools
Comparing version 0.5.0 to 0.5.1
@@ -13,6 +13,5 @@ var _ = require('lodash'); | ||
var gameKeys = '', | ||
subresources = '', | ||
subresources = [], | ||
filters = {}, | ||
cb = arguments[arguments.length - 1], | ||
apiCallback = this._fetch_callback.bind(this, cb); | ||
cb = arguments[arguments.length - 1]; | ||
@@ -56,2 +55,4 @@ // there should be a better way... | ||
var apiCallback = this._fetch_callback.bind(this, cb, subresources); | ||
this | ||
@@ -66,3 +67,3 @@ .yf | ||
GamesCollection.prototype._fetch_callback = function(cb, e, data) { | ||
GamesCollection.prototype._fetch_callback = function(cb, subresources, e, data) { | ||
if ( e ) return cb(e); | ||
@@ -76,6 +77,5 @@ | ||
// no gamekeys... | ||
var subresources = '', | ||
var subresources = [], | ||
filters = {}, | ||
cb = arguments[arguments.length - 1], | ||
apiCallback = this._user_callback.bind(this, cb); | ||
cb = arguments[arguments.length - 1]; | ||
@@ -119,2 +119,4 @@ switch (arguments.length) { | ||
var apiCallback = this._user_callback.bind(this, cb, subresources); | ||
this | ||
@@ -129,3 +131,3 @@ .yf | ||
GamesCollection.prototype._user_callback = function(cb, e, data) { | ||
GamesCollection.prototype._user_callback = function(cb, subresources, e, data) { | ||
if ( e ) return cb(e); | ||
@@ -141,4 +143,3 @@ | ||
subresources = ( arguments.length > 2 ) ? arguments[1] : [], | ||
cb = arguments[arguments.length - 1], | ||
apiCallback = this._userFetch_callback.bind(this, cb); | ||
cb = arguments[arguments.length - 1]; | ||
@@ -159,2 +160,4 @@ var url = 'http://fantasysports.yahooapis.com/fantasy/v2/users;use_login=1/games;game_keys='; | ||
var apiCallback = this._userFetch_callback.bind(this, cb, subresources); | ||
this | ||
@@ -169,3 +172,3 @@ .yf | ||
GamesCollection.prototype._userFetch_callback = function(cb, e, data) { | ||
GamesCollection.prototype._userFetch_callback = function(cb, subresources, e, data) { | ||
if ( e ) return cb(e); | ||
@@ -172,0 +175,0 @@ |
@@ -14,4 +14,3 @@ var _ = require('lodash'); | ||
subresources = ( arguments.length > 2 ) ? arguments[1] : [], | ||
cb = arguments[arguments.length - 1], | ||
apiCallback = this._fetch_callback.bind(this, cb); | ||
cb = arguments[arguments.length - 1]; | ||
@@ -36,2 +35,4 @@ var url = 'http://fantasysports.yahooapis.com/fantasy/v2/leagues;league_keys='; | ||
var apiCallback = this._fetch_callback.bind(this, cb, subresources); | ||
this | ||
@@ -46,3 +47,3 @@ .yf | ||
LeaguesCollection.prototype._fetch_callback = function(cb, e, data) { | ||
LeaguesCollection.prototype._fetch_callback = function(cb, subresources, e, data) { | ||
if ( e ) return cb(e); | ||
@@ -49,0 +50,0 @@ |
@@ -13,4 +13,3 @@ var _ = require('lodash'); | ||
subresources = ( arguments.length > 2 ) ? arguments[1] : [], | ||
cb = arguments[arguments.length - 1], | ||
apiCallback = this._fetch_callback.bind(this, cb); | ||
cb = arguments[arguments.length - 1]; | ||
@@ -35,2 +34,4 @@ var url = 'http://fantasysports.yahooapis.com/fantasy/v2/players;player_keys='; | ||
var apiCallback = this._fetch_callback.bind(this, cb, subresources); | ||
this | ||
@@ -45,5 +46,5 @@ .yf | ||
PlayersCollection.prototype._fetch_callback = function(cb, e, data) { | ||
PlayersCollection.prototype._fetch_callback = function(cb, subresources, e, data) { | ||
if ( e ) return cb(e); | ||
var players = playerHelper.parseCollection(data.fantasy_content.players, subresources); | ||
@@ -58,4 +59,3 @@ return cb(null, players); | ||
subresources = ( arguments.length > 3 ) ? arguments[2] : ( arguments.length > 2 && _.isArray( arguments[1]) ) ? arguments[1] : [], // ugliest line of code ever? | ||
cb = arguments[arguments.length - 1], | ||
apiCallback = this._leagues_callback.bind(this, cb); | ||
cb = arguments[arguments.length - 1]; | ||
@@ -87,2 +87,4 @@ var url = 'http://fantasysports.yahooapis.com/fantasy/v2/leagues;league_keys='; | ||
apiCallback = this._leagues_callback.bind(this, cb, subresources); | ||
this | ||
@@ -97,3 +99,3 @@ .yf | ||
PlayersCollection.prototype._leagues_callback = function(cb, e, data) { | ||
PlayersCollection.prototype._leagues_callback = function(cb, subresources, e, data) { | ||
if ( e ) return cb(e); | ||
@@ -109,4 +111,3 @@ | ||
subresources = ( arguments.length > 3 ) ? arguments[2] : ( arguments.length > 2 && _.isArray( arguments[1]) ) ? arguments[1] : [], // ugliest line of code ever? | ||
cb = arguments[arguments.length - 1], | ||
apiCallback = this._teams_callback.bind(this, cb); | ||
cb = arguments[arguments.length - 1]; | ||
@@ -138,2 +139,4 @@ var url = 'http://fantasysports.yahooapis.com/fantasy/v2/teams;team_keys='; | ||
var apiCallback = this._teams_callback.bind(this, cb, subresources); | ||
this | ||
@@ -148,3 +151,3 @@ .yf | ||
PlayersCollection.prototype._teams_callback = function(cb, e, data) { | ||
PlayersCollection.prototype._teams_callback = function(cb, subresources, e, data) { | ||
if ( e ) return cb(e); | ||
@@ -151,0 +154,0 @@ |
@@ -13,4 +13,3 @@ var _ = require('lodash'); | ||
subresources = ( arguments.length > 2 ) ? arguments[1] : [], | ||
cb = arguments[arguments.length - 1], | ||
apiCallback = this._fetch_callback.bind(this, cb); | ||
cb = arguments[arguments.length - 1]; | ||
@@ -35,2 +34,4 @@ var url = 'http://fantasysports.yahooapis.com/fantasy/v2/teams;team_keys='; | ||
var apiCallback = this._fetch_callback.bind(this, cb, subresources); | ||
this | ||
@@ -45,3 +46,3 @@ .yf | ||
TeamsCollection.prototype._fetch_callback = function(cb, e, data) { | ||
TeamsCollection.prototype._fetch_callback = function(cb, subresources, e, data) { | ||
if ( e ) return cb(e); | ||
@@ -56,4 +57,3 @@ | ||
subresources = ( arguments.length > 2 ) ? arguments[1] : [], | ||
cb = arguments[arguments.length - 1], | ||
apiCallback = this._leagues_callback.bind(this, cb); | ||
cb = arguments[arguments.length - 1]; | ||
@@ -79,2 +79,4 @@ var url = 'http://fantasysports.yahooapis.com/fantasy/v2/leagues;league_keys='; | ||
var apiCallback = this._leagues_callback.bind(this, cb, subresources); | ||
this | ||
@@ -89,3 +91,3 @@ .yf | ||
TeamsCollection.prototype._leagues_callback = function(cb, e, data) { | ||
TeamsCollection.prototype._leagues_callback = function(cb, subresources, e, data) { | ||
if ( e ) return cb(e); | ||
@@ -99,4 +101,3 @@ | ||
var subresources = ( arguments.length > 1 ) ? arguments[1] : [], | ||
cb = arguments[arguments.length - 1], | ||
apiCallback = this._userFetch_callback.bind(this, cb); | ||
cb = arguments[arguments.length - 1]; | ||
@@ -115,2 +116,4 @@ var url = 'http://fantasysports.yahooapis.com/fantasy/v2/users;use_login=1/teams'; | ||
var apiCallback = this._userFetch_callback.bind(this, cb, subresources); | ||
this | ||
@@ -125,3 +128,3 @@ .yf | ||
TeamsCollection.prototype._userFetch_callback = function(cb, e, data) { | ||
TeamsCollection.prototype._userFetch_callback = function(cb, subresources, e, data) { | ||
if ( e ) return cb(e); | ||
@@ -136,4 +139,3 @@ | ||
subresources = ( arguments.length > 2 ) ? arguments[1] : [], | ||
cb = arguments[arguments.length - 1], | ||
apiCallback = this._games_callback.bind(this, cb); | ||
cb = arguments[arguments.length - 1]; | ||
@@ -159,2 +161,4 @@ var url = 'http://fantasysports.yahooapis.com/fantasy/v2/users;use_login=1/games;game_keys='; | ||
var apiCallback = this._games_callback.bind(this, cb, subresources); | ||
this | ||
@@ -169,3 +173,3 @@ .yf | ||
TeamsCollection.prototype._games_callback = function(cb, e, data) { | ||
TeamsCollection.prototype._games_callback = function(cb, subresources, e, data) { | ||
if ( e ) return cb(e); | ||
@@ -172,0 +176,0 @@ |
{ | ||
"name": "yahoo-fantasy", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"description": "An API to help facilitate the use of the Yahoo! Fantasy Sports API in NodeJS projects.", | ||
@@ -28,3 +28,3 @@ "main": "index.js", | ||
"istanbul": "^0.4.3", | ||
"jasmine-node": "^1.14.5", | ||
"jasmine": "^2.4.1", | ||
"lodash": "^4.11.1", | ||
@@ -31,0 +31,0 @@ "nock": "^3.3.2", |
@@ -58,2 +58,5 @@ Yahoo! Fantasy API Node Module | ||
#### 0.5.1 | ||
* Fixed a bug where collections that contained subresources would return no data. | ||
#### 0.5.0 | ||
@@ -60,0 +63,0 @@ * Added "Transactions" collection with functionality to add players, drop players, and add/drop players, thanks again [githubsmilo](https://github.com/githubsmilo)! |
@@ -1,4 +0,3 @@ | ||
module.exports = { | ||
"meta": {"fantasy_content":{"xml:lang":"en-US","yahoo:uri":"\/fantasy\/v2\/game\/328\/metadata","game":[{"game_key":"328","game_id":"328","name":"Baseball","code":"mlb","type":"full","url":"http:\/\/baseball.fantasysports.yahoo.com\/archive\/mlb\/2014","season":"2014","is_registration_over":1}],"time":"20.011901855469ms","copyright":"Data provided by Yahoo! and STATS, LLC","refresh_rate":"31"}}, | ||
"invalid": { statusCode: 400, data: '{"error":{"xml:lang":"en-us","yahoo:uri":"\\/fantasy\\/v2\\/game\\/MBL\\/metadata?format=json","description":"Invalid game key provided - mbl","detail":""}}' } | ||
}; | ||
exports.meta = {"fantasy_content":{"xml:lang":"en-US","yahoo:uri":"\/fantasy\/v2\/game\/328\/metadata","game":[{"game_key":"328","game_id":"328","name":"Baseball","code":"mlb","type":"full","url":"http:\/\/baseball.fantasysports.yahoo.com\/archive\/mlb\/2014","season":"2014","is_registration_over":1}],"time":"20.011901855469ms","copyright":"Data provided by Yahoo! and STATS, LLC","refresh_rate":"31"}}; | ||
exports.invalid = { statusCode: 400, data: '{"error":{"xml:lang":"en-us","yahoo:uri":"\\/fantasy\\/v2\\/game\\/MBL\\/metadata?format=json","description":"Invalid game key provided - mbl","detail":""}}' }; |
@@ -5,3 +5,3 @@ var YahooFantasy = require('../../index.js'); | ||
describe ("resource: gameResource", function(){ | ||
describe ("resource : gameResource", function(){ | ||
var yf = new YahooFantasy( | ||
@@ -45,80 +45,72 @@ 'Y!APPLICATION_KEY', | ||
// building urls | ||
beforeEach(function() { | ||
// deferred = q.defer(); | ||
spyOn(yf, "api").andCallThrough(); | ||
}); | ||
// meta | ||
it ("should build a proper url to retrieve metadata via a numeric game key", function() { | ||
// var callback = jasmine.createSpy('callback'); | ||
describe(": meta", function(){ | ||
var meta = require('../nock-data/gameMeta').meta; | ||
// nock('http://fantasysports.yahooapis.com') | ||
// .get("/fantasy/v2/game/328/metadata?format=json") | ||
// .reply(200, require('../nock-data/gameMeta.js').meta); | ||
var data = require('../nock-data/gameMeta.js').meta; | ||
deferred.resolve(data); | ||
// spyOn(yf, "api").andReturn(deferred.promise); | ||
spyOn(game.meta(328)).andReturn(deferred.promise); // callback); | ||
expect(yf.api) | ||
.toHaveBeenCalledWith("http://fantasysports.yahooapis.com/fantasy/v2/game/328/metadata?format=json"); | ||
expect(callback).toHaveBeenCalled(); | ||
}); | ||
it ("should build a proper url to retrieve metadata via a numeric game key", function(done) { | ||
nock('http://fantasysports.yahooapis.com') | ||
.get("/fantasy/v2/game/328/metadata?format=json") | ||
.reply(200, meta); | ||
it ("should build a proper url to retrieve metadata via a string game key", function() { | ||
nock('http://fantasysports.yahooapis.com') | ||
.get("/fantasy/v2/game/mlb/metadata?format=json") | ||
.reply(200, {}); | ||
game.meta(328, function(e, data) { | ||
expect(data).toEqual(meta.fantasy_content.game[0]); | ||
done(); | ||
}); | ||
}); | ||
game.meta('mlb', null); | ||
it ("should build a proper url to retrieve metadata via a string game key", function(done) { | ||
nock('http://fantasysports.yahooapis.com') | ||
.get("/fantasy/v2/game/mlb/metadata?format=json") | ||
.reply(200, meta); | ||
expect(yf.api) | ||
.toHaveBeenCalledWith("http://fantasysports.yahooapis.com/fantasy/v2/game/mlb/metadata?format=json"); | ||
game.meta('mlb', function(e, data) { | ||
expect(data).toEqual(meta.fantasy_content.game[0]); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
// leagues | ||
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); | ||
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); | ||
expect(yf.api) | ||
.toHaveBeenCalledWith("http://fantasysports.yahooapis.com/fantasy/v2/game/328/leagues;league_keys=328.l.34014?format=json"); | ||
}); | ||
expect(yf.api) | ||
.toHaveBeenCalledWith("http://fantasysports.yahooapis.com/fantasy/v2/game/328/leagues;league_keys=328.l.34014?format=json"); | ||
}); | ||
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("http://fantasysports.yahooapis.com/fantasy/v2/game/mlb/leagues;league_keys=mlb.l.34014?format=json"); | ||
}); | ||
expect(yf.api) | ||
.toHaveBeenCalledWith("http://fantasysports.yahooapis.com/fantasy/v2/game/mlb/leagues;league_keys=mlb.l.34014?format=json"); | ||
}); | ||
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("http://fantasysports.yahooapis.com/fantasy/v2/game/328/leagues;league_keys=328.l.34014?format=json"); | ||
}); | ||
expect(yf.api) | ||
.toHaveBeenCalledWith("http://fantasysports.yahooapis.com/fantasy/v2/game/328/leagues;league_keys=328.l.34014?format=json"); | ||
}); | ||
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("http://fantasysports.yahooapis.com/fantasy/v2/game/mlb/leagues;league_keys=mlb.l.34014?format=json"); | ||
}); | ||
expect(yf.api) | ||
.toHaveBeenCalledWith("http://fantasysports.yahooapis.com/fantasy/v2/game/mlb/leagues;league_keys=mlb.l.34014?format=json"); | ||
}); | ||
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("http://fantasysports.yahooapis.com/fantasy/v2/game/328/leagues;league_keys=328.l.34014,328.l.24281?format=json"); | ||
}); | ||
expect(yf.api) | ||
.toHaveBeenCalledWith("http://fantasysports.yahooapis.com/fantasy/v2/game/328/leagues;league_keys=328.l.34014,328.l.24281?format=json"); | ||
}); | ||
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("http://fantasysports.yahooapis.com/fantasy/v2/game/mlb/leagues;league_keys=mlb.l.34014,mlb.l.24281?format=json"); | ||
expect(yf.api) | ||
.toHaveBeenCalledWith("http://fantasysports.yahooapis.com/fantasy/v2/game/mlb/leagues;league_keys=mlb.l.34014,mlb.l.24281?format=json"); | ||
}); | ||
}); | ||
@@ -125,0 +117,0 @@ |
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
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
727515
75
5079
109
2
+ Addedjasmine@^2.4.1
+ Addedexit@0.1.2(transitive)
+ Addedglob@7.2.3(transitive)
+ Addedjasmine@2.99.0(transitive)
+ Addedjasmine-core@2.99.1(transitive)
- Removedjasmine-node@^1.14.5
- Removedcoffeescript@1.12.7(transitive)
- Removedgaze@1.1.3(transitive)
- Removedglob@7.1.7(transitive)
- Removedglobule@1.3.4(transitive)
- Removedgrowl@1.7.0(transitive)
- Removedjasmine-growl-reporter@0.2.1(transitive)
- Removedjasmine-node@1.16.2(transitive)
- Removedjasmine-reporters@1.0.2(transitive)
- Removedminimatch@3.0.8(transitive)
- Removedmkdirp@0.3.5(transitive)
- Removedrequirejs@2.3.7(transitive)
- Removedunderscore@1.9.2(transitive)
- Removedwalkdir@0.0.12(transitive)