Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pkgdown site and update README #33

Merged
merged 14 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
^\.Rproj\.user$
^README\.Rmd$
^LICENSE\.md$
^\.github$
^docs$
^pkgdown$
41 changes: 41 additions & 0 deletions .github/workflows/pkgdown.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
release:
types: [published]
workflow_dispatch:

name: pkgdown

jobs:
pkgdown:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
DK_IV: ${{ secrets.DK_IV }}
DK_JWE: ${{ secrets.DK_JWE }}
steps:
- uses: actions/checkout@v2

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::pkgdown, local::.
needs: website

- name: Build site
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
shell: Rscript {0}

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/[email protected]
with:
clean: false
branch: gh-pages
folder: docs
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@
.RData
.Ruserdata
.Renviron
docs/
inst/doc

/.quarto/
11 changes: 8 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: draft.kings
Type: Package
Title: Draft Kings API Wrapper and Optimization
Version: 0.5.3
Version: 0.5.4
Author: Giovanni Colitti
Maintainer: Giovanni Colitti <[email protected]>
Description: Fetch data from DraftKings using the provided API and perform lineup optimization.
Expand All @@ -11,7 +11,6 @@ LazyData: true
Imports:
cli,
dplyr,
furrr,
glue,
httr2,
jsonlite,
Expand All @@ -24,13 +23,19 @@ Imports:
tidyjson,
tidyr,
utils
RoxygenNote: 7.2.3
RoxygenNote: 7.3.2
Suggests:
devtools,
diffviewer,
httptest2,
knitr,
pkgdown,
rmarkdown,
ROI.plugin.glpk,
testthat (>= 3.0.0),
usethis
Config/testthat/edition: 3
Roxygen: list(markdown = TRUE)
URL: https://gacolitti.github.io/draft.kings
BugReports: https://github.com/gacolitti/draft.kings/issues
VignetteBuilder: knitr
8 changes: 3 additions & 5 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ S3method(dk_resp_parse,contest_info_resp)
S3method(dk_resp_parse,default)
S3method(dk_resp_parse,draft_group_info2_resp)
S3method(dk_resp_parse,draft_group_info_resp)
S3method(dk_resp_parse,draft_group_resp)
S3method(dk_resp_parse,entries_resp)
S3method(dk_resp_parse,game_type_rules_resp)
S3method(dk_resp_parse,leaderboard_resp)
Expand All @@ -23,9 +24,7 @@ S3method(print,classic_solution)
S3method(print,showdown_captain_mode_multiple_solutions)
S3method(print,showdown_captain_mode_solution)
export("%>%")
export(clean_names)
export(dk_extract_solution)
export(dk_get)
export(dk_get_competitions)
export(dk_get_contest_info)
export(dk_get_draft_group)
Expand All @@ -42,12 +41,11 @@ export(dk_get_player_fp)
export(dk_get_player_list)
export(dk_get_sports)
export(dk_get_team_list)
export(dk_multi_get)
export(dk_optimize_lineup)
export(dk_prepare_schematic)
export(dk_req)
export(dk_req_perform)
export(dk_request)
export(dk_request_process)
export(dk_req_process)
export(dk_resp_parse)
export(dk_write_csv)
importFrom(magrittr,"%>%")
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# draft.kings 0.5.4
* Added pkgdown site and udpated README
* Removed `dk_get()` and `dk_multi_get()`
* Renamed functions like `dk_request_*()` to `dk_req_*()`
* Renamed functions like `dk_response_*()` to `dk_resp_*()`
* Replaced `cookies_file` argument with `iv` and `jwe` arguments to functions that require DraftKings session cookies
4 changes: 2 additions & 2 deletions R/api-parse.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ extract_unix_timestamp <- function(x) {
#' Parse Response JSON
#'
#' @inheritParams httr2::resp_body_json
#'
#' @export
dk_resp_parse <- function(resp) {
UseMethod("dk_resp_parse")
Expand Down Expand Up @@ -207,7 +206,8 @@ dk_resp_parse.lobby_game_types_resp <- function(resp) {
}

#### Draftgroup ------------------------------------------------------------------------------------

#' @method dk_resp_parse draft_group_resp
#' @export
dk_resp_parse.draft_group_resp <- function(resp) {

resp$draftables %>%
Expand Down
6 changes: 3 additions & 3 deletions R/competition.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#' team IDs, and sport name.
#'
#' @inheritParams dk_get_contest_info
#' @inheritDotParams dk_request
#' @inheritDotParams dk_req
#'
#' @param draft_group_id Sequence of digits that correspond to a draft table/group.
#'
Expand All @@ -30,7 +30,7 @@ dk_get_competitions <- function(draft_group_id = NULL,

output <- rlang::arg_match(output)

req <- dk_request(
req <- dk_req(
...,
paths = glue::glue(
"sports/v1/competitions?draftGroupId={draft_group_id}&format=json"
Expand All @@ -40,6 +40,6 @@ dk_get_competitions <- function(draft_group_id = NULL,
process_args <- c(list(req = req, output = output, objclass = "competitions_resp"),
process_args)

do.call(dk_request_process, process_args)
do.call(dk_req_process, process_args)

}
32 changes: 16 additions & 16 deletions R/contest.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
#'
#' Fetch contest information such as the sport, payout, and contest summary.
#'
#' @inheritParams dk_request_process
#' @inheritDotParams dk_request
#' @inheritParams dk_req_process
#' @inheritDotParams dk_req
#'
#' @param contest_key The sequence of digits that correspond to a specific contest.
#' This can be found by examining the URL of a contest page.
#' For example: \url{https://www.draftkings.com/draft/contest/133645678#}. Here the contest ID
#' is 133645678.
#' @param process_args Optional list of arguments passed to `dk_request_process`
#' @param process_args Optional list of arguments passed to `dk_req_process`
#'
#' @examples
#' \dontrun{
Expand All @@ -26,25 +26,25 @@ dk_get_contest_info <- function(contest_key,
stopifnot(is.numeric(contest_key))
output <- rlang::arg_match(output)

req <- dk_request(
req <- dk_req(
...,
paths = glue::glue("contests/v1/contests/{contest_key}"),
query_params = list(format = "json")
)

process_args <- c(list(req = req, output = output, objclass = "contest_info_resp"), process_args)

do.call(dk_request_process, process_args)
do.call(dk_req_process, process_args)

}

#' Get List of Contests in Lobby
#'
#' Fetch the full table of contests and related info from DraftKings.com lobby
#'
#' @inheritParams dk_request_process
#' @inheritParams dk_req_process
#' @inheritParams dk_get_contest_info
#' @inheritDotParams dk_request
#' @inheritDotParams dk_req
#'
#' @param sport character. optional.
#'
Expand All @@ -56,7 +56,7 @@ dk_get_lobby_contests <- function(sport = NULL,

output <- rlang::arg_match(output)

req <- dk_request(
req <- dk_req(
...,
base_url = "https://www.draftkings.com/",
paths = "lobby/getcontests",
Expand All @@ -66,17 +66,17 @@ dk_get_lobby_contests <- function(sport = NULL,
process_args <- c(list(req = req, output = output, objclass = "lobby_contests_resp"),
process_args)

do.call(dk_request_process, process_args)
do.call(dk_req_process, process_args)

}

#' Get Gametype Rules
#'
#' Fetch rules corresponding to a specific game type ID.
#'
#' @inheritParams dk_request_process
#' @inheritParams dk_req_process
#' @inheritParams dk_get_contest_info
#' @inheritDotParams dk_request
#' @inheritDotParams dk_req
#'
#' @param game_type_id Integer corresponding to the game type.
#' For example, 159 in \url{https://api.draftkings.com/lineups/v1/gametypes/159/rules}.
Expand Down Expand Up @@ -105,15 +105,15 @@ dk_get_game_type_rules <- function(game_type_id = NULL,

}

req <- dk_request(
req <- dk_req(
...,
paths = glue::glue("lineups/v1/gametypes/{game_type_id}/rules")
)

process_args <- c(list(req = req, output = output, objclass = "game_type_rules_resp"),
process_args)

do.call(dk_request_process, process_args)
do.call(dk_req_process, process_args)

}

Expand All @@ -122,7 +122,7 @@ dk_get_game_type_rules <- function(game_type_id = NULL,
#' Fetch the full list of game types
#'
#' @inheritParams dk_get_lobby_contests
#' @inheritDotParams dk_request
#' @inheritDotParams dk_req
#'
#' @export
dk_get_lobby_game_types <- function(sport = NULL,
Expand All @@ -132,7 +132,7 @@ dk_get_lobby_game_types <- function(sport = NULL,

output <- rlang::arg_match(output)

req <- dk_request(
req <- dk_req(
...,
base_url = "https://www.draftkings.com/",
paths = "lobby/getcontests",
Expand All @@ -143,6 +143,6 @@ dk_get_lobby_game_types <- function(sport = NULL,
process_args <- c(list(req = req, output = output, objclass = "lobby_game_types_resp"),
process_args)

do.call(dk_request_process, process_args)
do.call(dk_req_process, process_args)

}
Loading
Loading