Skip to content

Commit

Permalink
Update documentation and fix other minor issues
Browse files Browse the repository at this point in the history
  • Loading branch information
andrie committed Jun 10, 2019
1 parent 8e8cf69 commit 82f7571
Show file tree
Hide file tree
Showing 23 changed files with 194 additions and 116 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ client_id.json
^data-raw$
logo.svg
^LICENSE\.md$
^\.travis\.yml$
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# R for travis: see documentation at https://docs.travis-ci.com/user/languages/r

language: R
cache: packages
6 changes: 4 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ Authors@R:
family = "Bryan",
role = c("ctb"),
email = "[email protected]",
comment = c(ORCID = "0000-0002-6983-2759")),
comment = c(ORCID = "0000-0002-6983-2759",
"author of gargle package")),
person(given = "Google Inc",
role = "cph"))
role = "cph",
comment = "Google Calendar API and discovery documents"))
Description: Read events from the Google Calendar API.
Date: 2019-06-10
License: MIT + file LICENSE
Expand Down
23 changes: 21 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,2 +1,21 @@
YEAR: 2019
COPYRIGHT HOLDER: Andrie de Vries
# MIT License

Copyright (c) 2019 Andrie de Vries

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
21 changes: 0 additions & 21 deletions LICENSE.md

This file was deleted.

2 changes: 0 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,9 @@ importFrom(purrr,map_dfr)
importFrom(purrr,map_int)
importFrom(purrr,map_lgl)
importFrom(purrr,pluck)
importFrom(purrr,vec_depth)
importFrom(rlang,"%||%")
importFrom(rlang,flatten)
importFrom(rlang,is_string)
importFrom(rlang,squash)
importFrom(tibble,as_tibble)
importFrom(tibble,tibble)
importFrom(tidyr,nest)
2 changes: 1 addition & 1 deletion R/convert_items_to_events.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
utils::globalVariables(c("start", "end", "summary", "location"))
utils::globalVariables(c("start", "end", "summary", "location", "."))

transform_or_na <- function(df, varname, fn = as_date) {
if (varname %in% names(df)) df %>% dplyr::pull(!!varname) %>% fn() else fn(NA)
Expand Down
21 changes: 15 additions & 6 deletions R/gcalendr-package.r
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
#' gcalendr
#'
#' Important functions:
#' You can read Google calendar data using the Google Calendar API
#'
#' Access your calendar:
#'
#' * [get_google_token()]
#' * [get_gcal_list()]
#' * [get_gcal_events()]
#'
#' Authenticate
#'
#' * [gcalendr_auth()]
#' * [gcalendr_token()]
#'
#' @name gcalendr
#' @aliases gcalendr-package
#' @docType package
#'
#' @importFrom dplyr '%>%' bind_cols select mutate if_else bind_rows one_of left_join group_by rename
#' @importFrom httr GET content oauth_app config oauth_endpoints oauth2.0_token
#' @importFrom purrr map map_chr map_int map_lgl map_dfr
#' @importFrom purrr pluck discard pluck vec_depth
#' @importFrom rlang flatten squash
#' @importFrom dplyr '%>%' bind_cols select mutate if_else bind_rows one_of left_join group_by
# @importFrom memoise memoise
#' @importFrom purrr pluck discard pluck
#' @importFrom rlang flatten is_string %||%
#' @importFrom lubridate as_date as_datetime
#' @importFrom tidyr nest
#' @importFrom tibble tibble as_tibble
#' @importFrom gargle request_make
#'
NULL
1 change: 0 additions & 1 deletion R/gcalendr_auth.R
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ gcalendr_has_token <- function() {
#' )
#' }
#'
#' @importFrom rlang is_string
gcalendr_auth_config <- function(
app = NULL,
path = NULL,
Expand Down
1 change: 0 additions & 1 deletion R/generate_request.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ stop_glue <- function (..., .sep = "", .envir = parent.frame(), call. = FALSE,
#' @family low-level API functions
#' @seealso [gargle::request_develop()], [gargle::request_build()]
#'
#' @importFrom rlang "%||%"
#'
#' @examples
#' \dontrun{
Expand Down
32 changes: 18 additions & 14 deletions R/get_calendar_events.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
call_gcal_api <- function(id, token = gcalendr_token(), time_min, time_max, max_results = 250){
# api = "https://www.googleapis.com/calendar/v3/calendars"
# url <- sprintf(
# "%s/%s/events?maxResults=%d&timeMin=%s&timeMax=%s&orderBy=startTime&singleEvents=true",
# api, id, max_results, time_min, time_max
# )
# r <- GET(url, config(token = google_token))

time_min <- strftime(time_min, tz = "UTC", "%Y-%m-%dT%H:%M:00Z")
time_max <- strftime(time_max, tz = "UTC", "%Y-%m-%dT%H:%M:00Z")
Expand Down Expand Up @@ -42,8 +37,6 @@ call_gcal_api <- function(id, token = gcalendr_token(), time_min, time_max, max_
)
)

# new_url <- sprintf("%s&pageToken=%s", url, r[["nextPageToken"]])
# r <- GET(new_url, config(token = google_token))
r <- request_make(req)
httr::stop_for_status(r)
r <- content(r)
Expand All @@ -54,21 +47,32 @@ call_gcal_api <- function(id, token = gcalendr_token(), time_min, time_max, max_
}


#' Read list of google calendar events.
#' Retrieve google calendar events.
#'
#' This returns a tibble of events for a specific calendar.
#'
#' The resulting tibble has nested list columns for:
#'
#' * `attendees`
#' * `creator`
#' * `organizer`
#'
#' To unnest these columns, use [tidyr::unnest()]
#'
#' @inheritParams get_gcal_list
#'
#' @param id calendar id, obtained from [get_gcal_list()]
#' @param days_in_past Restrict results to date range, number of days in past
#' @param days_in_future Restrict results to date range, number of days into future
#' @param days_in_future Restrict results to date range, number of days into
#' future
#' @param now Reference time stamp, defaulting to [Sys.time()]
#' @param max_results Maximum number of results retrieved per query
#' @param max_results Used internally to specify the maximum number of results
#' retrieved per "page" of the query.
#'
#' @references https://developers.google.com/google-apps/calendar/v3/reference/events/list
#' @family gcal functions
#' @references
#' https://developers.google.com/google-apps/calendar/v3/reference/events/list
#' @family calendar functions
#' @export
#' @importFrom tibble tibble as_tibble
#' @importFrom dplyr rename
get_gcal_events <- function(id, token = gcalendr_token(),
days_in_past = 90, days_in_future = 90,
now = Sys.time(), max_results = 250){
Expand Down
8 changes: 4 additions & 4 deletions R/get_calendar_list.R
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#' Get list of calendars from google.
#'
#' @param token token obtained from [get_google_token]
#'
#' @return character vector with calendar ids
#' @family gcal functions
#' @param token token obtained from [gcalendr_token()]
#'
#' @return Tibble with columns for `id`, `summary` and `description`.
#' @family calendar functions
#'
#' @importFrom gargle request_make
#' @export
get_gcal_list <- function(token = gcalendr_token()){

Expand Down
10 changes: 5 additions & 5 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
destination: docs

reference:
- title: Read a google calendar
desc: Get a list of calendars and read events from a calendar
contents:
- '`get_gcal_list`'
- '`get_gcal_events`'
- title: Authenticating
desc: Take explicit control of the Google auth status or examine current state
contents:
Expand All @@ -9,11 +14,6 @@ reference:
- '`gcalendr_token`'
- '`gcalendr_auth_config`'
- '`gcalendr_has_token`'
- title: Read a google calendar
desc: Get a list of calendars and read events from a calendar
contents:
- '`get_gcal_events`'
- '`get_gcal_list`'
- title: Calendar API spec
desc: Info about or check input against the Calendar API spec
contents:
Expand Down
23 changes: 21 additions & 2 deletions docs/LICENSE-text.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/authors.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 14 additions & 3 deletions docs/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions docs/reference/gcalendr.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 82f7571

Please sign in to comment.