yahoo-fantasy
Advanced tools
Comparing version 3.1.2 to 3.2.0
@@ -1,2 +0,3 @@ | ||
var transactionHelper = require("../helpers/transactionHelper.js"); | ||
const transactionHelper = require("../helpers/transactionHelper.js"); | ||
const isEmpty = require("../helpers/isEmpty.js"); | ||
@@ -11,6 +12,6 @@ // TODO: https://fantasysports.yahooapis.com/fantasy/v2/league/{league_key}/transactions;types=waiver,pending_trade;team_key={team_key} | ||
fetch(transactionKeys, resources, filters, cb = () => {}) { | ||
var url = | ||
"https://fantasysports.yahooapis.com/fantasy/v2/transactions;transaction_keys="; | ||
let url = | ||
"https://fantasysports.yahooapis.com/fantasy/v2/transactions;transaction_keys="; | ||
if (_.isString(transactionKeys)) { | ||
if ("string" === typeof transactionKeys) { | ||
transactionKeys = [transactionKeys]; | ||
@@ -21,4 +22,4 @@ } | ||
if (!_.isEmpty(resources)) { | ||
if (_.isString(resources)) { | ||
if (!isEmpty(resources)) { | ||
if ("string" === typeof resources) { | ||
resources = [resources]; | ||
@@ -30,4 +31,4 @@ } | ||
if (!_.isEmpty(filters)) { | ||
_.each(Object.keys(filters), function(key) { | ||
if (!isEmpty(filters)) { | ||
Object.keys(filters).forEach(function(key) { | ||
url += ";" + key + "=" + filters[key]; | ||
@@ -39,9 +40,10 @@ }); | ||
return this.yf.api(this.yf.GET, url) | ||
return this.yf | ||
.api(this.yf.GET, url) | ||
.then(data => { | ||
const meta = data.fantasy_content; | ||
cb(null, meta); | ||
return meta; | ||
cb(null, meta); | ||
return meta; | ||
}) | ||
.catch(e => { | ||
.catch(e => { | ||
cb(e); | ||
@@ -53,6 +55,6 @@ throw e; | ||
leagueFetch = function(leagueKeys, resources, filters, cb = () => {}) { | ||
var url = | ||
"https://fantasysports.yahooapis.com/fantasy/v2/leagues;league_keys="; | ||
let url = | ||
"https://fantasysports.yahooapis.com/fantasy/v2/leagues;league_keys="; | ||
if (_.isString(leagueKeys)) { | ||
if ("string" === typeof leagueKeys) { | ||
leagueKeys = [leagueKeys]; | ||
@@ -64,4 +66,4 @@ } | ||
if (!_.isEmpty(resources)) { | ||
if (_.isString(resources)) { | ||
if (!isEmpty(resources)) { | ||
if ("string" === typeof resources) { | ||
resources = [resources]; | ||
@@ -73,4 +75,4 @@ } | ||
if (!_.isEmpty(filters)) { | ||
_.each(Object.keys(filters), function(key) { | ||
if (!isEmpty(filters)) { | ||
Object.keys(filters).forEach(function(key) { | ||
url += ";" + key + "=" + filters[key]; | ||
@@ -82,9 +84,10 @@ }); | ||
return this.yf.api(this.yf.GET, url) | ||
return this.yf | ||
.api(this.yf.GET, url) | ||
.then(meta => { | ||
const meta = data.fantasy_content; | ||
cb(null, meta); | ||
return meta; | ||
cb(null, meta); | ||
return meta; | ||
}) | ||
.catch(e => { | ||
.catch(e => { | ||
cb(e); | ||
@@ -96,8 +99,5 @@ throw e; | ||
add_player = function(leagueKey, teamKey, playerKey, cb = () => {}) { | ||
var url = | ||
"https://fantasysports.yahooapis.com/fantasy/v2/league/" + | ||
leagueKey + | ||
"/transactions?format=json"; | ||
var xmlData = | ||
" \ | ||
const url = `https://fantasysports.yahooapis.com/fantasy/v2/league/${leagueKey}/transactions?format=json`; | ||
const xmlData = ` \ | ||
<fantasy_content> \ | ||
@@ -107,29 +107,24 @@ <transaction> \ | ||
<player> \ | ||
<player_key>" + | ||
playerKey + | ||
"</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>"; | ||
</fantasy_content>`; | ||
return this.yf.api(this.yf.POST, url, xmlData) | ||
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( | ||
const transactions = data.fantasy_content.league[1].transactions | ||
.filter(p => typeof p === "object") | ||
.map(({ transaction }) => transaction); | ||
const transaction = transactions[0]; | ||
const meta = transaction[0]; | ||
const players = transactionHelper.mapTransactionPlayers( | ||
transaction[1].players | ||
); | ||
meta.players = players; | ||
@@ -139,3 +134,3 @@ cb(null, meta); | ||
}) | ||
.catch(e => { | ||
.catch(e => { | ||
cb(e); | ||
@@ -147,8 +142,4 @@ throw e; | ||
drop_player = function(leagueKey, teamKey, playerKey, cb = () => {}) { | ||
var url = | ||
"https://fantasysports.yahooapis.com/fantasy/v2/league/" + | ||
leagueKey + | ||
"/transactions?format=json"; | ||
var xmlData = | ||
" \ | ||
const url = `https://fantasysports.yahooapis.com/fantasy/v2/league/${leagueKey}/transactions?format=json`; | ||
const xmlData = ` \ | ||
<fantasy_content> \ | ||
@@ -158,27 +149,21 @@ <transaction> \ | ||
<player> \ | ||
<player_key>" + | ||
playerKey + | ||
"</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> \ | ||
</transaction> \ | ||
</fantasy_content>"; | ||
</fantasy_content>`; | ||
return this.yf.api(this.yf.POST, url, xmlData) | ||
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( | ||
const transactions = data.fantasy_content.league[1].transactions | ||
.filter(p => typeof p === "object") | ||
.map(({ transaction }) => transaction); | ||
const transaction = transactions[0]; | ||
const meta = transaction[0]; | ||
const players = transactionHelper.mapTransactionPlayers( | ||
transaction[1].players | ||
@@ -204,8 +189,4 @@ ); | ||
) { | ||
var url = | ||
"https://fantasysports.yahooapis.com/fantasy/v2/league/" + | ||
leagueKey + | ||
"/transactions?format=json"; | ||
var xmlData = | ||
" \ | ||
const url = `https://fantasysports.yahooapis.com/fantasy/v2/league/${leagueKey}/transactions?format=json`; | ||
const xmlData = ` \ | ||
<fantasy_content> \ | ||
@@ -216,21 +197,13 @@ <transaction> \ | ||
<player> \ | ||
<player_key>" + | ||
addPlayerKey + | ||
"</player_key> \ | ||
<player_key>${addPlayerKey}</player_key> \ | ||
<transaction_data> \ | ||
<type>add</type> \ | ||
<destination_team_key>" + | ||
teamKey + | ||
"</destination_team_key> \ | ||
<destination_team_key>${teamKey}</destination_team_key> \ | ||
</transaction_data> \ | ||
</player> \ | ||
<player> \ | ||
<player_key>" + | ||
dropPlayerKey + | ||
"</player_key> \ | ||
<player_key>${dropPlayerKey}</player_key> \ | ||
<transaction_data> \ | ||
<type>drop</type> \ | ||
<source_team_key>" + | ||
teamKey + | ||
"</source_team_key> \ | ||
<source_team_key>${teamKey}</source_team_key> \ | ||
</transaction_data> \ | ||
@@ -240,16 +213,13 @@ </player> \ | ||
</transaction> \ | ||
</fantasy_content>"; | ||
</fantasy_content>`; | ||
return this.yf.api(this.yf.POST, url, xmlData) | ||
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( | ||
const transactions = data.fantasy_content.league[1].transactions | ||
.filter(p => typeof p === "object") | ||
.map(({ transaction }) => transaction); | ||
const transaction = transactions[0]; | ||
const meta = transaction[0]; | ||
const players = transactionHelper.mapTransactionPlayers( | ||
transaction[1].players | ||
@@ -256,0 +226,0 @@ ); |
@@ -1,3 +0,3 @@ | ||
var _ = require('lodash'); | ||
var userHelper = require('../helpers/userHelper.js'); | ||
const userHelper = require("../helpers/userHelper.js"); | ||
const isEmpty = require("../helpers/isEmpty.js"); | ||
@@ -14,20 +14,24 @@ import { extractCallback } from "../helpers/argsParser.mjs"; | ||
UsersCollection.prototype.fetch = function() { | ||
var subresources = ( arguments.length > 1 ) ? arguments[0] : []; | ||
const cb = extractCallback(args); | ||
let subresources = arguments.length ? arguments[0] : []; | ||
var url = 'https://fantasysports.yahooapis.com/fantasy/v2/users;use_login=1'; | ||
let url = "https://fantasysports.yahooapis.com/fantasy/v2/users;use_login=1"; | ||
if ( !( _.isEmpty(subresources) ) ) { | ||
if ( _.isString(subresources) ) { | ||
if (!isEmpty(subresources)) { | ||
if ("string" === typeof subresources) { | ||
subresources = [subresources]; | ||
} | ||
url += ';out=' + subresources.join(','); | ||
url += `;out=${subresources.join(",")}`; | ||
} | ||
url += '?format=json'; | ||
url += "?format=json"; | ||
return this.yf.api(this.yf.GET, url) | ||
return this.yf | ||
.api(this.yf.GET, url) | ||
.then(data => { | ||
const user = userHelper.parseCollection(data.fantasy_content.users[0].user); | ||
const user = userHelper.parseCollection( | ||
data.fantasy_content.users[0].user | ||
); | ||
cb(null, user); | ||
@@ -40,2 +44,2 @@ return user; | ||
}); | ||
}; | ||
}; |
{ | ||
"name": "yahoo-fantasy", | ||
"version": "3.1.2", | ||
"version": "3.2.0", | ||
"description": "An API to help facilitate the use of the Yahoo! Fantasy Sports API in NodeJS projects.", | ||
@@ -27,10 +27,9 @@ "main": "index.js", | ||
"dependencies": { | ||
"esm": "^3.2.25", | ||
"request": "^2.87.0" | ||
"esm": "^3.2.25" | ||
}, | ||
"devDependencies": { | ||
"istanbul": "^0.4.3", | ||
"jasmine": "^3.0.0", | ||
"jasmine": "^3.4.0", | ||
"jasmine-spec-reporter": "^4.2.1", | ||
"nock": "^9.3.0", | ||
"nock": "^9.6.1", | ||
"prettier": "^1.18.2", | ||
"q": "^1.4.1" | ||
@@ -37,0 +36,0 @@ }, |
@@ -29,5 +29,5 @@ # Yahoo! Fantasy API Node Module | ||
var YahooFantasy = require('yahoo-fantasy'); | ||
const YahooFantasy = require('yahoo-fantasy'); | ||
// you can get an application key/secret by creating a new application on Yahoo! | ||
var yf = new YahooFantasy( | ||
const yf = new YahooFantasy( | ||
Y!APPLICATION_KEY, | ||
@@ -79,2 +79,9 @@ Y!APPLICATION_SECRET | ||
#### 3.2.0 | ||
- Added "players" subresource to "league" in order to obtain weekly / season stats for a player based on league settings | ||
- Fixed a bug where the starting status wasn't properly being returned due to a shift in how the data was being returned | ||
- Removed use of "request" library for size and performance reasons | ||
- General code optimizations and improvements | ||
#### 3.1.2 | ||
@@ -81,0 +88,0 @@ |
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
Sorry, the diff of this file is not supported yet
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
735480
1
82
5544
229
1
- Removedrequest@^2.87.0
- Removedajv@6.12.6(transitive)
- Removedasn1@0.2.6(transitive)
- Removedassert-plus@1.0.0(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedaws-sign2@0.7.0(transitive)
- Removedaws4@1.13.2(transitive)
- Removedbcrypt-pbkdf@1.0.2(transitive)
- Removedcaseless@0.12.0(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removedcore-util-is@1.0.2(transitive)
- Removeddashdash@1.14.1(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removedecc-jsbn@0.1.2(transitive)
- Removedextend@3.0.2(transitive)
- Removedextsprintf@1.3.0(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedforever-agent@0.6.1(transitive)
- Removedform-data@2.3.3(transitive)
- Removedgetpass@0.1.7(transitive)
- Removedhar-schema@2.0.0(transitive)
- Removedhar-validator@5.1.5(transitive)
- Removedhttp-signature@1.2.0(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedisstream@0.1.2(transitive)
- Removedjsbn@0.1.1(transitive)
- Removedjson-schema@0.4.0(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedjsprim@1.4.2(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedoauth-sign@0.9.0(transitive)
- Removedperformance-now@2.1.0(transitive)
- Removedpsl@1.15.0(transitive)
- Removedpunycode@2.3.1(transitive)
- Removedqs@6.5.3(transitive)
- Removedrequest@2.88.2(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedsshpk@1.18.0(transitive)
- Removedtough-cookie@2.5.0(transitive)
- Removedtunnel-agent@0.6.0(transitive)
- Removedtweetnacl@0.14.5(transitive)
- Removeduri-js@4.4.1(transitive)
- Removeduuid@3.4.0(transitive)
- Removedverror@1.10.0(transitive)