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

update secrets in workflow #14

Merged
merged 2 commits into from
Feb 28, 2022
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 .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ jobs:
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes
ONA_USERNAME: okapi_bot
ONA_PASSWORD: ${{ secrets.ONA_PASSWORD }}
ONA_TOKEN: ${{ secrets.ONA_TOKEN }}

steps:
- uses: actions/checkout@v2
Expand Down
10 changes: 6 additions & 4 deletions R/ona_form.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ ona_form_list <- function(base_url = "https://api.ona.io",
#' @param project_id Project identifier of project to publish XLSForm to.
#' If NULL (default), XLSForm is published to the an account's default
#' project.
#' @param public Logical. Should the form be public? Default to FALSE.
#'
#' @return A published form on ONA.
#'
Expand All @@ -77,7 +78,8 @@ ona_form_publish <- function(base_url = "https://api.ona.io",
xls_file = NULL,
xls_url = NULL,
dropbox_xls_url = NULL,
project_id = NULL) {
project_id = NULL,
public = FALSE) {
##
auth_mode <- match.arg(auth_mode)

Expand All @@ -87,12 +89,12 @@ ona_form_publish <- function(base_url = "https://api.ona.io",
## Create body
if (!is.null(xls_file)) {
x <- httr::upload_file(xls_file)
.body <- list(xls_file = x)
.body <- list(xls_file = x, public = public)
} else {
if (!is.null(xls_url) & is.null(dropbox_xls_url)) {
.body <- list(xls_url = xls_url)
.body <- list(xls_url = xls_url, public = public)
} else {
.body <- list(dropbox_xls_url = dropbox_xls_url)
.body <- list(dropbox_xls_url = dropbox_xls_url, public = public)
}
}

Expand Down
19 changes: 11 additions & 8 deletions R/ona_project.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#' @param name Name of the project. If NULL (default), project is given a
#' default name similar to that created by ONA for forms published without
#' a project
#' @param public Logical. Should the project be public? Default to TRUE.
#'
#' @return Invisible. Project registered and created in ONA account
#'
Expand All @@ -28,7 +29,8 @@
ona_project_register <- function(base_url = "https://api.ona.io",
auth_mode = c("token", "password"),
owner = Sys.getenv("ONA_USERNAME"),
name = NULL) {
name = NULL,
public = TRUE) {
## Get authentication mode
auth_mode <- match.arg(auth_mode)

Expand Down Expand Up @@ -59,7 +61,8 @@ ona_project_register <- function(base_url = "https://api.ona.io",
## Create body to POST
.body <- list(
owner = paste(base_url, "api/v1/users", owner, sep = "/"),
name = name
name = name,
public = public
)

## Apply POST
Expand Down Expand Up @@ -143,15 +146,15 @@ ona_project_list <- function(base_url = "https://api.ona.io",
config <- ona_configure(auth_mode = auth_mode)

## Apply GET
resp <- httr::GET(
response <- httr::GET(
url = base_url,
path = "api/v1/projects",
config = config
)

## Read JSON
x <- jsonlite::fromJSON(
txt = httr::content(x = resp, as = "text", encoding = "UTF-8")
txt = httr::content(x = response, as = "text", encoding = "UTF-8")
)

## Convert output to tibble
Expand Down Expand Up @@ -192,14 +195,14 @@ ona_project_info <- function(base_url = "https://api.ona.io",
config <- ona_configure(auth_mode = auth_mode)

## Apply GET
resp <- httr::GET(
response <- httr::GET(
url = base_url,
path = paste("api/v1/projects", project_id, sep = "/"),
config = config)

## Read JSON
x <- jsonlite::fromJSON(
txt = httr::content(x = resp, as = "text", encoding = "UTF-8")
txt = httr::content(x = response, as = "text", encoding = "UTF-8")
)

## Convert output to tibble
Expand Down Expand Up @@ -259,15 +262,15 @@ ona_project_share <- function(base_url = "https://api.ona.io",

## Apply PUT
if (is.null(email)) {
httr::PUT(
response <- httr::PUT(
url = base_url,
path = paste("api/v1/projects", project_id, "share", sep = "/"),
config = config,
body = list(username = username, role = role),
encoding = "json"
)
} else {
httr::PUT(
response <- httr::PUT(
url = base_url,
path = paste("api/v1/projects", project_id, "share", sep = "/"),
config = config,
Expand Down
2 changes: 1 addition & 1 deletion docs/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pandoc: 2.14.0.3
pkgdown: 2.0.2
pkgdown_sha: ~
articles: {}
last_built: 2022-02-27T00:31Z
last_built: 2022-02-28T03:21Z
urls:
reference: https://rapidsurveys.io/okapi/reference
article: https://rapidsurveys.io/okapi/articles
Expand Down
48 changes: 34 additions & 14 deletions docs/reference/index.html

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

117 changes: 117 additions & 0 deletions docs/reference/ona_data_get.html

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

Loading