Skip to content

Commit

Permalink
version 2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
csgillespie authored and cran-robot committed Aug 31, 2020
1 parent 67f0f26 commit c39940d
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 68 deletions.
27 changes: 16 additions & 11 deletions DESCRIPTION
@@ -1,27 +1,32 @@
Type: Package
Package: rtypeform
Title: Interface to 'typeform' Results
Version: 2.0.1
Version: 2.1.0
Authors@R:
person(given = "Colin",
family = "Gillespie",
role = c("aut", "cre"),
email = "csgillespie@gmail.com")
c(person(given = "Colin",
family = "Gillespie",
role = c("aut", "cre"),
email = "csgillespie@gmail.com"),
person(given = "Jamie",
family = "Owen",
role = "aut",
email = "jamie@jumpingrivers.com"))
Maintainer: Colin Gillespie <csgillespie@gmail.com>
Description: An R interface to the 'typeform'
<https://typeform.com> application program interface. Also provides
functions for downloading your results.
License: GPL-2 | GPL-3
URL: https://github.com/csgillespie/rtypeform
BugReports: https://github.com/csgillespie/rtypeform/issues
Imports: assertthat, dplyr, glue, httr, jsonlite, lubridate, purrr,
tibble, tidyr, utils
Imports: assertthat, dplyr (>= 1.0.0), glue, httr, jsonlite, lubridate,
purrr, rlang, tibble, tidyr, utils
Suggests: testthat
Encoding: UTF-8
LazyData: TRUE
RoxygenNote: 7.1.0
RoxygenNote: 7.1.1
NeedsCompilation: no
Packaged: 2020-03-23 19:43:14 UTC; ncsg3
Author: Colin Gillespie [aut, cre]
Packaged: 2020-08-29 16:06:04 UTC; ncsg3
Author: Colin Gillespie [aut, cre],
Jamie Owen [aut]
Repository: CRAN
Date/Publication: 2020-03-23 20:00:03 UTC
Date/Publication: 2020-08-31 07:00:17 UTC
22 changes: 11 additions & 11 deletions MD5
@@ -1,21 +1,21 @@
64db7919b8e760fbf63a2bb97c2c75c8 *DESCRIPTION
b47b07927acac276bdc62867fe0602dd *NAMESPACE
64328b76fb13007b6dcd1362f5fd6528 *NEWS.md
a7e28d64a6025d5a4c5c5598d82f663c *DESCRIPTION
f0a3e3d58fe71c855b12de8b5724e866 *NAMESPACE
9f8a108328d1f44ba7a71c63cd846904 *NEWS.md
635941dbbd7270c4c0c635937c8b6dda *R/auth.R
ec4f83eeeeae26a3c802e16ffb00c2b4 *R/delete_form.R
bf1204cf35dff4755fdd64d8802343dc *R/delete_responses.R
fed4ca2e94ebd53398ee0b8c57d285ad *R/get_api.R
f4253d36bfbe6232e55c10b4a3bf9f92 *R/get_form.R
2009cfe179335606d1d0d43e6195d4be *R/get_forms.R
01729171ce4087bb91100ad98ff881ac *R/get_forms.R
f5454863a2f9e48f5d9464646004fabb *R/get_me.R
44cf772e70695b3184a75c6d9e8939e3 *R/get_responses.R
062f89dfcb5b474c648965ebbbe9824c *R/get_responses.R
12822260c363e197956490e36655dc54 *R/httr_responses.R
a73a3fcb2639f70c62d416b7ef99c52f *R/options.R
20e5fb77416585c28da4a4690932adb5 *R/rest_argument_formatting.R
90a474d2b5a836cf6593319505cca356 *R/rest_argument_formatting.R
b87db923050475b3d983984b85c22979 *R/teams.R
5ba71666b6518164bf63ffb38f83b03b *R/themes.R
df7ddd5764f9bfb9987d09d46c44f925 *R/workspaces.R
ecba08dfe5c3f3a583dcb46e6a78fa3d *README.md
630b7aade0153b616e9df3c06879c579 *R/themes.R
57151fce6422e6c4794a7940dfc7fc65 *R/workspaces.R
b651b164375eee1134cf7d593aeb0b06 *README.md
790fd12460b0df9d3a8849fbe2e36faf *man/check_api_response.Rd
fd0c0105e44f7e8a7fb88eaa2a992bb8 *man/create_theme.Rd
c85b5c659797d93c9500d50f929579cd *man/delete_form.Rd
Expand All @@ -25,7 +25,7 @@ e8c3146bdfd477782c289737b9998fa7 *man/get_api.Rd
6fcd8f725fa5ee83555ad4005022bdb1 *man/get_forms.Rd
81715703a1b68bcac259da599f447dca *man/get_me.Rd
83094a8c848d2792d7079b56bbf02711 *man/get_response.Rd
3e0b01eb43f79f7b5e8b2ae465b7c90b *man/get_responses.Rd
2dabc03762fbf428f94214ea342d46ff *man/get_responses.Rd
68d55f545cedd37ece882b040bfc4dce *man/get_teams.Rd
d01d39f6588c7f4667064023813e009b *man/get_workspaces.Rd
e2da0017130b8f7f6ce41280113aaa05 *man/make_new_token.Rd
Expand All @@ -35,6 +35,6 @@ fdd4d6b2f737f7cb02bf00b0bb2af68b *tests/testthat.R
e9d07d124d972d20f7d2a6b7d119e206 *tests/testthat/form.rds
3e1effe7d783ee66b046d128bc5235ba *tests/testthat/test_api_response.R
4898c69b4c1ee54890fb589e51434dda *tests/testthat/test_get_forms.R
d2c1c21687ea2f97d1456eff5d6765fe *tests/testthat/test_get_responses.R
e528cccec5aedbcb8c006abaaf229561 *tests/testthat/test_get_responses.R
8fd9aab8902e5a44a860c8416e4e9a0b *tests/testthat/test_teams.R
b59ff56421e4b521cf6628584174ca16 *tests/testthat/test_workspaces.R
1 change: 1 addition & 0 deletions NAMESPACE
Expand Up @@ -59,6 +59,7 @@ importFrom(purrr,"%>%")
importFrom(purrr,flatten_df)
importFrom(purrr,keep)
importFrom(purrr,map_df)
importFrom(rlang,.data)
importFrom(tibble,as_tibble)
importFrom(tidyr,unnest)
importFrom(utils,read.csv)
28 changes: 17 additions & 11 deletions NEWS.md
@@ -1,45 +1,51 @@
# Version 2.0.1
# rtypeform 2.1.0 _2020-08-29_
* CRAN release

# rtypeform 2.0.3 _2020-08-28_
* Fixed an issue introduced with dplyr 1.0.0 in handling of duplicate variable names

# rtypeform 2.0.1
* Tidying up code
* Update docs
* Use Oauth

# Version 2.0.0
# rtypeform 2.0.0
* Move to the new typeform API - breaking changes
* Jumped to Version 2 to match the V2 API.

# Version 0.4.0
# rtypeform 0.4.0
* Bug fix: Empty data frames now returned
* Intended to the final version using the V1 data API. Added a start-up message.
* Removed offset argument - seems to be broken at the typeform end.

# Version 0.3.3
# rtypeform 0.3.3
* More consistent response with `get_typeforms()`.
* Bug fix: Return an empty data frame when there are no typeforms (very edge case).
* Bug fix: typeform API insists on integers for times; so use times.

# Version 0.3.2
# rtypeform 0.3.2
* Bug fix: Return an empty data frame when there are no completed responses.
* Bug fix: Parse hidden fields correctly

# Version 0.3.1
# rtypeform 0.3.1
* Improved error messages for http status codes.
* More consistent response with `get_questionnaire()`.

# Version 0.3.0
# rtypeform 0.3.0
* Breaking changes to the API. `get_results()` now depreciated.
Instead, use `get_questionnaire()`. This returns a list with http_status,
question stats, questions, completed, and uncompleted responses (thanks to @hrbrmstr).

# Version 0.2.1
# rtypeform 0.2.1
* Adding automatic type conversion in the `get_results()` function (thanks to @1beb).

# Version 0.2.0
# rtypeform 0.2.0
* Adding user agent to API call.
* Better error handling.
* Export get_api function.

# Version 0.1.1
# rtypeform 0.1.1
* Minor tweaks for CRAN.

# Version 0.1.0
# rtypeform 0.1.0
* Initial release.
20 changes: 11 additions & 9 deletions R/get_forms.R
Expand Up @@ -13,7 +13,6 @@ get_number_of_forms = function(api = NULL,
content$total_items
}

globalVariables(c("settings", "self", "theme", "href", "href1", "display", "last_updated_at"))
#' Fetch all available typeforms
#'
#' This function returns a two column data frame containing the typeform names and
Expand All @@ -28,6 +27,7 @@ globalVariables(c("settings", "self", "theme", "href", "href1", "display", "last
#' @return A list containing content and the response.
#' @import dplyr purrr
#' @importFrom tidyr unnest
#' @importFrom rlang .data
#' @export
get_forms = function(api = NULL,
page = 1,
Expand All @@ -53,18 +53,20 @@ get_forms = function(api = NULL,
is_trial = "", questions = "", theme = "", questionnaire_url = "")[0, ]
return(items)
}

theme = items$theme %>% select(theme = .data$href)
self = items$self %>% rename(questions = .data$href)

items = items %>%
select(-settings, -self, -theme, -"_links") %>%
select(-.data$settings, -.data$self, -.data$theme, -.data[["_links"]]) %>%
as_tibble() %>%
bind_cols(items$settings,
items$self,
items$theme,
self,
theme,
items$`_links`) %>%
rename(questions = href,
theme = href1,
questionnaire_url = display,
last_updated = last_updated_at,
form_id = id) %>%
rename(questionnaire_url = .data$display,
last_updated = .data$last_updated_at,
form_id = .data$id) %>%
mutate(last_updated = lubridate::ymd_hms(items$last_updated))
attr(items, "total_items") = content$total_items
attr(items, "page_count") = content$page_count
Expand Down
19 changes: 9 additions & 10 deletions R/get_responses.R
Expand Up @@ -8,9 +8,9 @@ flatten_answers = function(a) {
bind_cols()
}

globalVariables(c("answers", "metadata", "hidden", "calculated",
"landed_at", "submitted_at"))

#' @importFrom dplyr matches
#' @importFrom rlang .data
get_meta = function(content) {
items = content$items
if (length(items) == 0) {
Expand All @@ -21,19 +21,18 @@ get_meta = function(content) {
return(empty_meta)
}
meta = items %>%
select(-answers, -metadata, -matches("hidden"), -matches("calculated")) %>%
select(-.data$answers, -.data$metadata, -matches("hidden"), -matches("calculated")) %>%
as_tibble() %>%
bind_cols(items$metadata, items$hidden, items$calculated) %>%
mutate(landed_at = ymd_hms(landed_at),
submitted_at = ymd_hms(submitted_at))
mutate(landed_at = ymd_hms(.data$landed_at),
submitted_at = ymd_hms(.data$submitted_at))

attr(meta, "total_items") = content$total_items
attr(meta, "page_count") = content$page_count
meta
}


globalVariables(".")
#' Download questionnaire results
#'
#' Download results for a particular typeform questionnaire.
Expand All @@ -57,7 +56,7 @@ globalVariables(".")
#' possible to determine completed/non-completed results.
#' @param query Limit request to only responses that that include the specified term.
#' @param fields Not implemented. Pull requests welcome
#' @return A list. The first value is meta imformation. Subsequent elements are
#' @return A list. The first value is meta information. Subsequent elements are
#' questions..
#' @importFrom purrr flatten_df map_df keep
#' @importFrom utils read.csv
Expand Down Expand Up @@ -105,8 +104,8 @@ get_responses = function(form_id, api = NULL,
all_answers = answers %>%
map(flatten_answers) %>%
map2(items$landing_id, ~mutate(.x, landing_id = .y)) %>%
bind_rows() %>%
split(.$field_id)
bind_rows()
all_answers = split(all_answers, all_answers$field_id)

question_types = all_answers %>%
map(~select(.x, type_value)) %>%
Expand All @@ -117,7 +116,7 @@ get_responses = function(form_id, api = NULL,
all_answers = all_answers %>%
map2(question_types,
~select(.x,
"field_type", "landing_id", starts_with(paste0(.y, "_")))) %>%
.data$field_type, .data$landing_id, starts_with(paste0(.y, "_")))) %>%
map(~unnest(.x, cols = c())) %>%
map(~rename(.x, type = 1, value = 3))

Expand Down
3 changes: 1 addition & 2 deletions R/rest_argument_formatting.R
@@ -1,4 +1,3 @@
globalVariables("obj_name")
#' @importFrom lubridate tz with_tz is.POSIXct ymd_hms
format_date_time = function(date_time) {
if (is.null(date_time)) return(NULL)
Expand All @@ -15,7 +14,7 @@ format_date_time = function(date_time) {

create_argument = function(arg) {
if (is.null(arg) || nchar(arg) == 0) return("")
obj_name = deparse(substitute(arg))
obj_name = deparse(substitute(arg)) # nolint
glue("{obj_name}={arg}")
}

Expand Down
5 changes: 2 additions & 3 deletions R/themes.R
@@ -1,5 +1,3 @@
globalVariables(c("colors", "background"))

#' @title Theme functions
#'
#' Theme API functions
Expand Down Expand Up @@ -55,6 +53,7 @@ get_theme = function(theme_id, api = NULL) {

#' @rdname create_theme
#' @inheritParams get_forms
#' @importFrom rlang .data
#' @export
get_themes = function(api = NULL, page = 1, page_size = 10) {
page = create_argument(page)
Expand All @@ -64,7 +63,7 @@ get_themes = function(api = NULL, page = 1, page_size = 10) {
content = get_response(api = api, url)
items = content$items
backgrounds = items %>%
select(-colors, -background) %>%
select(-.data$colors, -.data$background) %>%
as_tibble() %>%
bind_cols(items$colors, items$background)

Expand Down
7 changes: 4 additions & 3 deletions R/workspaces.R
@@ -1,4 +1,3 @@
globalVariables(c("forms", "name1"))

#' @rdname get_workspaces
#' @export
Expand All @@ -15,6 +14,7 @@ get_number_of_workspace = function(api = NULL, search = NULL) {
#' @export
#' @inheritParams get_api
#' @inheritParams get_forms
#' @importFrom rlang .data
get_workspaces = function(api = NULL,
search = NULL,
page = 1,
Expand All @@ -27,7 +27,7 @@ get_workspaces = function(api = NULL,
content = get_response(api = api, url)
items = content$items
workspaces = items %>%
select(-forms, -self) %>%
select(-.data$forms, -.data$self) %>%
as_tibble() %>%
bind_cols(items$forms, items$self)
attr(workspaces, "page_count") = content$page_space
Expand All @@ -36,6 +36,7 @@ get_workspaces = function(api = NULL,
}

#' @importFrom httr content_type_json
#' @importFrom rlang .data
#' @param workspace_name The name workspace name
#' @rdname get_workspaces
#' @export
Expand All @@ -46,7 +47,7 @@ create_workspace = function(workspace_name, api = NULL) {
content = post_response(api = api, url, body = body, content_type_json())
content %>%
flatten_dfc() %>%
rename(workspace_name = name1)
rename(workspace_name = .data$name1)
}

#' @rdname get_workspaces
Expand Down
12 changes: 6 additions & 6 deletions README.md
Expand Up @@ -4,13 +4,13 @@

[![Build
Status](https://travis-ci.org/csgillespie/rtypeform.svg?branch=master)](https://travis-ci.org/csgillespie/rtypeform)
[![Downloads](http://cranlogs.r-pkg.org/badges/rtypeform?color=brightgreen)](https://cran.r-project.org/package=rtypeform)
[![CRAN\_Status\_Badge](http://www.r-pkg.org/badges/version/rtypeform)](https://cran.r-project.org/package=rtypeform)
[![Downloads](https://cranlogs.r-pkg.org/badges/rtypeform?color=brightgreen)](https://cran.r-project.org/package=rtypeform)
[![CRAN\_Status\_Badge](https://www.r-pkg.org/badges/version/rtypeform)](https://cran.r-project.org/package=rtypeform)
[![codecov.io](https://codecov.io/github/csgillespie/rtypeform/coverage.svg?branch=master)](https://codecov.io/github/csgillespie/rtypeform?branch=master)

[Typeform](http://referral.typeform.com/mzcsnTI) is a company that
specializes in online form building. This R package allows users to
download their form results through the exposed API (V2).
[Typeform](https://www.typeform.com) is a company that specializes in
online form building. This R package allows users to download their form
results through the exposed API (V2).

\*\* The `rtypeform` package now uses V2. This is a breaking change from
the previous version.\*\*
Expand Down Expand Up @@ -118,7 +118,7 @@ of forms.

``` r
attr(forms, "total_items")
#> [1] 3
#> [1] 135
```

If you don’t pass your `api` token as an argument, it will attempt to
Expand Down
2 changes: 1 addition & 1 deletion man/get_responses.Rd

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

0 comments on commit c39940d

Please sign in to comment.