Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

yahoo-fantasy

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yahoo-fantasy - npm Package Compare versions

Comparing version 3.0.4 to 3.1.0

helpers/argsParser.mjs

176

collections/transactionsCollection.js

@@ -10,6 +10,5 @@ var transactionHelper = require("../helpers/transactionHelper.js");

fetch(transactionKeys, resources, filters, cb) {
fetch(transactionKeys, resources, filters, cb = () => {}) {
var url =
"https://fantasysports.yahooapis.com/fantasy/v2/transactions;transaction_keys=",
apiCallback = this._fetch_callback.bind(this, cb);
"https://fantasysports.yahooapis.com/fantasy/v2/transactions;transaction_keys=";

@@ -38,16 +37,17 @@ if (_.isString(transactionKeys)) {

this.yf.api(this.yf.GET, url, (e, data) => {
if (e) {
return cb(e);
}
var meta = data.fantasy_content;
return cb(null, meta);
});
return this.yf.api(this.yf.GET, url)
.then(data => {
const meta = data.fantasy_content;
cb(null, meta);
return meta;
})
.catch(e => {
cb(e);
throw e;
});
}
leagueFetch = function(leagueKeys, resources, filters, cb) {
leagueFetch = function(leagueKeys, resources, filters, cb = () => {}) {
var url =
"https://fantasysports.yahooapis.com/fantasy/v2/leagues;league_keys=",
apiCallback = this._leagueFetch_callback.bind(this, cb);
"https://fantasysports.yahooapis.com/fantasy/v2/leagues;league_keys=";

@@ -77,13 +77,15 @@ if (_.isString(leagueKeys)) {

this.yf.api(this.yf.GET, url, (e, data) => {
if (e) {
return cb(e);
}
var meta = data.fantasy_content;
return cb(null, meta);
});
return this.yf.api(this.yf.GET, url)
.then(meta => {
const meta = data.fantasy_content;
cb(null, meta);
return meta;
})
.catch(e => {
cb(e);
throw e;
});
};
add_player = function(leagueKey, teamKey, playerKey, cb) {
add_player = function(leagueKey, teamKey, playerKey, cb = () => {}) {
var url =

@@ -93,3 +95,2 @@ "https://fantasysports.yahooapis.com/fantasy/v2/league/" +

"/transactions?format=json";
var apiCallback = this._add_player_callback.bind(this, cb);
var xmlData =

@@ -114,26 +115,27 @@ " \

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";
return this.yf.api(this.yf.POST, url, xmlData)
.then(data => {
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;
cb(null, meta);
return meta;
})
.catch(e => {
cb(e);
throw e;
});
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) {
drop_player = function(leagueKey, teamKey, playerKey, cb = () => {}) {
var url =

@@ -143,3 +145,2 @@ "https://fantasysports.yahooapis.com/fantasy/v2/league/" +

"/transactions?format=json";
var apiCallback = this._drop_player_callback.bind(this, cb);
var xmlData =

@@ -164,23 +165,25 @@ " \

this.yf.api(this.yf.POST, url, xmlData, (e, data) => {
if (e) {
return cb(e);
}
return this.yf.api(this.yf.POST, url, xmlData)
.then(data => {
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";
cb(null, meta);
return meta;
})
.catch(e => {
cb(e);
throw e;
});
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);
});
};

@@ -193,3 +196,3 @@

dropPlayerKey,
cb
cb = () => {}
) {

@@ -200,3 +203,2 @@ var url =

"/transactions?format=json";
var apiCallback = this._adddrop_players_callback.bind(this, cb);
var xmlData =

@@ -234,23 +236,25 @@ " \

this.yf.api(this.yf.POST, url, xmlData, (e, data) => {
if (e) {
return cb(e);
}
return this.yf.api(this.yf.POST, url, xmlData)
.then(data => {
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";
cb(null, meta);
return meta;
})
.catch(e => {
cb(e);
throw e;
});
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);
});
};

@@ -257,0 +261,0 @@ }

var _ = require('lodash');
var userHelper = require('../helpers/userHelper.js');
import { extractCallback } from "../helpers/argsParser.mjs";
module.exports = UsersCollection;

@@ -12,5 +14,4 @@

UsersCollection.prototype.fetch = function() {
var subresources = ( arguments.length > 1 ) ? arguments[0] : [],
cb = arguments[arguments.length - 1],
apiCallback = this._fetch_callback.bind(this, cb);
var subresources = ( arguments.length > 1 ) ? arguments[0] : [];
const cb = extractCallback(args);

@@ -29,16 +30,12 @@ var url = 'https://fantasysports.yahooapis.com/fantasy/v2/users;use_login=1';

this
.yf
.api(
this.yf.GET,
url,
apiCallback
);
};
UsersCollection.prototype._fetch_callback = function(cb, e, data) {
if ( e ) return cb(e);
var user = userHelper.parseCollection(data.fantasy_content.users[0].user);
return cb(user);
return this.yf.api(this.yf.GET, url)
.then(data => {
const user = userHelper.parseCollection(data.fantasy_content.users[0].user);
cb(null, user);
return user;
})
.catch(e => {
cb(e);
throw e;
});
};
{
"name": "yahoo-fantasy",
"version": "3.0.4",
"version": "3.1.0",
"description": "An API to help facilitate the use of the Yahoo! Fantasy Sports API in NodeJS projects.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -56,2 +56,6 @@ # Yahoo! Fantasy API Node Module

#### 3.1.0
- Introduced `promise` based flow for all endpoints as an alternative to callbacks. Thanks [Marois](https://github.com/ryus08)!
#### 3.0.4

@@ -58,0 +62,0 @@

@@ -49,2 +49,3 @@ import YahooFantasy from "../YahooFantasy.mjs";

.get("/fantasy/v2/game/328/metadata?format=json")
.times(2)
.reply(200, meta);

@@ -54,3 +55,7 @@

expect(data).toEqual(meta.fantasy_content.game[0]);
done();
game.meta(328)
.then(data => {
expect(data).toEqual(meta.fantasy_content.game[0]);
})
.then(done);
});

@@ -62,2 +67,3 @@ });

.get("/fantasy/v2/game/mlb/metadata?format=json")
.times(2)
.reply(200, meta);

@@ -67,3 +73,7 @@

expect(data).toEqual(meta.fantasy_content.game[0]);
done();
game.meta("mlb")
.then(data => {
expect(data).toEqual(meta.fantasy_content.game[0]);
})
.then(done);
});

@@ -79,59 +89,71 @@ });

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", () => {});
it("should build a proper url to retrieve league data for a single league using a numeric game key", function(done) {
nock("https://fantasysports.yahooapis.com")
.get("/fantasy/v2/game/328/leagues;league_keys=328.l.34014?format=json")
.reply(200, require("./nock-data/gameLeagues").league);
game.leagues(328, "328.l.34014", done);
expect(yf.api).toHaveBeenCalledWith(
"GET",
"https://fantasysports.yahooapis.com/fantasy/v2/game/328/leagues;league_keys=328.l.34014?format=json",
jasmine.any(Function)
"https://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", () => {});
it("should build a proper url to retrieve league data for a single league using a string game key", function(done) {
nock("https://fantasysports.yahooapis.com")
.get("/fantasy/v2/game/mlb/leagues;league_keys=mlb.l.34014?format=json")
.reply(200, require("./nock-data/gameLeagues").league);
game.leagues("mlb", "mlb.l.34014", done);
expect(yf.api).toHaveBeenCalledWith(
"GET",
"https://fantasysports.yahooapis.com/fantasy/v2/game/mlb/leagues;league_keys=mlb.l.34014?format=json",
jasmine.any(Function)
"https://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"], () => {});
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(done) {
nock("https://fantasysports.yahooapis.com")
.get("/fantasy/v2/game/328/leagues;league_keys=328.l.34014?format=json")
.reply(200, require("./nock-data/gameLeagues").league);
game.leagues(328, ["328.l.34014"], done);
expect(yf.api).toHaveBeenCalledWith(
"GET",
"https://fantasysports.yahooapis.com/fantasy/v2/game/328/leagues;league_keys=328.l.34014?format=json",
jasmine.any(Function)
"https://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"], () => {});
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(done) {
nock("https://fantasysports.yahooapis.com")
.get("/fantasy/v2/game/mlb/leagues;league_keys=mlb.l.34014?format=json")
.reply(200, require("./nock-data/gameLeagues").league);
game.leagues("mlb", ["mlb.l.34014"], done);
expect(yf.api).toHaveBeenCalledWith(
"GET",
"https://fantasysports.yahooapis.com/fantasy/v2/game/mlb/leagues;league_keys=mlb.l.34014?format=json",
jasmine.any(Function)
"https://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"], () => {});
it("should build a proper url to retrieve league data for a multiple leagues using a numeric game key", function(done) {
nock("https://fantasysports.yahooapis.com")
.get("/fantasy/v2/game/328/leagues;league_keys=328.l.34014,328.l.24281?format=json")
.reply(200, require("./nock-data/gameLeagues").multiple);
game.leagues(328, ["328.l.34014", "328.l.24281"], done);
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)
"https://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"], () => {});
it("should build a proper url to retrieve league data for a multiple leagues using a string game key", function(done) {
nock("https://fantasysports.yahooapis.com")
.get("/fantasy/v2/game/mlb/leagues;league_keys=mlb.l.34014,mlb.l.24281?format=json")
.reply(200, require("./nock-data/gameLeagues").multiple);
game.leagues("mlb", ["mlb.l.34014", "mlb.l.24281"], done);
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)
"https://fantasysports.yahooapis.com/fantasy/v2/game/mlb/leagues;league_keys=mlb.l.34014,mlb.l.24281?format=json"
);

@@ -142,59 +164,71 @@ });

// 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", () => {});
it("should build a proper url to retrieve player data for a single player using a numeric game key", function(done) {
nock("https://fantasysports.yahooapis.com")
.get("/fantasy/v2/game/328/players;player_keys=328.p.6619?format=json")
.reply(200, require("./nock-data/gamePlayers").players);
game.players(328, "328.p.6619", done);
expect(yf.api).toHaveBeenCalledWith(
"GET",
"https://fantasysports.yahooapis.com/fantasy/v2/game/328/players;player_keys=328.p.6619?format=json",
jasmine.any(Function)
"https://fantasysports.yahooapis.com/fantasy/v2/game/328/players;player_keys=328.p.6619?format=json"
);
});
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", () => {});
it("should build a proper url to retrieve player data for a single player using a string game key", function(done) {
nock("https://fantasysports.yahooapis.com")
.get("/fantasy/v2/game/mlb/players;player_keys=mlb.p.6619?format=json")
.reply(200, require("./nock-data/gamePlayers").players);
game.players("mlb", "mlb.p.6619", done);
expect(yf.api).toHaveBeenCalledWith(
"GET",
"https://fantasysports.yahooapis.com/fantasy/v2/game/mlb/players;player_keys=mlb.p.6619?format=json",
jasmine.any(Function)
"https://fantasysports.yahooapis.com/fantasy/v2/game/mlb/players;player_keys=mlb.p.6619?format=json"
);
});
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"], () => {});
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(done) {
nock("https://fantasysports.yahooapis.com")
.get("/fantasy/v2/game/328/players;player_keys=328.p.6619?format=json")
.reply(200, require("./nock-data/gamePlayers").players);
game.players(328, ["328.p.6619"], done);
expect(yf.api).toHaveBeenCalledWith(
"GET",
"https://fantasysports.yahooapis.com/fantasy/v2/game/328/players;player_keys=328.p.6619?format=json",
jasmine.any(Function)
"https://fantasysports.yahooapis.com/fantasy/v2/game/328/players;player_keys=328.p.6619?format=json"
);
});
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"], () => {});
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(done) {
nock("https://fantasysports.yahooapis.com")
.get("/fantasy/v2/game/mlb/players;player_keys=mlb.p.6619?format=json")
.reply(200, require("./nock-data/gamePlayers").players);
game.players("mlb", ["mlb.p.6619"], done);
expect(yf.api).toHaveBeenCalledWith(
"GET",
"https://fantasysports.yahooapis.com/fantasy/v2/game/mlb/players;player_keys=mlb.p.6619?format=json",
jasmine.any(Function)
"https://fantasysports.yahooapis.com/fantasy/v2/game/mlb/players;player_keys=mlb.p.6619?format=json"
);
});
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"], () => {});
it("should build a proper url to retrieve player data for a multiple players using a numeric game key", function(done) {
nock("https://fantasysports.yahooapis.com")
.get("/fantasy/v2/game/328/players;player_keys=328.p.6619,328.p.8172?format=json")
.reply(200, require("./nock-data/gamePlayers").multiple);
game.players(328, ["328.p.6619", "328.p.8172"], done);
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)
"https://fantasysports.yahooapis.com/fantasy/v2/game/328/players;player_keys=328.p.6619,328.p.8172?format=json"
);
});
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"], () => {});
it("should build a proper url to retrieve player data for a multiple players using a string game key", function(done) {
nock("https://fantasysports.yahooapis.com")
.get("/fantasy/v2/game/mlb/players;player_keys=mlb.p.6619,mlb.p.8172?format=json")
.reply(200, require("./nock-data/gamePlayers").multiple);
game.players("mlb", ["mlb.p.6619", "mlb.p.8172"], done);
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)
"https://fantasysports.yahooapis.com/fantasy/v2/game/mlb/players;player_keys=mlb.p.6619,mlb.p.8172?format=json"
);

@@ -204,19 +238,23 @@ });

// game_weeks
it("should build a proper url to retrieve game weeks using a numeric game key", function() {
game.game_weeks(328, () => {});
it("should build a proper url to retrieve game weeks using a numeric game key", function(done) {
nock("https://fantasysports.yahooapis.com")
.get("/fantasy/v2/game/328/game_weeks?format=json")
.reply(200, require("./nock-data/gameWeeks").weeks);
game.game_weeks(328, done);
expect(yf.api).toHaveBeenCalledWith(
"GET",
"https://fantasysports.yahooapis.com/fantasy/v2/game/328/game_weeks?format=json",
jasmine.any(Function)
"https://fantasysports.yahooapis.com/fantasy/v2/game/328/game_weeks?format=json"
);
});
it("should build a proper url to retrieve game weeks using a string game key", function() {
game.game_weeks("nfl", () => {});
it("should build a proper url to retrieve game weeks using a string game key", function(done) {
nock("https://fantasysports.yahooapis.com")
.get("/fantasy/v2/game/nfl/game_weeks?format=json")
.reply(200, require("./nock-data/gameWeeks").weeks);
game.game_weeks("nfl", done);
expect(yf.api).toHaveBeenCalledWith(
"GET",
"https://fantasysports.yahooapis.com/fantasy/v2/game/nfl/game_weeks?format=json",
jasmine.any(Function)
"https://fantasysports.yahooapis.com/fantasy/v2/game/nfl/game_weeks?format=json"
);

@@ -226,19 +264,23 @@ });

// stat_categories
it("should build a proper url to retrieve stat categories using a numeric game key", function() {
game.stat_categories(328, () => {});
it("should build a proper url to retrieve stat categories using a numeric game key", function(done) {
nock("https://fantasysports.yahooapis.com")
.get("/fantasy/v2/game/328/stat_categories?format=json")
.reply(200, require("./nock-data/gameStatCategories"));
game.stat_categories(328, done);
expect(yf.api).toHaveBeenCalledWith(
"GET",
"https://fantasysports.yahooapis.com/fantasy/v2/game/328/stat_categories?format=json",
jasmine.any(Function)
"https://fantasysports.yahooapis.com/fantasy/v2/game/328/stat_categories?format=json"
);
});
it("should build a proper url to retrieve stat categories using a string game key", function() {
game.stat_categories("nfl", () => {});
it("should build a proper url to retrieve stat categories using a string game key", function(done) {
nock("https://fantasysports.yahooapis.com")
.get("/fantasy/v2/game/nfl/stat_categories?format=json")
.reply(200, require("./nock-data/gameStatCategories"));
game.stat_categories("nfl", done);
expect(yf.api).toHaveBeenCalledWith(
"GET",
"https://fantasysports.yahooapis.com/fantasy/v2/game/nfl/stat_categories?format=json",
jasmine.any(Function)
"https://fantasysports.yahooapis.com/fantasy/v2/game/nfl/stat_categories?format=json"
);

@@ -248,19 +290,23 @@ });

// position_types
it("should build a proper url to retrieve position types using a numeric game key", function() {
game.position_types(328, () => {});
it("should build a proper url to retrieve position types using a numeric game key", function(done) {
nock("https://fantasysports.yahooapis.com")
.get("/fantasy/v2/game/328/position_types?format=json")
.reply(200, require("./nock-data/gamePositionTypes"));
game.position_types(328, done);
expect(yf.api).toHaveBeenCalledWith(
"GET",
"https://fantasysports.yahooapis.com/fantasy/v2/game/328/position_types?format=json",
jasmine.any(Function)
"https://fantasysports.yahooapis.com/fantasy/v2/game/328/position_types?format=json"
);
});
it("should build a proper url to retrieve position types using a string game key", function() {
game.position_types("nfl", () => {});
it("should build a proper url to retrieve position types using a string game key", function(done) {
nock("https://fantasysports.yahooapis.com")
.get("/fantasy/v2/game/nfl/position_types?format=json")
.reply(200, require("./nock-data/gamePositionTypes"));
game.position_types("nfl", done);
expect(yf.api).toHaveBeenCalledWith(
"GET",
"https://fantasysports.yahooapis.com/fantasy/v2/game/nfl/position_types?format=json",
jasmine.any(Function)
"https://fantasysports.yahooapis.com/fantasy/v2/game/nfl/position_types?format=json"
);

@@ -270,21 +316,25 @@ });

// roster_positions
it("should build a proper url to retrieve roster positions using a numeric game key", function() {
game.roster_positions(328, () => {});
it("should build a proper url to retrieve roster positions using a numeric game key", function(done) {
nock("https://fantasysports.yahooapis.com")
.get("/fantasy/v2/game/328/roster_positions?format=json")
.reply(200, require("./nock-data/gameRosterPositions"));
game.roster_positions(328, done);
expect(yf.api).toHaveBeenCalledWith(
"GET",
"https://fantasysports.yahooapis.com/fantasy/v2/game/328/roster_positions?format=json",
jasmine.any(Function)
"https://fantasysports.yahooapis.com/fantasy/v2/game/328/roster_positions?format=json"
);
});
it("should build a proper url to retrieve roster positions using a string game key", function() {
game.roster_positions("nfl", () => {});
it("should build a proper url to retrieve roster positions using a string game key", function(done) {
nock("https://fantasysports.yahooapis.com")
.get("/fantasy/v2/game/nfl/roster_positions?format=json")
.reply(200, require("./nock-data/gameRosterPositions"));
game.roster_positions("nfl", done);
expect(yf.api).toHaveBeenCalledWith(
"GET",
"https://fantasysports.yahooapis.com/fantasy/v2/game/nfl/roster_positions?format=json",
jasmine.any(Function)
"https://fantasysports.yahooapis.com/fantasy/v2/game/nfl/roster_positions?format=json"
);
});
});

@@ -31,12 +31,15 @@ import YahooFantasy from "../YahooFantasy.mjs";

// fetch
it("should build a proper url to retrieve metadata via a numeric game key", function() {
nock("http://fantasysports.yahooapis.com")
.get("/fantasy/v2/game/328/metadata?format=json")
.reply(200, {});
it("should build a proper url to retrieve metadata via a numeric game key", function(done) {
nock("https://fantasysports.yahooapis.com")
.get("/fantasy/v2/games?format=json")
.reply(200, { fantasy_content: { games: [] } });
games.fetch(328, () => {});
games.fetch(328, done);
// expect(yf.api)
// .toHaveBeenCalledWith("http://fantasysports.yahooapis.com/fantasy/v2/game/328/metadata?format=json");
expect(yf.api).toHaveBeenCalledWith(
"GET",
"https://fantasysports.yahooapis.com/fantasy/v2/games?format=json"
);
});
});

@@ -51,3 +51,3 @@ import YahooFantasy from "../YahooFantasy.mjs";

// meta
it("should build a proper url to retrieve metadata via a league key", function() {
it("should build a proper url to retrieve metadata via a league key", function(done) {
nock("https://fantasysports.yahooapis.com")

@@ -57,8 +57,7 @@ .get("/fantasy/v2/league/328.l.34014/metadata?format=json")

league.meta("328.l.34014", () => {});
league.meta("328.l.34014", done);
expect(yf.api).toHaveBeenCalledWith(
"GET",
"https://fantasysports.yahooapis.com/fantasy/v2/league/328.l.34014/metadata?format=json",
jasmine.any(Function)
"https://fantasysports.yahooapis.com/fantasy/v2/league/328.l.34014/metadata?format=json"
);

@@ -68,3 +67,3 @@ });

// settings
it("should build a proper url to retrieve settings via a league key", function() {
it("should build a proper url to retrieve settings via a league key", function(done) {
nock("https://fantasysports.yahooapis.com")

@@ -74,8 +73,7 @@ .get("/fantasy/v2/league/328.l.34014/settings?format=json")

league.settings("328.l.34014", () => {});
league.settings("328.l.34014", done);
expect(yf.api).toHaveBeenCalledWith(
"GET",
"https://fantasysports.yahooapis.com/fantasy/v2/league/328.l.34014/settings?format=json",
jasmine.any(Function)
"https://fantasysports.yahooapis.com/fantasy/v2/league/328.l.34014/settings?format=json"
);

@@ -85,3 +83,3 @@ });

// standings
it("should build a proper url to retrieve standings via a league key", function() {
it("should build a proper url to retrieve standings via a league key", function(done) {
nock("https://fantasysports.yahooapis.com")

@@ -91,8 +89,7 @@ .get("/fantasy/v2/league/328.l.34014/standings?format=json")

league.standings("328.l.34014", () => {});
league.standings("328.l.34014", done);
expect(yf.api).toHaveBeenCalledWith(
"GET",
"https://fantasysports.yahooapis.com/fantasy/v2/league/328.l.34014/standings?format=json",
jasmine.any(Function)
"https://fantasysports.yahooapis.com/fantasy/v2/league/328.l.34014/standings?format=json"
);

@@ -102,3 +99,3 @@ });

// scoreboard
it("should build a proper url to retrieve scoreboard via a league key", function() {
it("should build a proper url to retrieve scoreboard via a league key", function(done) {
nock("https://fantasysports.yahooapis.com")

@@ -108,8 +105,7 @@ .get("/fantasy/v2/league/328.l.34014/scoreboard?format=json")

league.scoreboard("328.l.34014", () => {});
league.scoreboard("328.l.34014", done);
expect(yf.api).toHaveBeenCalledWith(
"GET",
"https://fantasysports.yahooapis.com/fantasy/v2/league/328.l.34014/scoreboard?format=json",
jasmine.any(Function)
"https://fantasysports.yahooapis.com/fantasy/v2/league/328.l.34014/scoreboard?format=json"
);

@@ -119,3 +115,3 @@ });

// teams
it("should build a proper url to retrieve teams via a league key", function() {
it("should build a proper url to retrieve teams via a league key", function(done) {
nock("https://fantasysports.yahooapis.com")

@@ -125,8 +121,7 @@ .get("/fantasy/v2/league/328.l.34014/teams?format=json")

league.teams("328.l.34014", () => {});
league.teams("328.l.34014", done);
expect(yf.api).toHaveBeenCalledWith(
"GET",
"https://fantasysports.yahooapis.com/fantasy/v2/league/328.l.34014/teams?format=json",
jasmine.any(Function)
"https://fantasysports.yahooapis.com/fantasy/v2/league/328.l.34014/teams?format=json"
);

@@ -136,3 +131,3 @@ });

// // players
// it("should build a proper url to retrieve players via a league key", function() {
// it("should build a proper url to retrieve players via a league key", function(done) {
// nock("https://fantasysports.yahooapis.com")

@@ -142,8 +137,7 @@ // .get("/fantasy/v2/league/328.l.34014/players?format=json")

// league.players("328.l.34014", () => {});
// league.players("328.l.34014", done);
// expect(yf.api).toHaveBeenCalledWith(
// "GET",
// "https://fantasysports.yahooapis.com/fantasy/v2/league/328.l.34014/players?format=json",
// jasmine.any(Function)
// "https://fantasysports.yahooapis.com/fantasy/v2/league/328.l.34014/players?format=json"
// );

@@ -153,13 +147,12 @@ // });

// draft_results
it("should build a proper url to retrieve draft_results via a league key", function() {
it("should build a proper url to retrieve draft_results via a league key", function(done) {
nock("https://fantasysports.yahooapis.com")
.get("/fantasy/v2/league/328.l.34014/draft_results?format=json")
.get("/fantasy/v2/league/328.l.34014/draftresults?format=json")
.reply(200, require("./nock-data/leagueDraftResults"));
league.draft_results("328.l.34014", () => {});
league.draft_results("328.l.34014", done);
expect(yf.api).toHaveBeenCalledWith(
"GET",
"https://fantasysports.yahooapis.com/fantasy/v2/league/328.l.34014/draftresults?format=json",
jasmine.any(Function)
"https://fantasysports.yahooapis.com/fantasy/v2/league/328.l.34014/draftresults?format=json"
);

@@ -169,3 +162,3 @@ });

// transactions
it("should build a proper url to retrieve transactions via a league key", function() {
it("should build a proper url to retrieve transactions via a league key", function(done) {
nock("https://fantasysports.yahooapis.com")

@@ -175,10 +168,9 @@ .get("/fantasy/v2/league/328.l.34014/transactions?format=json")

league.transactions("328.l.34014", () => {});
league.transactions("328.l.34014", done);
expect(yf.api).toHaveBeenCalledWith(
"GET",
"https://fantasysports.yahooapis.com/fantasy/v2/league/328.l.34014/transactions?format=json",
jasmine.any(Function)
"https://fantasysports.yahooapis.com/fantasy/v2/league/328.l.34014/transactions?format=json"
);
});
});

@@ -43,3 +43,3 @@ var YahooFantasy = require("../index.js");

// meta
it("should build a proper url to retrieve metadata via a player key", function() {
it("should build a proper url to retrieve metadata via a player key", function(done) {
nock("https://fantasysports.yahooapis.com")

@@ -49,8 +49,7 @@ .get("/fantasy/v2/player/328.p.6619/metadata?format=json")

player.meta("328.p.6619", () => {});
player.meta("328.p.6619", done);
expect(yf.api).toHaveBeenCalledWith(
"GET",
"https://fantasysports.yahooapis.com/fantasy/v2/player/328.p.6619/metadata?format=json",
jasmine.any(Function)
"https://fantasysports.yahooapis.com/fantasy/v2/player/328.p.6619/metadata?format=json"
);

@@ -60,13 +59,22 @@ });

// stats
it("should build a proper url to retrieve player stats via a player key", function() {
it("should build a proper url to retrieve player stats via a player key", function(done) {
var mockPlayerStats = require("./nock-data/playerStats");
nock("https://fantasysports.yahooapis.com")
.get("/fantasy/v2/player/328.p.6619/stats?format=json")
.reply(200, require("./nock-data/playerStats"));
.times(2)
.reply(200, mockPlayerStats);
player.stats("328.p.6619", () => {});
player.stats("328.p.6619", function(e, data) {
expect(data.stats.coverage_type).toEqual(mockPlayerStats.fantasy_content.player[1].player_stats[0].coverage_type);
player.stats("328.p.6619")
.then(data => {
expect(data.stats.coverage_type).toEqual(mockPlayerStats.fantasy_content.player[1].player_stats[0].coverage_type);
})
.then(done)
.catch(done);
});
expect(yf.api).toHaveBeenCalledWith(
"GET",
"https://fantasysports.yahooapis.com/fantasy/v2/player/328.p.6619/stats?format=json",
jasmine.any(Function)
"https://fantasysports.yahooapis.com/fantasy/v2/player/328.p.6619/stats?format=json"
);

@@ -76,3 +84,3 @@ });

// percent_owned
it("should build a proper url to retrieve player ownership percentage via a player key", function() {
it("should build a proper url to retrieve player ownership percentage via a player key", function(done) {
nock("https://fantasysports.yahooapis.com")

@@ -82,8 +90,7 @@ .get("/fantasy/v2/player/328.p.6619/percent_owned?format=json")

player.percent_owned("328.p.6619", () => {});
player.percent_owned("328.p.6619", done);
expect(yf.api).toHaveBeenCalledWith(
"GET",
"https://fantasysports.yahooapis.com/fantasy/v2/player/328.p.6619/percent_owned?format=json",
jasmine.any(Function)
"https://fantasysports.yahooapis.com/fantasy/v2/player/328.p.6619/percent_owned?format=json"
);

@@ -93,3 +100,3 @@ });

// ownership
it("should build a proper url to retrieve player ownership in a given league via a player key and a league key", function() {
it("should build a proper url to retrieve player ownership in a given league via a player key and a league key", function(done) {
nock("https://fantasysports.yahooapis.com")

@@ -101,8 +108,7 @@ .get(

player.ownership("328.p.6619", "328.l.34014", () => {});
player.ownership("328.p.6619", "328.l.34014", done);
expect(yf.api).toHaveBeenCalledWith(
"GET",
"https://fantasysports.yahooapis.com/fantasy/v2/league/328.l.34014/players;player_keys=328.p.6619/ownership?format=json",
jasmine.any(Function)
"https://fantasysports.yahooapis.com/fantasy/v2/league/328.l.34014/players;player_keys=328.p.6619/ownership?format=json"
);

@@ -114,15 +120,14 @@ });

// draft_analysis
it("should build a proper url to retrieve player draft analysis via a player key", function() {
it("should build a proper url to retrieve player draft analysis via a player key", function(done) {
nock("https://fantasysports.yahooapis.com")
.get("/fantasy/v2/player/328.p.6619/teams?format=json")
.get("/fantasy/v2/player/328.p.6619/draft_analysis?format=json")
.reply(200, require("./nock-data/playerDraftAnalysis"));
player.draft_analysis("328.p.6619", () => {});
player.draft_analysis("328.p.6619", done);
expect(yf.api).toHaveBeenCalledWith(
"GET",
"https://fantasysports.yahooapis.com/fantasy/v2/player/328.p.6619/draft_analysis?format=json",
jasmine.any(Function)
"https://fantasysports.yahooapis.com/fantasy/v2/player/328.p.6619/draft_analysis?format=json"
);
});
});

@@ -23,15 +23,14 @@ var YahooFantasy = require("../index.js");

// meta
it("should build a proper url to retrieve players on a team", function() {
it("should build a proper url to retrieve players on a team", function(done) {
nock("https://fantasysports.yahooapis.com")
.get("/fantasy/v2/team/328.l.34014.t.1/roster/players?format=json")
.reply(200, {});
.get("/fantasy/v2/team/328.l.34014.t.1/roster?format=json")
.reply(200, require("./nock-data/teamRoster"));
roster.players("328.l.34014.t.1", () => {});
roster.players("328.l.34014.t.1", done);
expect(yf.api).toHaveBeenCalledWith(
"GET",
"https://fantasysports.yahooapis.com/fantasy/v2/team/328.l.34014.t.1/roster?format=json",
jasmine.any(Function)
"https://fantasysports.yahooapis.com/fantasy/v2/team/328.l.34014.t.1/roster?format=json"
);
});
});

@@ -43,3 +43,3 @@ var YahooFantasy = require("../index.js");

// meta
it("should build a proper url to retrieve metadata via a team key", function() {
it("should build a proper url to retrieve metadata via a team key", function(done) {
nock("https://fantasysports.yahooapis.com")

@@ -49,8 +49,7 @@ .get("/fantasy/v2/team/328.l.34014.t.1/metadata?format=json")

team.meta("328.l.34014.t.1", () => {});
team.meta("328.l.34014.t.1", done);
expect(yf.api).toHaveBeenCalledWith(
"GET",
"https://fantasysports.yahooapis.com/fantasy/v2/team/328.l.34014.t.1/metadata?format=json",
jasmine.any(Function)
"https://fantasysports.yahooapis.com/fantasy/v2/team/328.l.34014.t.1/metadata?format=json"
);

@@ -60,3 +59,3 @@ });

// stats
it("should build a proper url to retrieve team stats via a team key", function() {
it("should build a proper url to retrieve team stats via a team key", function(done) {
nock("https://fantasysports.yahooapis.com")

@@ -66,8 +65,7 @@ .get("/fantasy/v2/team/328.l.34014.t.1/stats?format=json")

team.stats("328.l.34014.t.1", () => {});
team.stats("328.l.34014.t.1", done);
expect(yf.api).toHaveBeenCalledWith(
"GET",
"https://fantasysports.yahooapis.com/fantasy/v2/team/328.l.34014.t.1/stats?format=json",
jasmine.any(Function)
"https://fantasysports.yahooapis.com/fantasy/v2/team/328.l.34014.t.1/stats?format=json"
);

@@ -77,3 +75,3 @@ });

// standings
it("should build a proper url to retrieve team standings via a team key", function() {
it("should build a proper url to retrieve team standings via a team key", function(done) {
nock("https://fantasysports.yahooapis.com")

@@ -83,8 +81,7 @@ .get("/fantasy/v2/team/328.l.34014.t.1/standings?format=json")

team.standings("328.l.34014.t.1", () => {});
team.standings("328.l.34014.t.1", done);
expect(yf.api).toHaveBeenCalledWith(
"GET",
"https://fantasysports.yahooapis.com/fantasy/v2/team/328.l.34014.t.1/standings?format=json",
jasmine.any(Function)
"https://fantasysports.yahooapis.com/fantasy/v2/team/328.l.34014.t.1/standings?format=json"
);

@@ -94,3 +91,3 @@ });

// roster
it("should build a proper url to retrieve team ownership in a given league via a team key and a league key", function() {
it("should build a proper url to retrieve team ownership in a given league via a team key and a league key", function(done) {
nock("https://fantasysports.yahooapis.com")

@@ -100,8 +97,7 @@ .get("/fantasy/v2/team/328.l.34014.t.1/roster?format=json")

team.roster("328.l.34014.t.1", () => {});
team.roster("328.l.34014.t.1", done);
expect(yf.api).toHaveBeenCalledWith(
"GET",
"https://fantasysports.yahooapis.com/fantasy/v2/team/328.l.34014.t.1/roster?format=json",
jasmine.any(Function)
"https://fantasysports.yahooapis.com/fantasy/v2/team/328.l.34014.t.1/roster?format=json"
);

@@ -111,3 +107,3 @@ });

// draft_results
it("should build a proper url to retrieve team draft analysis via a team key", function() {
it("should build a proper url to retrieve team draft analysis via a team key", function(done) {
nock("https://fantasysports.yahooapis.com")

@@ -117,8 +113,7 @@ .get("/fantasy/v2/team/328.l.34014.t.1/draftresults?format=json")

team.draft_results("328.l.34014.t.1", () => {});
team.draft_results("328.l.34014.t.1", done);
expect(yf.api).toHaveBeenCalledWith(
"GET",
"https://fantasysports.yahooapis.com/fantasy/v2/team/328.l.34014.t.1/draftresults?format=json",
jasmine.any(Function)
"https://fantasysports.yahooapis.com/fantasy/v2/team/328.l.34014.t.1/draftresults?format=json"
);

@@ -128,3 +123,3 @@ });

// matchups
it("should build a proper url to retrieve team draft analysis via a team key", function() {
it("should build a proper url to retrieve team draft analysis via a team key", function(done) {
nock("https://fantasysports.yahooapis.com")

@@ -134,10 +129,9 @@ .get("/fantasy/v2/team/328.l.34014.t.1/matchups?format=json")

team.matchups("328.l.34014.t.1", () => {});
team.matchups("328.l.34014.t.1", done);
expect(yf.api).toHaveBeenCalledWith(
"GET",
"https://fantasysports.yahooapis.com/fantasy/v2/team/328.l.34014.t.1/matchups?format=json",
jasmine.any(Function)
"https://fantasysports.yahooapis.com/fantasy/v2/team/328.l.34014.t.1/matchups?format=json"
);
});
});

@@ -27,3 +27,3 @@ var YahooFantasy = require("../index.js");

// meta
it("should build a proper url to retrieve metadata via a transaction key", function() {
it("should build a proper url to retrieve metadata via a transaction key", function(done) {
nock("https://fantasysports.yahooapis.com")

@@ -33,8 +33,7 @@ .get("/fantasy/v2/transaction/328.l.34014.tr.237/players?format=json")

transaction.meta("328.l.34014.tr.237", () => {});
transaction.meta("328.l.34014.tr.237", done);
expect(yf.api).toHaveBeenCalledWith(
"GET",
"https://fantasysports.yahooapis.com/fantasy/v2/transaction/328.l.34014.tr.237/players?format=json",
jasmine.any(Function)
"https://fantasysports.yahooapis.com/fantasy/v2/transaction/328.l.34014.tr.237/players?format=json"
);

@@ -44,3 +43,3 @@ });

// players
it("should build a proper url to retrieve player info via a transaction key", function() {
it("should build a proper url to retrieve player info via a transaction key", function(done) {
nock("https://fantasysports.yahooapis.com")

@@ -50,10 +49,9 @@ .get("/fantasy/v2/transaction/328.l.34014.tr.237/players?format=json")

transaction.players("328.l.34014.tr.237", () => {});
transaction.players("328.l.34014.tr.237", done);
expect(yf.api).toHaveBeenCalledWith(
"GET",
"https://fantasysports.yahooapis.com/fantasy/v2/transaction/328.l.34014.tr.237/players?format=json",
jasmine.any(Function)
"https://fantasysports.yahooapis.com/fantasy/v2/transaction/328.l.34014.tr.237/players?format=json"
);
});
});

@@ -31,3 +31,3 @@ var YahooFantasy = require("../index.js");

// games
it("should build a proper url to retrieve games a user has played and is playing", function() {
it("should build a proper url to retrieve games a user has played and is playing", function(done) {
nock("https://fantasysports.yahooapis.com")

@@ -37,8 +37,7 @@ .get("/fantasy/v2/users;use_login=1/games?format=json")

user.games(() => {});
user.games(done);
expect(yf.api).toHaveBeenCalledWith(
"GET",
"https://fantasysports.yahooapis.com/fantasy/v2/users;use_login=1/games?format=json",
jasmine.any(Function)
"https://fantasysports.yahooapis.com/fantasy/v2/users;use_login=1/games?format=json"
);

@@ -48,3 +47,3 @@ });

// game_leagues
it("should build a proper url to retrieve leagues a user plays in for a given game", function() {
it("should build a proper url to retrieve leagues a user plays in for a given game", function(done) {
nock("https://fantasysports.yahooapis.com")

@@ -56,12 +55,11 @@ .get(

user.game_leagues("328", () => {});
user.game_leagues("328", done);
expect(yf.api).toHaveBeenCalledWith(
"GET",
"https://fantasysports.yahooapis.com/fantasy/v2/users;use_login=1/games;game_keys=328/leagues?format=json",
jasmine.any(Function)
"https://fantasysports.yahooapis.com/fantasy/v2/users;use_login=1/games;game_keys=328/leagues?format=json"
);
});
it("should build a proper url to retrieve leagues a user plays in for given games", function() {
it("should build a proper url to retrieve leagues a user plays in for given games", function(done) {
nock("https://fantasysports.yahooapis.com")

@@ -73,8 +71,7 @@ .get(

user.game_leagues(["328", "242"], () => {});
user.game_leagues(["328", "242"], done);
expect(yf.api).toHaveBeenCalledWith(
"GET",
"https://fantasysports.yahooapis.com/fantasy/v2/users;use_login=1/games;game_keys=328,242/leagues?format=json",
jasmine.any(Function)
"https://fantasysports.yahooapis.com/fantasy/v2/users;use_login=1/games;game_keys=328,242/leagues?format=json"
);

@@ -84,3 +81,3 @@ });

// game_teams
it("should build a proper url to retrieve teams a user owns in for a given game", function() {
it("should build a proper url to retrieve teams a user owns in for a given game", function(done) {
nock("https://fantasysports.yahooapis.com")

@@ -92,12 +89,12 @@ .get(

user.game_teams("328", () => {});
user.game_teams("328", done);
expect(yf.api).toHaveBeenCalledWith(
"GET",
"https://fantasysports.yahooapis.com/fantasy/v2/users;use_login=1/games;game_keys=328/teams?format=json",
jasmine.any(Function)
"https://fantasysports.yahooapis.com/fantasy/v2/users;use_login=1/games;game_keys=328/teams?format=json"
);
});
it("should build a proper url to retrieve teams a user owns in for given games", function() {
it("should build a proper url to retrieve teams a user owns in for given games", function(done) {
nock("https://fantasysports.yahooapis.com")

@@ -109,10 +106,9 @@ .get(

user.game_teams(["328", "242"], () => {});
user.game_teams(["328", "242"], done);
expect(yf.api).toHaveBeenCalledWith(
"GET",
"https://fantasysports.yahooapis.com/fantasy/v2/users;use_login=1/games;game_keys=328,242/teams?format=json",
jasmine.any(Function)
"https://fantasysports.yahooapis.com/fantasy/v2/users;use_login=1/games;game_keys=328,242/teams?format=json"
);
});
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc