From e6c85d8958341944a4154855f1fa010c2e8fe917 Mon Sep 17 00:00:00 2001 From: boB Rudis Date: Wed, 27 Dec 2017 17:17:45 -0500 Subject: [PATCH] initial commit --- .Rbuildignore | 12 +++++ .codecov.yml | 1 + .gitignore | 9 ++++ .travis.yml | 31 ++++++++++++ CONDUCT.md | 25 ++++++++++ DESCRIPTION | 31 ++++++++++++ NAMESPACE | 14 ++++++ NEWS.md | 2 + R/aaa.R | 1 + R/about-me.R | 22 ++++++++ R/my-posts.R | 113 ++++++++++++++++++++++++++++++++++++++++++ R/post-stats.R | 44 ++++++++++++++++ R/pressur-package.R | 13 +++++ R/site-info.R | 24 +++++++++ R/site-stats.R | 30 +++++++++++ R/util.R | 3 ++ R/wp_auth.R | 41 +++++++++++++++ README.Rmd | 77 ++++++++++++++++++++++++++++ README.md | 111 +++++++++++++++++++++++++++++++++++++++++ man/pressur.Rd | 16 ++++++ man/wp_about_me.Rd | 20 ++++++++ man/wp_auth.Rd | 19 +++++++ man/wp_get_my_posts.Rd | 23 +++++++++ man/wp_post_stats.Rd | 29 +++++++++++ man/wp_site_info.Rd | 27 ++++++++++ man/wp_site_stats.Rd | 27 ++++++++++ pressur.Rproj | 21 ++++++++ tests/test-all.R | 2 + tests/testthat/test-pressur.R | 6 +++ 29 files changed, 794 insertions(+) create mode 100644 .Rbuildignore create mode 100644 .codecov.yml create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100644 CONDUCT.md create mode 100644 DESCRIPTION create mode 100644 NAMESPACE create mode 100644 NEWS.md create mode 100644 R/aaa.R create mode 100644 R/about-me.R create mode 100644 R/my-posts.R create mode 100644 R/post-stats.R create mode 100644 R/pressur-package.R create mode 100644 R/site-info.R create mode 100644 R/site-stats.R create mode 100644 R/util.R create mode 100644 R/wp_auth.R create mode 100644 README.Rmd create mode 100644 README.md create mode 100644 man/pressur.Rd create mode 100644 man/wp_about_me.Rd create mode 100644 man/wp_auth.Rd create mode 100644 man/wp_get_my_posts.Rd create mode 100644 man/wp_post_stats.Rd create mode 100644 man/wp_site_info.Rd create mode 100644 man/wp_site_stats.Rd create mode 100644 pressur.Rproj create mode 100644 tests/test-all.R create mode 100644 tests/testthat/test-pressur.R diff --git a/.Rbuildignore b/.Rbuildignore new file mode 100644 index 0000000..65401da --- /dev/null +++ b/.Rbuildignore @@ -0,0 +1,12 @@ +^.*\.Rproj$ +^\.Rproj\.user$ +^\.travis\.yml$ +^README\.*Rmd$ +^README\.*html$ +^NOTES\.*Rmd$ +^NOTES\.*html$ +^\.codecov\.yml$ +^README_files$ +^doc$ +^\.httr-oauth$ +^CONDUCT\.md$ diff --git a/.codecov.yml b/.codecov.yml new file mode 100644 index 0000000..69cb760 --- /dev/null +++ b/.codecov.yml @@ -0,0 +1 @@ +comment: false diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..27175f0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +.DS_Store +.Rproj.user +.Rhistory +.RData +.Rproj +src/*.o +src/*.so +src/*.dll +.httr-oauth diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..76d9586 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,31 @@ +language: r + +warnings_are_errors: true + +sudo: required + +cache: packages + +r: + - oldrel + - release + - devel + +apt_packages: + - libv8-dev + - xclip + +env: + global: + - CRAN: http://cran.rstudio.com + +after_success: + - Rscript -e 'covr::codecov()' + +notifications: + email: + - bob@rud.is + irc: + channels: + - "104.236.112.222#builds" + nick: travisci diff --git a/CONDUCT.md b/CONDUCT.md new file mode 100644 index 0000000..52a673e --- /dev/null +++ b/CONDUCT.md @@ -0,0 +1,25 @@ +# Contributor Code of Conduct + +As contributors and maintainers of this project, we pledge to respect all people who +contribute through reporting issues, posting feature requests, updating documentation, +submitting pull requests or patches, and other activities. + +We are committed to making participation in this project a harassment-free experience for +everyone, regardless of level of experience, gender, gender identity and expression, +sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion. + +Examples of unacceptable behavior by participants include the use of sexual language or +imagery, derogatory comments or personal attacks, trolling, public or private harassment, +insults, or other unprofessional conduct. + +Project maintainers have the right and responsibility to remove, edit, or reject comments, +commits, code, wiki edits, issues, and other contributions that are not aligned to this +Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed +from the project team. + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by +opening an issue or contacting one or more of the project maintainers. + +This Code of Conduct is adapted from the Contributor Covenant +(http:contributor-covenant.org), version 1.0.0, available at +http://contributor-covenant.org/version/1/0/0/ diff --git a/DESCRIPTION b/DESCRIPTION new file mode 100644 index 0000000..09b33b5 --- /dev/null +++ b/DESCRIPTION @@ -0,0 +1,31 @@ +Package: pressur +Type: Package +Title: Query and Orchestrate the 'WordPress' 'API' +Version: 0.1.0 +Date: 2017-12-27 +Authors@R: c( + person("Bob", "Rudis", email = "bob@rud.is", role = c("aut", "cre"), + comment = c(ORCID = "0000-0001-5670-2640")) + ) +Maintainer: Bob Rudis +Description: 'WordPress' has a fairly comprehensive 'API' + that makes it possible to perform blog orchestration ('CRUD' operations on posts, users, + sites, etc.) as well as retrieve and process blog statistics. Tools are provided to work + with the 'WordPress' 'API' functions. +URL: https://github.com/hrbrmstr/pressur +BugReports: https://github.com/hrbrmstr/pressur/issues +License: AGPL +Encoding: UTF-8 +Suggests: + testthat, + covr +Depends: + R (>= 3.2.0) +Imports: + purrr, + httr, + stringi, + crayon, + tibble, + anytime +RoxygenNote: 6.0.1.9000 diff --git a/NAMESPACE b/NAMESPACE new file mode 100644 index 0000000..a5c5fcd --- /dev/null +++ b/NAMESPACE @@ -0,0 +1,14 @@ +# Generated by roxygen2: do not edit by hand + +export(wp_about_me) +export(wp_auth) +export(wp_get_my_posts) +export(wp_post_stats) +export(wp_site_info) +export(wp_site_stats) +import(anytime) +import(crayon) +import(httr) +import(purrr) +import(stringi) +importFrom(tibble,data_frame) diff --git a/NEWS.md b/NEWS.md new file mode 100644 index 0000000..9b4679b --- /dev/null +++ b/NEWS.md @@ -0,0 +1,2 @@ +0.1.0 +* Initial release diff --git a/R/aaa.R b/R/aaa.R new file mode 100644 index 0000000..5cfee4f --- /dev/null +++ b/R/aaa.R @@ -0,0 +1 @@ +.pkg <- new.env(parent = emptyenv()) diff --git a/R/about-me.R b/R/about-me.R new file mode 100644 index 0000000..1ef0adb --- /dev/null +++ b/R/about-me.R @@ -0,0 +1,22 @@ +#' Get your user information +#' +#' @md +#' @references +#' @export +#' @examples \dontrun{ +#' wp_auth() +#' wp_about_me() +#' } +wp_about_me <- function() { + + httr::GET( + url = sprintf("https://public-api.wordpress.com/rest/v1.1/me"), + .add_bearer_token(), + httr::accept_json() + ) -> res + + httr::stop_for_status(res) + + httr::content(res) + +} \ No newline at end of file diff --git a/R/my-posts.R b/R/my-posts.R new file mode 100644 index 0000000..ae0e493 --- /dev/null +++ b/R/my-posts.R @@ -0,0 +1,113 @@ +.wp_next_posts_page <- function(.x) { + + ret <- NULL + + if (!is.null(.x$meta$next_page)) { + + httr::GET( + url = "https://public-api.wordpress.com/rest/v1.1/me/posts", + query = list(page_handle = .x$meta$next_page), + .add_bearer_token(), + httr::accept_json() + ) -> res + + return(httr::content(res)) + + } + + return(ret) + +} + +#' Get all 'my' posts across all sites +#' +#' @md +#' @references +#' @param quiet if `TRUE` then no progress information will be displayed +#' @export +#' @examples \dontrun{ +#' wp_auth() +#' my_posts <- wp_get_my_posts() +#' } +wp_get_my_posts <- function(.quiet=FALSE) { + + httr::GET( + url = "https://public-api.wordpress.com/rest/v1.1/me/posts", + .add_bearer_token(), + httr::accept_json() + ) -> res + + httr::stop_for_status(res) + + pg <- httr::content(res) + + .posts <- list() + .posts[[1]] <- pg + + n_pages <- ceiling(pg$found / 20) + + for (idx in 2:n_pages) { + if (!.quiet) cat(crayon::green("."), sep="") + pg <- .wp_next_posts_page(pg) + .posts[[idx]] <- pg + } + if (!.quiet) cat("\n",sep="") + + purrr::map_df(.posts, ~{ + + purrr::map_df(.x$posts, ~{ + + list( + post_id = as.character(.x$ID), + site_id = as.character(.x$site_ID), + author = list(.x$author), + date = .x$date, + modified = .x$modified, + title = .x$title, + url = .x$URL, + short_url = .x$short_URL, + content = .x$content, + excerpt = .x$excerpt, + slug = .x$slug, + guid = .x$guid, + status = .x$status, + sticky = .x$sticky, + password = .x$password, + parent = .x$parent, + type = .x$type, + discussion = list(.x$discussion), + likes_enabled = .x$likes_enabled, + sharing_enabled = .x$sharing_enabled, + like_count = .x$like_count, + i_like = .x$i_like, + is_reblogged = .x$is_reblogged, + is_following = .x$is_following, + global_id = .x$global_ID, + featured_image = .x$featured_image, + post_thumbnail = list(.x$post_thumbnail), + format = .x$format, + geo = .x$geo, + menu_order = .x$menu_order, + page_template = .x$page_template, + publicize_urls = list(.x$publicize_URLs), + terms = list(.x$terms), + tags = list(.x$tags), + categories = list(.x$categories), + attachments = list(.x$attachments), + attachment_count = list(.x$attachment_count), + metadata = list(.x$metadata), + meta = list(.x$meta), + capabilities = list(.x$capabilities), + other_URLs = list(.x$other_URLs) + ) + + }) + + }) -> .posts_df + + .posts_df$date <- anytime::anytime(.posts_df$date) + .posts_df$modified <- anytime::anytime(.posts_df$modified) + + return(.posts_df) + +} diff --git a/R/post-stats.R b/R/post-stats.R new file mode 100644 index 0000000..bb6a51e --- /dev/null +++ b/R/post-stats.R @@ -0,0 +1,44 @@ +#' Retrieve statistics for a WordPress post +#' +#' TODO: make most of the list columns more immediately usable +#' +#' @md +#' @references +#' @param site site id or domain +#' @param post_id a valid post id +#' @note I've only had this work successfully with my blog by using the site id. +#' @export +#' @examples \dontrun{ +#' wp_auth() +#' me <- wp_about_me() +#' wp_post_stats(me$primary_blog, "7713") +#' } +wp_post_stats <- function(site, post_id) { + + httr::GET( + url = sprintf("https://public-api.wordpress.com/rest/v1.1/sites/%s/stats/post/%s", site, post_id), + .add_bearer_token(), + accept_json() + ) -> res + + httr::stop_for_status(res) + + .stats <- httr::content(res) + + tibble::data_frame( + date = as.Date(.stats$date), + views = .stats$views, + years = list(.stats$years), + averages = list(.stats$averages), + weeks = list(.stats$weeks), + fields = list(.stats$fields), + data = list(.stats$data), + highest_month = .stats$highest_month, + highest_day_average = .stats$highest_day_average, + highest_week_average = .stats$highest_week_average, + post_detail = list(.stats$post) + ) -> .stats_df + + return(.stats_df) + +} diff --git a/R/pressur-package.R b/R/pressur-package.R new file mode 100644 index 0000000..fd4bf27 --- /dev/null +++ b/R/pressur-package.R @@ -0,0 +1,13 @@ +#' Query and Orchestrate the 'WordPress' 'API' +#' +#' 'WordPress' has a fairly comprehensive 'API' +#' that makes it possible to perform blog orchestration ('CRUD' operations on posts, users, +#' sites, etc.) as well as retrieve and process blog statistics. Tools are provided to work +#' with the 'WordPress' 'API' functions. +#' +#' @name pressur +#' @docType package +#' @author Bob Rudis (bob@@rud.is) +#' @import purrr stringi httr crayon anytime +#' @importFrom tibble data_frame +NULL diff --git a/R/site-info.R b/R/site-info.R new file mode 100644 index 0000000..dc4367b --- /dev/null +++ b/R/site-info.R @@ -0,0 +1,24 @@ +#' Get information about a site +#' +#' @md +#' @references +#' @param site site id or domain +#' @note I've only had this work successfully with my blog by using the site id. +#' @export +#' @examples \dontrun{ +#' wp_auth() +#' me <- wp_about_me() +#' wp_site_info(me$primary_blog) +#' } +wp_site_info <- function(site) { + + httr::GET( + url = sprintf("https://public-api.wordpress.com/rest/v1.2/sites/%s", site), + httr::accept_json() + ) -> res + + httr::stop_for_status(res) + + httr::content(res) + +} \ No newline at end of file diff --git a/R/site-stats.R b/R/site-stats.R new file mode 100644 index 0000000..158e4cf --- /dev/null +++ b/R/site-stats.R @@ -0,0 +1,30 @@ +#' Get a site's stats +#' +#' @md +#' @references +#' @param site site id or domain +#' @note I've only had this work successfully with my blog by using the site id. +#' @export +#' @examples \dontrun{ +#' wp_auth() +#' me <- wp_about_me() +#' wp_site_stats(me$primary_blog) +#' } +wp_site_stats <- function(site) { + + httr::GET( + url = sprintf("https://public-api.wordpress.com/rest/v1.1/sites/%s/stats", site), + .add_bearer_token(), + accept_json() + ) -> res + + httr::stop_for_status(res) + + .stats <- httr::content(res) + + .stats$visits <- purrr::map_df(.stats$visits$data, ~purrr::set_names(.x, .stats$visits$fields)) + .stats$visits$period <- anytime::anydate(.stats$visits$period) + + return(.stats) + +} diff --git a/R/util.R b/R/util.R new file mode 100644 index 0000000..c9f444c --- /dev/null +++ b/R/util.R @@ -0,0 +1,3 @@ +.add_bearer_token <- function() { + httr::add_headers(`Authorization` = sprintf("Bearer %s", .pkg$token$credentials$access_token)) +} diff --git a/R/wp_auth.R b/R/wp_auth.R new file mode 100644 index 0000000..6e5aaa2 --- /dev/null +++ b/R/wp_auth.R @@ -0,0 +1,41 @@ +oauth_app( + appname = "wordpress", + key = Sys.getenv("WORDPRESS_API_KEY"), + secret = Sys.getenv("WORDPRESS_API_SECRET") +) -> wordpress_app + +oauth_endpoint( + base_url = "https://public-api.wordpress.com/oauth2", + request = "authenticate", + authorize = "authorize", + access = "token" +) -> wordpress_endpoint + +#' Authenticate to WordPress +#' +#' Call this at the start of any WordPress API interaction +#' +#' @md +#' @references +#' @export +#' @examples \dontrun{ +#' wp_auth() +#' } +wp_auth <- function() { + + oauth2.0_token( + wordpress_endpoint, + wordpress_app, + user_params = list( + grant_type = "authorization_code", + response_type = "code", + scope = "global" + ), + cache = TRUE + ) -> wordpress_token + + .pkg$token <- wordpress_token + + invisible(wordpress_token) + +} \ No newline at end of file diff --git a/README.Rmd b/README.Rmd new file mode 100644 index 0000000..5609321 --- /dev/null +++ b/README.Rmd @@ -0,0 +1,77 @@ +--- +output: rmarkdown::github_document +--- + +# pressur + +Query and Orchestrate the 'WordPress' 'API' + +## Description + +'WordPress' has a fairly comprehensive 'API' +that makes it possible to perform blog orchestration ('CRUD' operations on posts, users, +sites, etc.) as well as retrieve and process blog statistics. Tools are provided to work +with the 'WordPress' 'API' functions. + +### YOU MUST + +=> Go here and make an app: + +=> Put the `Client ID` you receive into `~/.Renviron` with a line that looks like: + + `WORDPRESS_API_KEY=#####` + +=> Put the `Client Secret` you receive into `~/.Renviron` with a line that looks like: + + `WORDPRESS_API_SECRET=Yn50ds........` + +And start with a fresh R session for any of this to even have a remote possibility of working. + +### NOTE + +Only minimal functionality is provided at present (enough to get stats out). + +You are encouraged to poke around the source and contribute PRs or issues for high priority items you'd like to see in the package. + +## What's Inside The Tin + +The following functions are implemented: + +- `wp_auth`: Authenticate to WordPress +- `wp_about_me`: Get your user information +- `wp_get_my_posts`: Get all 'my' posts across all sites +- `wp_post_stats`: Retrieve statistics for a WordPress post +- `wp_site_info`: Get information about a site +- `wp_site_stats`: Get a site's stats + +## Installation + +```{r eval=FALSE} +devtools::install_github("hrbrmstr/pressur") +``` + +```{r message=FALSE, warning=FALSE, error=FALSE, include=FALSE} +options(width=120) +``` + +## Usage + +```{r message=FALSE, warning=FALSE, error=FALSE} +library(pressur) + +# current verison +packageVersion("pressur") +``` + +### Basic operation + +```{r} +wp_auth() +me <- wp_about_me() +dplyr::glimpse(wp_site_stats(me$primary_blog)) +``` + +## Code of Conduct + +Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). By participating in this project you agree to abide by its terms. + diff --git a/README.md b/README.md new file mode 100644 index 0000000..9fb2146 --- /dev/null +++ b/README.md @@ -0,0 +1,111 @@ + +# pressur + +Query and Orchestrate the ‘WordPress’ ‘API’ + +## Description + +‘WordPress’ has a fairly comprehensive ‘API’ + that makes it possible to perform +blog orchestration (‘CRUD’ operations on posts, users, sites, etc.) as +well as retrieve and process blog statistics. Tools are provided to work +with the ‘WordPress’ ‘API’ functions. + +### YOU MUST + +\=\> Go here and make an app: + +\=\> Put the `Client ID` you receive into `~/.Renviron` with a line that +looks like: + + `WORDPRESS_API_KEY=#####` + +\=\> Put the `Client Secret` you receive into `~/.Renviron` with a line +that looks like: + + `WORDPRESS_API_SECRET=Yn50ds........` + +And start with a fresh R session for any of this to even have a remote +possibility of working. + +### NOTE + +Only minimal functionality is provided at present (enough to get stats +out). + +You are encouraged to poke around the source and contribute PRs or +issues for high priority items you’d like to see in the package. + +## What’s Inside The Tin + +The following functions are implemented: + + - `wp_auth`: Authenticate to WordPress + - `wp_about_me`: Get your user information + - `wp_get_my_posts`: Get all ‘my’ posts across all sites + - `wp_post_stats`: Retrieve statistics for a WordPress post + - `wp_site_info`: Get information about a site + - `wp_site_stats`: Get a site’s stats + +## Installation + +``` r +devtools::install_github("hrbrmstr/pressur") +``` + +## Usage + +``` r +library(pressur) + +# current verison +packageVersion("pressur") +``` + + ## [1] '0.1.0' + +### Basic operation + +``` r +wp_auth() +me <- wp_about_me() +dplyr::glimpse(wp_site_stats(me$primary_blog)) +``` + + ## List of 3 + ## $ date : chr "2017-12-27" + ## $ stats :List of 24 + ## ..$ visitors_today : int 86 + ## ..$ visitors_yesterday : int 129 + ## ..$ visitors : int 203068 + ## ..$ views_today : int 147 + ## ..$ views_yesterday : int 178 + ## ..$ views_best_day : chr "2017-05-15" + ## ..$ views_best_day_total : int 3984 + ## ..$ views : int 347797 + ## ..$ comments : int 1324 + ## ..$ posts : int 445 + ## ..$ followers_blog : int 197 + ## ..$ followers_comments : int 132 + ## ..$ comments_per_month : int 16 + ## ..$ comments_most_active_recent_day: chr "2015-10-05 19:39:56" + ## ..$ comments_most_active_time : chr "N/A" + ## ..$ comments_spam : int 0 + ## ..$ categories : int 209 + ## ..$ tags : int 695 + ## ..$ shares : int 0 + ## ..$ shares_twitter : int 0 + ## ..$ shares_print : int 0 + ## ..$ shares_linkedin : int 0 + ## ..$ shares_google-plus-1 : int 0 + ## ..$ shares_email : int 0 + ## $ visits:Classes 'tbl_df', 'tbl' and 'data.frame': 30 obs. of 3 variables: + ## ..$ period : Date[1:30], format: "2017-11-28" "2017-11-29" "2017-11-30" "2017-12-01" ... + ## ..$ views : int [1:30] 364 389 451 427 432 204 353 424 573 354 ... + ## ..$ visitors: int [1:30] 253 268 300 319 325 154 254 312 399 259 ... + +## Code of Conduct + +Please note that this project is released with a [Contributor Code of +Conduct](CONDUCT.md). By participating in this project you agree to +abide by its terms. diff --git a/man/pressur.Rd b/man/pressur.Rd new file mode 100644 index 0000000..bd0065a --- /dev/null +++ b/man/pressur.Rd @@ -0,0 +1,16 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/pressur-package.R +\docType{package} +\name{pressur} +\alias{pressur} +\alias{pressur-package} +\title{Query and Orchestrate the 'WordPress' 'API'} +\description{ +'WordPress' has a fairly comprehensive 'API' +that makes it possible to perform blog orchestration ('CRUD' operations on posts, users, +sites, etc.) as well as retrieve and process blog statistics. Tools are provided to work +with the 'WordPress' 'API' functions. +} +\author{ +Bob Rudis (bob@rud.is) +} diff --git a/man/wp_about_me.Rd b/man/wp_about_me.Rd new file mode 100644 index 0000000..ef04532 --- /dev/null +++ b/man/wp_about_me.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/about-me.R +\name{wp_about_me} +\alias{wp_about_me} +\title{Get your user information} +\usage{ +wp_about_me() +} +\description{ +Get your user information +} +\examples{ +\dontrun{ +wp_auth() +wp_about_me() +} +} +\references{ +\url{https://developer.wordpress.com/docs/api/1.1/get/me/} +} diff --git a/man/wp_auth.Rd b/man/wp_auth.Rd new file mode 100644 index 0000000..f12fa22 --- /dev/null +++ b/man/wp_auth.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/wp_auth.R +\name{wp_auth} +\alias{wp_auth} +\title{Authenticate to WordPress} +\usage{ +wp_auth() +} +\description{ +Call this at the start of any WordPress API interaction +} +\examples{ +\dontrun{ +wp_auth() +} +} +\references{ +\url{https://developer.wordpress.com/docs/oauth2/} +} diff --git a/man/wp_get_my_posts.Rd b/man/wp_get_my_posts.Rd new file mode 100644 index 0000000..9107015 --- /dev/null +++ b/man/wp_get_my_posts.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/my-posts.R +\name{wp_get_my_posts} +\alias{wp_get_my_posts} +\title{Get all 'my' posts across all sites} +\usage{ +wp_get_my_posts(.quiet = FALSE) +} +\arguments{ +\item{quiet}{if \code{TRUE} then no progress information will be displayed} +} +\description{ +Get all 'my' posts across all sites +} +\examples{ +\dontrun{ +wp_auth() +my_posts <- wp_get_my_posts() +} +} +\references{ +\url{https://developer.wordpress.com/docs/api/1.1/get/me/posts/} +} diff --git a/man/wp_post_stats.Rd b/man/wp_post_stats.Rd new file mode 100644 index 0000000..b1e1bee --- /dev/null +++ b/man/wp_post_stats.Rd @@ -0,0 +1,29 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/post-stats.R +\name{wp_post_stats} +\alias{wp_post_stats} +\title{Retrieve statistics for a WordPress post} +\usage{ +wp_post_stats(site, post_id) +} +\arguments{ +\item{site}{site id or domain} + +\item{post_id}{a valid post id} +} +\description{ +TODO: make most of the list columns more immediately usable +} +\note{ +I've only had this work successfully with my blog by using the site id. +} +\examples{ +\dontrun{ +wp_auth() +me <- wp_about_me() +wp_post_stats(me$primary_blog, "7713") +} +} +\references{ +\url{https://developer.wordpress.com/docs/api/1.1/get/sites/$site/stats/post/$post_id/} +} diff --git a/man/wp_site_info.Rd b/man/wp_site_info.Rd new file mode 100644 index 0000000..6ed5321 --- /dev/null +++ b/man/wp_site_info.Rd @@ -0,0 +1,27 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/site-info.R +\name{wp_site_info} +\alias{wp_site_info} +\title{Get information about a site} +\usage{ +wp_site_info(site) +} +\arguments{ +\item{site}{site id or domain} +} +\description{ +Get information about a site +} +\note{ +I've only had this work successfully with my blog by using the site id. +} +\examples{ +\dontrun{ +wp_auth() +me <- wp_about_me() +wp_site_info(me$primary_blog) +} +} +\references{ +\url{https://developer.wordpress.com/docs/api/1.2/get/sites/$site/} +} diff --git a/man/wp_site_stats.Rd b/man/wp_site_stats.Rd new file mode 100644 index 0000000..2f08da2 --- /dev/null +++ b/man/wp_site_stats.Rd @@ -0,0 +1,27 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/site-stats.R +\name{wp_site_stats} +\alias{wp_site_stats} +\title{Get a site's stats} +\usage{ +wp_site_stats(site) +} +\arguments{ +\item{site}{site id or domain} +} +\description{ +Get a site's stats +} +\note{ +I've only had this work successfully with my blog by using the site id. +} +\examples{ +\dontrun{ +wp_auth() +me <- wp_about_me() +wp_site_stats(me$primary_blog) +} +} +\references{ +\url{https://developer.wordpress.com/docs/api/1.1/get/sites/$site/stats/} +} diff --git a/pressur.Rproj b/pressur.Rproj new file mode 100644 index 0000000..446d9e1 --- /dev/null +++ b/pressur.Rproj @@ -0,0 +1,21 @@ +Version: 1.0 + +RestoreWorkspace: Default +SaveWorkspace: Default +AlwaysSaveHistory: Default + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 +Encoding: UTF-8 + +RnwWeave: Sweave +LaTeX: pdfLaTeX + +StripTrailingWhitespace: Yes + +BuildType: Package +PackageUseDevtools: Yes +PackageInstallArgs: --no-multiarch --with-keep.source +PackageBuildArgs: --resave-data +PackageRoxygenize: rd,collate,namespace diff --git a/tests/test-all.R b/tests/test-all.R new file mode 100644 index 0000000..f87cf4f --- /dev/null +++ b/tests/test-all.R @@ -0,0 +1,2 @@ +library(testthat) +test_check("pressur") diff --git a/tests/testthat/test-pressur.R b/tests/testthat/test-pressur.R new file mode 100644 index 0000000..ab6f62f --- /dev/null +++ b/tests/testthat/test-pressur.R @@ -0,0 +1,6 @@ +context("basic functionality") +test_that("we can do something", { + + #expect_that(some_function(), is_a("data.frame")) + +})