stattleship / stattleship-r

Stattleship R Wrapper
https://api.stattleship.com/
MIT License
48 stars 14 forks source link

Walk=TRUE bug #17

Closed Btibert3 closed 8 years ago

Btibert3 commented 8 years ago

I believe there is a bug when walk=FALSE is set. The error check simply needs to be moved inside the parent {.

The issue:

options(stringsAsFactors=F)

## library
library(stattleshipR)
library(dplyr)

## set the token
set_token(Sys.getenv("STATTLE_TOKEN"))

goals3 <- ss_get_result(ep="total_stats", query=list(type="hockey_team_stat",
                                                     stat="goals_period_3",
                                                     team_id="nhl-bos"),
                        walk = FALSE)

returns

[1] "Making initial API request"
Error in stopifnot(length(response) == pages) : object 'pages' not found
Btibert3 commented 8 years ago

The https://github.com/stattleship/stattleship-r/tree/brock-issue17 makes the change.

goals3 <- ss_get_result(ep="total_stats", query=list(type="hockey_team_stat",
                                                     stat="goals_period_3",
                                                     team_id="nhl-bos"),
                        walk = FALSE)

yields

> goals3[[1]]$total_team_stat
$stat
[1] "goals_period_3"

$total
[1] 33

$team_id
[1] "e9d7bcb5-6723-4ca9-b1d9-1ccd026be1cb"

It's curious why the result is not a dataframe, but that needs to be explored further and may be resolved on the completion of https://github.com/stattleship/stattleship-r/issues/7.

tcash21 commented 8 years ago

Works now, nice work @Btibert3 !