diff --git a/R/add-tracked-time-issue.R b/R/add-tracked-time-issue.R
index acf5bf9..e5e1391 100644
--- a/R/add-tracked-time-issue.R
+++ b/R/add-tracked-time-issue.R
@@ -74,7 +74,7 @@ add_tracked_time_issue <- function(base_url, api_key, owner, repo, id_issue, tim
stop_for_status(r)
- content_tracked_time <- fromJSON(content(r, as = "text"))
+ content_tracked_time <- jsonlite::fromJSON(content(r, as = "text"))
repo_info <- as.data.frame(content_tracked_time$issue$repository)
diff --git a/R/create-comment-issue.R b/R/create-comment-issue.R
index e0eb310..803c099 100644
--- a/R/create-comment-issue.R
+++ b/R/create-comment-issue.R
@@ -73,7 +73,7 @@ create_comment_issue <- function(base_url, api_key, owner, repo, id_issue, body)
# To convert http errors to R errors
stop_for_status(r)
- add_comment_issue <- fromJSON(content(r, as = "text"))
+ add_comment_issue <- jsonlite::fromJSON(content(r, as = "text"))
add_comment_issue <- as.data.frame(add_comment_issue)
return(add_comment_issue)
diff --git a/R/create-issue.R b/R/create-issue.R
index c4b1ced..7b2a715 100644
--- a/R/create-issue.R
+++ b/R/create-issue.R
@@ -73,7 +73,7 @@ create_issue <- function(base_url, api_key, owner, repo, title, body){
# To convert http errors to R errors
stop_for_status(r)
- content_create_issue <- fromJSON(content(r, as = "text"))
+ content_create_issue <- jsonlite::fromJSON(content(r, as = "text"))
return(content_create_issue)
diff --git a/R/edit-comment.R b/R/edit-comment.R
index 2a3bf63..a0d4569 100644
--- a/R/edit-comment.R
+++ b/R/edit-comment.R
@@ -72,7 +72,7 @@ edit_comment <- function(base_url, api_key, owner, repo, id_comment, body){
# To convert http errors to R errors
stop_for_status(r)
- content_edited_comment <- fromJSON(content(r, as = "text"))
+ content_edited_comment <- jsonlite::fromJSON(content(r, as = "text"))
return (content_edited_comment)
diff --git a/R/edit-issue.R b/R/edit-issue.R
index 181b8e8..80d4e0d 100644
--- a/R/edit-issue.R
+++ b/R/edit-issue.R
@@ -76,7 +76,7 @@ edit_issue <- function(base_url, api_key, owner, repo, id_issue, title, body, st
# To convert http errors to R errors
stop_for_status(r)
- content_edit_issue <- fromJSON(content(r, as = "text"))
+ content_edit_issue <- jsonlite::fromJSON(content(r, as = "text"))
return (content_edit_issue)
}
diff --git a/R/edit-user.R b/R/edit-user.R
index bf14a43..4a9343f 100644
--- a/R/edit-user.R
+++ b/R/edit-user.R
@@ -64,7 +64,7 @@ edit_user <- function(base_url, api_key, username, active, login_name){
# To convert http errors to R errors
stop_for_status(r)
- content_edit_user <- fromJSON(content(r, as = "text"))
+ content_edit_user <- jsonlite::fromJSON(content(r, as = "text"))
return (content_edit_user)
}
diff --git a/R/get-an-organization.R b/R/get-an-organization.R
index e8d9291..1a88572 100644
--- a/R/get-an-organization.R
+++ b/R/get-an-organization.R
@@ -43,7 +43,7 @@ get_an_organization <- function(base_url, api_key, org){
# To convert http errors to R errors
stop_for_status(r)
- content_an_organization <- fromJSON(content(r, as = "text"))
+ content_an_organization <- jsonlite::fromJSON(content(r, as = "text"))
content_an_organization <- as.data.frame(content_an_organization)
return(content_an_organization)
diff --git a/R/get-branches.R b/R/get-branches.R
index 3512002..0b5f11c 100644
--- a/R/get-branches.R
+++ b/R/get-branches.R
@@ -52,7 +52,7 @@ get_branches <- function(base_url, api_key, owner, repo){
# To convert http errors to R errors
stop_for_status(r)
- content_branches <- fromJSON(content(r, as = "text"))
+ content_branches <- jsonlite::fromJSON(content(r, as = "text"))
content_branches <- as.data.frame(content_branches)
return(content_branches)
diff --git a/R/get-commits.R b/R/get-commits.R
index 17a3a96..e643493 100644
--- a/R/get-commits.R
+++ b/R/get-commits.R
@@ -47,7 +47,7 @@ get_commits <- function(base_url, api_key, owner, repo){
# To convert http errors to R errors
stop_for_status(r)
- content_commits <- fromJSON(content(r, as = "text"))
+ content_commits <- jsonlite::fromJSON(content(r, as = "text"))
content_commits <- as.data.frame(content_commits)
return(content_commits)
diff --git a/R/get-forks.R b/R/get-forks.R
index edffe4c..2fe891d 100644
--- a/R/get-forks.R
+++ b/R/get-forks.R
@@ -46,7 +46,7 @@ get_forks <- function(base_url, api_key, owner, repo) {
# To convert http errors to R errors
stop_for_status(r)
- content_forks <- fromJSON(content(r, as = "text"))
+ content_forks <- jsonlite::fromJSON(content(r, as = "text"))
content_forks <- as.data.frame(content_forks)
return(content_forks)
diff --git a/R/get-issues-closed-state.R b/R/get-issues-closed-state.R
index 5562906..4b3795e 100644
--- a/R/get-issues-closed-state.R
+++ b/R/get-issues-closed-state.R
@@ -53,7 +53,7 @@ get_issues_closed_state <- function(base_url, api_key, owner, repo){
# To convert http errors to R errors
stop_for_status(r)
- page_issues <- fromJSON(content(r, as = "text"))
+ page_issues <- jsonlite::fromJSON(content(r, as = "text"))
page_issues <- jsonlite::flatten(as.data.frame(page_issues))
if (page != 1 && nrow(page_issues) == 0) {
diff --git a/R/get-issues.R b/R/get-issues.R
index 20409df..0f73419 100644
--- a/R/get-issues.R
+++ b/R/get-issues.R
@@ -1,101 +1,101 @@
-#' @import httr
-#' @import jsonlite
-#' @import magrittr
-#' @import graphics
-#'
-#' @title Returns open issues from an specific repository
-#' @description Returns open issues in an specific repository
-#'
-#' @param base_url The base URL for your gitea server (no trailing '/')
-#' @param api_key The user's API token key for the gitea service
-#'
-#' @param owner The owner of the repository
-#' @param repo The name of the repository
-#' @param full_info TRUE or FALSE value. If FALSE this will select specific
-#' columns from the issues data
-#'
-#' @export
-#'
-#' @examples
-#' \dontrun{
-#' get_issues(base_url = "https://example.gitea.service.com",
-#' api_key = "ccaf5c9a22e854856d0c5b1b96c81e851bafb288",
-#' owner = "company",
-#' repo = "test_repo",
-#' full_info = FALSE)
-#' }
-get_issues <- function(base_url, api_key, owner, repo, full_info = FALSE) {
- if (missing(base_url)) {
- stop("Please add a valid URL")
- } else if (missing(api_key)) {
- stop("Please add a valid API token")
- } else if (missing(owner)) {
- stop("Please add a valid owner")
- } else if (missing(repo)) {
- stop("Please add a valid repository")
- }
- base_url <- sub("/$", "", base_url)
- gitea_url <- file.path(base_url, "api/v1",
- sub("^/", "", "/repos"),
- owner, repo, "issues")
-
- authorization <- paste("token", api_key)
-
- r <- tryCatch(GET(gitea_url,
- add_headers(Authorization = authorization),
- accept_json()),
- error = function(cond) {"Failure"})
-
- if (class(r) != "response") {
- stop(paste0("Error consulting the url: ", gitea_url))
- }
-
- # To convert http errors to R errors
- stop_for_status(r)
-
- content_issues <- fromJSON(content(r, as = "text"))
-
- # Data frame wrangling
- if (full_info == FALSE) {
-
- if (is.data.frame(content_issues$user)) {
- users <- tibble::as_tibble(content_issues$user) %>%
- dplyr::select(username) %>%
- dplyr::rename(author = username)
- } else {
- users <- data.frame()
- }
-
-
- if (is.list(content_issues$assignees)) {
- assignees <- tibble::as_tibble(content_issues$assignee) %>%
- dplyr::select(username) %>%
- dplyr::rename(assignee = username)
- } else {
- assignees <- data.frame()
- }
-
- # Join by position
- issues_content <- content_issues %>%
- dplyr::select(number, title, body, created_at, updated_at,
- due_date) %>%
- dplyr::bind_cols(users, assignees) %>%
- tidyr::separate(col = created_at,
- into = c("created_date", "created_time"),
- sep = "T") %>%
- tidyr::separate(col = updated_at,
- into = c("updated_date", "updated_time"),
- sep = "T") %>%
- dplyr::mutate(created_time = stringr::str_remove(created_time,
- pattern = "Z"),
- updated_time = stringr::str_remove(updated_time,
- pattern = "Z"))
-
- # Return object filtered out
- return(issues_content)
-
- } else {
- return(content_issues)
- }
-
-}
+#' @import httr
+#' @import jsonlite
+#' @import magrittr
+#' @import graphics
+#'
+#' @title Returns open issues from an specific repository
+#' @description Returns open issues in an specific repository
+#'
+#' @param base_url The base URL for your gitea server (no trailing '/')
+#' @param api_key The user's API token key for the gitea service
+#'
+#' @param owner The owner of the repository
+#' @param repo The name of the repository
+#' @param full_info TRUE or FALSE value. If FALSE this will select specific
+#' columns from the issues data
+#'
+#' @export
+#'
+#' @examples
+#' \dontrun{
+#' get_issues(base_url = "https://example.gitea.service.com",
+#' api_key = "ccaf5c9a22e854856d0c5b1b96c81e851bafb288",
+#' owner = "company",
+#' repo = "test_repo",
+#' full_info = FALSE)
+#' }
+get_issues <- function(base_url, api_key, owner, repo, full_info = FALSE) {
+ if (missing(base_url)) {
+ stop("Please add a valid URL")
+ } else if (missing(api_key)) {
+ stop("Please add a valid API token")
+ } else if (missing(owner)) {
+ stop("Please add a valid owner")
+ } else if (missing(repo)) {
+ stop("Please add a valid repository")
+ }
+ base_url <- sub("/$", "", base_url)
+ gitea_url <- file.path(base_url, "api/v1",
+ sub("^/", "", "/repos"),
+ owner, repo, "issues")
+
+ authorization <- paste("token", api_key)
+
+ r <- tryCatch(GET(gitea_url,
+ add_headers(Authorization = authorization),
+ accept_json()),
+ error = function(cond) {"Failure"})
+
+ if (class(r) != "response") {
+ stop(paste0("Error consulting the url: ", gitea_url))
+ }
+
+ # To convert http errors to R errors
+ stop_for_status(r)
+
+ content_issues <- jsonlite::fromJSON(content(r, as = "text"))
+
+ # Data frame wrangling
+ if (full_info == FALSE) {
+
+ if (is.data.frame(content_issues$user)) {
+ users <- tibble::as_tibble(content_issues$user) %>%
+ dplyr::select(username) %>%
+ dplyr::rename(author = username)
+ } else {
+ users <- data.frame()
+ }
+
+
+ if (is.list(content_issues$assignees)) {
+ assignees <- tibble::as_tibble(content_issues$assignee) %>%
+ dplyr::select(username) %>%
+ dplyr::rename(assignee = username)
+ } else {
+ assignees <- data.frame()
+ }
+
+ # Join by position
+ issues_content <- content_issues %>%
+ dplyr::select(number, title, body, created_at, updated_at,
+ due_date) %>%
+ dplyr::bind_cols(users, assignees) %>%
+ tidyr::separate(col = created_at,
+ into = c("created_date", "created_time"),
+ sep = "T") %>%
+ tidyr::separate(col = updated_at,
+ into = c("updated_date", "updated_time"),
+ sep = "T") %>%
+ dplyr::mutate(created_time = stringr::str_remove(created_time,
+ pattern = "Z"),
+ updated_time = stringr::str_remove(updated_time,
+ pattern = "Z"))
+
+ # Return object filtered out
+ return(issues_content)
+
+ } else {
+ return(content_issues)
+ }
+
+}
diff --git a/R/get-label-issue.R b/R/get-label-issue.R
index d7feb27..2ecb008 100644
--- a/R/get-label-issue.R
+++ b/R/get-label-issue.R
@@ -50,7 +50,7 @@ get_label_issue <- function(base_url, api_key, owner, repo, id_issue){
# To convert http errors to R errors
stop_for_status(r)
- content_label_issue <- fromJSON(content(r, as = "text"))
+ content_label_issue <- jsonlite::fromJSON(content(r, as = "text"))
content_label_issue <- as.data.frame(content_label_issue)
return(content_label_issue)
diff --git a/R/get-list-an-org-teams.R b/R/get-list-an-org-teams.R
index 539c5c1..78939d4 100644
--- a/R/get-list-an-org-teams.R
+++ b/R/get-list-an-org-teams.R
@@ -42,7 +42,7 @@ get_list_org_teams <- function(base_url, api_key, org){
# To convert http errors to R errors
stop_for_status(r)
- cont_list_an_org_teams <- fromJSON(content(r, as = "text"))
+ cont_list_an_org_teams <- jsonlite::fromJSON(content(r, as = "text"))
cont_list_an_org_teams <- as.data.frame(cont_list_an_org_teams)
return(cont_list_an_org_teams)
diff --git a/R/get-list-comments-issue.R b/R/get-list-comments-issue.R
index ea2b999..ba271c0 100644
--- a/R/get-list-comments-issue.R
+++ b/R/get-list-comments-issue.R
@@ -57,7 +57,7 @@ get_list_comments_issue <- function(base_url, api_key, owner, repo, id_issue){
# To convert http errors to R errors
stop_for_status(r)
- content_list_comments_issue <- fromJSON(content(r, as = "text"))
+ content_list_comments_issue <- jsonlite::fromJSON(content(r, as = "text"))
return(content_list_comments_issue)
diff --git a/R/get-list-comments-repository.R b/R/get-list-comments-repository.R
index 7dea3cd..e45b9e2 100644
--- a/R/get-list-comments-repository.R
+++ b/R/get-list-comments-repository.R
@@ -58,7 +58,7 @@ get_list_comments_repository <- function(base_url, api_key, owner, repo){
# To convert http errors to R errors
stop_for_status(r)
- list_com_repository <- fromJSON(content(r, as = "text"))
+ list_com_repository <- jsonlite::fromJSON(content(r, as = "text"))
return(list_com_repository)
diff --git a/R/get-list-organization-members.R b/R/get-list-organization-members.R
index 6d9835a..1bb7e6b 100644
--- a/R/get-list-organization-members.R
+++ b/R/get-list-organization-members.R
@@ -49,7 +49,7 @@ get_list_org_members <- function(base_url, api_key, org){
# To convert http errors to R errors
stop_for_status(r)
- content_list_org_members <- fromJSON(content(r, as = "text"))
+ content_list_org_members <- jsonlite::fromJSON(content(r, as = "text"))
content_list_org_members <- as.data.frame(content_list_org_members)
return(content_list_org_members)
diff --git a/R/get-list-repos-of-an-organization.R b/R/get-list-repos-of-an-organization.R
index df13270..9d92fd2 100644
--- a/R/get-list-repos-of-an-organization.R
+++ b/R/get-list-repos-of-an-organization.R
@@ -49,7 +49,7 @@ get_list_repos_org <- function(base_url, api_key, org){
# To convert http errors to R errors
stop_for_status(r)
- content_list_repos_org <- fromJSON(content(r, as = "text"))
+ content_list_repos_org <- jsonlite::fromJSON(content(r, as = "text"))
content_list_repos_org <- as.data.frame(content_list_repos_org)
return(content_list_repos_org)
diff --git a/R/get-list-users.R b/R/get-list-users.R
index 946aecf..cf75e4f 100644
--- a/R/get-list-users.R
+++ b/R/get-list-users.R
@@ -43,7 +43,7 @@ get_list_users <- function(base_url, api_key) {
# To convert http errors to R errors
stop_for_status(r)
- content_list_users <- fromJSON(content(r, as = "text"))
+ content_list_users <- jsonlite::fromJSON(content(r, as = "text"))
content_list_users <- as.data.frame(content_list_users)
return(content_list_users)
diff --git a/R/get-milestones.R b/R/get-milestones.R
index a95dafc..254159e 100644
--- a/R/get-milestones.R
+++ b/R/get-milestones.R
@@ -58,7 +58,7 @@ get_milestones <- function(base_url, api_key, owner, repo){
# To convert http errors to R errors
stop_for_status(r)
- content_milestones <- fromJSON(content(r, as = "text"))
+ content_milestones <- jsonlite::fromJSON(content(r, as = "text"))
content_milestones <- as.data.frame(content_milestones)
return(content_milestones)
diff --git a/R/get-org-hook.R b/R/get-org-hook.R
index e542417..5bb9077 100644
--- a/R/get-org-hook.R
+++ b/R/get-org-hook.R
@@ -1,63 +1,63 @@
-#' @import httr
-#' @import jsonlite
-#
-#' @title Returns a hook
-#' @description Get a hook information of a organizations
-#'
-#' @param base_url The base URL for your gitea server (no trailing '/')
-#' @param api_key The user's API token key for the gitea service
-#'
-#' @param org Name of the organization
-#' @param id_hook Id of the hook to get information
-#'
-#' @export
-#'
-#' @examples
-#' \dontrun{
-#' get_org_hook(base_url = "https://example.gitea.service.com",
-#' api_key = "ccaf5c9a22e854856d0c5b1b96c81e851bafb288",
-#' org = "company",
-#' id_hook = 2)
-#' }
-get_org_hook <- function(base_url, api_key, org, id_hook){
- if (missing(base_url)) {
- stop("Please add a valid URL")
- } else if (missing(api_key)) {
- stop("Please add a valid API token")
- } else if (missing(org)) {
- stop("Please add a valid name of the organization")
- } else if (missing(id_hook)) {
- stop("Please add a id valid of hook")
- }
-
- base_url <- sub("/$", "", base_url)
- gitea_url <- file.path(base_url, "api/v1",
- sub("^/", "", "/orgs"),
- org, "hooks", id_hook)
-
- authorization <- paste("token", api_key)
- r <- tryCatch(
- GET(
- gitea_url,
- add_headers(Authorization = authorization),
- accept_json()
- ),
- error = function(cond) {
- "Failure"
- }
- )
-
- if (class(r) != "response") {
- stop(paste0("Error consulting the url: ", gitea_url))
- }
-
- # To convert http errors to R errors
- stop_for_status(r)
-
- content_org_hook <- content(r, as = "text")
- content_org_hook <- fromJSON(content_org_hook)
- content_org_hook <- as.data.frame(content_org_hook)
-
- return(content_org_hook)
-
-}
+#' @import httr
+#' @import jsonlite
+#
+#' @title Returns a hook
+#' @description Get a hook information of a organizations
+#'
+#' @param base_url The base URL for your gitea server (no trailing '/')
+#' @param api_key The user's API token key for the gitea service
+#'
+#' @param org Name of the organization
+#' @param id_hook Id of the hook to get information
+#'
+#' @export
+#'
+#' @examples
+#' \dontrun{
+#' get_org_hook(base_url = "https://example.gitea.service.com",
+#' api_key = "ccaf5c9a22e854856d0c5b1b96c81e851bafb288",
+#' org = "company",
+#' id_hook = 2)
+#' }
+get_org_hook <- function(base_url, api_key, org, id_hook){
+ if (missing(base_url)) {
+ stop("Please add a valid URL")
+ } else if (missing(api_key)) {
+ stop("Please add a valid API token")
+ } else if (missing(org)) {
+ stop("Please add a valid name of the organization")
+ } else if (missing(id_hook)) {
+ stop("Please add a id valid of hook")
+ }
+
+ base_url <- sub("/$", "", base_url)
+ gitea_url <- file.path(base_url, "api/v1",
+ sub("^/", "", "/orgs"),
+ org, "hooks", id_hook)
+
+ authorization <- paste("token", api_key)
+ r <- tryCatch(
+ GET(
+ gitea_url,
+ add_headers(Authorization = authorization),
+ accept_json()
+ ),
+ error = function(cond) {
+ "Failure"
+ }
+ )
+
+ if (class(r) != "response") {
+ stop(paste0("Error consulting the url: ", gitea_url))
+ }
+
+ # To convert http errors to R errors
+ stop_for_status(r)
+
+ content_org_hook <- content(r, as = "text")
+ content_org_hook <- jsonlite::fromJSON(content_org_hook)
+ content_org_hook <- as.data.frame(content_org_hook)
+
+ return(content_org_hook)
+
+}
diff --git a/R/get-org-list-hooks.R b/R/get-org-list-hooks.R
index edd7b5c..663c503 100644
--- a/R/get-org-list-hooks.R
+++ b/R/get-org-list-hooks.R
@@ -1,58 +1,58 @@
-#' @import httr
-#' @import jsonlite
-#'
-#' @title Returns organization's webhooks
-#' @description Returns a list of organization's webhooks
-#'
-#' @param base_url The base URL for your gitea server (no trailing '/')
-#' @param api_key The user's API token key for the gitea service
-#'
-#' @param org Name of the organization
-#'
-#' @export
-#'
-#' @examples
-#' \dontrun{
-#' get_org_list_hooks(base_url = "https://example.gitea.service.com",
-#' api_key = "ccaf5c9a22e854856d0c5b1b96c81e851bafb288",
-#' org = "company")
-#' }
-get_org_list_hooks <- function(base_url, api_key, org){
- if (missing(base_url)) {
- stop("Please add a valid URL")
- } else if (missing(api_key)) {
- stop("Please add a valid API token")
- } else if (missing(org)) {
- stop("Please add a valid name of the organization")
- }
-
- base_url <- sub("/$", "", base_url)
- gitea_url <- file.path(base_url, "api/v1",
- sub("^/", "", "/orgs"), org, "hooks")
-
- authorization <- paste("token", api_key)
- r <- tryCatch(
- GET(
- gitea_url,
- add_headers(Authorization = authorization),
- accept_json()
- ),
- error = function(cond) {
- "Failure"
- }
- )
-
- if (class(r) != "response") {
- stop(paste0("Error consulting the url: ", gitea_url))
- }
-
- # To convert http errors to R errors
- stop_for_status(r)
-
- content_org_list_hooks <- content(r, as = "text")
- content_org_list_hooks <- fromJSON(content_org_list_hooks)
- content_org_list_hooks <- as.data.frame(content_org_list_hooks)
-
- return(content_org_list_hooks)
-
-}
+#' @import httr
+#' @import jsonlite
+#'
+#' @title Returns organization's webhooks
+#' @description Returns a list of organization's webhooks
+#'
+#' @param base_url The base URL for your gitea server (no trailing '/')
+#' @param api_key The user's API token key for the gitea service
+#'
+#' @param org Name of the organization
+#'
+#' @export
+#'
+#' @examples
+#' \dontrun{
+#' get_org_list_hooks(base_url = "https://example.gitea.service.com",
+#' api_key = "ccaf5c9a22e854856d0c5b1b96c81e851bafb288",
+#' org = "company")
+#' }
+get_org_list_hooks <- function(base_url, api_key, org){
+ if (missing(base_url)) {
+ stop("Please add a valid URL")
+ } else if (missing(api_key)) {
+ stop("Please add a valid API token")
+ } else if (missing(org)) {
+ stop("Please add a valid name of the organization")
+ }
+
+ base_url <- sub("/$", "", base_url)
+ gitea_url <- file.path(base_url, "api/v1",
+ sub("^/", "", "/orgs"), org, "hooks")
+
+ authorization <- paste("token", api_key)
+ r <- tryCatch(
+ GET(
+ gitea_url,
+ add_headers(Authorization = authorization),
+ accept_json()
+ ),
+ error = function(cond) {
+ "Failure"
+ }
+ )
+
+ if (class(r) != "response") {
+ stop(paste0("Error consulting the url: ", gitea_url))
+ }
+
+ # To convert http errors to R errors
+ stop_for_status(r)
+
+ content_org_list_hooks <- content(r, as = "text")
+ content_org_list_hooks <- jsonlite::fromJSON(content_org_list_hooks)
+ content_org_list_hooks <- as.data.frame(content_org_list_hooks)
+
+ return(content_org_list_hooks)
+
+}
diff --git a/R/get-organizations.R b/R/get-organizations.R
index 0185ff8..bf42d1b 100644
--- a/R/get-organizations.R
+++ b/R/get-organizations.R
@@ -44,7 +44,7 @@ get_organizations <- function(base_url, api_key){
# To convert http errors to R errors
stop_for_status(r)
- content_organizations <- fromJSON(content(r, as = "text"))
+ content_organizations <- jsonlite::fromJSON(content(r, as = "text"))
return(content_organizations)
@@ -96,7 +96,7 @@ get_admin_organizations <- function(base_url, api_key){
# To convert http errors to R errors
stop_for_status(r)
- content_organizations <- fromJSON(content(r, as = "text"))
+ content_organizations <- jsonlite::fromJSON(content(r, as = "text"))
return(content_organizations)
diff --git a/R/get-pull-requests.R b/R/get-pull-requests.R
index b94103b..c2592fe 100644
--- a/R/get-pull-requests.R
+++ b/R/get-pull-requests.R
@@ -54,7 +54,7 @@ get_pull_requests <- function(base_url, api_key, owner, repo){
# To convert http errors to R errors
stop_for_status(r)
- content_pull_req <- fromJSON(content(r, as = "text"))
+ content_pull_req <- jsonlite::fromJSON(content(r, as = "text"))
content_pull_req <- as.data.frame(content_pull_req)
return(content_pull_req)
diff --git a/R/get-releases.R b/R/get-releases.R
index 76fa3c9..653e92e 100644
--- a/R/get-releases.R
+++ b/R/get-releases.R
@@ -58,7 +58,7 @@ get_releases <- function(base_url, api_key, owner, repo){
# To convert http errors to R errors
stop_for_status(r)
- content_releases <- fromJSON(content(r, as = "text"))
+ content_releases <- jsonlite::fromJSON(content(r, as = "text"))
content_releases <- as.data.frame(content_releases)
return(content_releases)
diff --git a/R/get-repositories.R b/R/get-repositories.R
index 487290e..e82d41c 100644
--- a/R/get-repositories.R
+++ b/R/get-repositories.R
@@ -44,7 +44,7 @@ get_repositories <- function(base_url, api_key){
# To convert http errors to R errors
stop_for_status(r)
- content_repositories <- fromJSON(content(r, as = "text"))
+ content_repositories <- jsonlite::fromJSON(content(r, as = "text"))
content_repositories <- as.data.frame(content_repositories)
return(content_repositories)
diff --git a/R/get-times-issues.R b/R/get-times-issues.R
index c3603d5..31a164a 100644
--- a/R/get-times-issues.R
+++ b/R/get-times-issues.R
@@ -64,7 +64,7 @@ get_times_issue <- function(base_url, api_key, owner, repo, id_issue){
# To convert http errors to R errors
stop_for_status(r)
- content_issue_times <- fromJSON(content(r, as = "text"))
+ content_issue_times <- jsonlite::fromJSON(content(r, as = "text"))
content_issue_times <- as.data.frame(content_issue_times)
return (content_issue_times)
diff --git a/R/get-version.R b/R/get-version.R
index bc06185..7e70eca 100644
--- a/R/get-version.R
+++ b/R/get-version.R
@@ -44,7 +44,7 @@ get_version <- function(base_url, api_key){
# To convert http errors to R errors
stop_for_status(r)
- content_version <- fromJSON(content(r, "text"))
+ content_version <- jsonlite::fromJSON(content(r, "text"))
content_version <- as.data.frame(content_version)
return(content_version)
diff --git a/R/search_repos.R b/R/search_repos.R
new file mode 100644
index 0000000..7ed620d
--- /dev/null
+++ b/R/search_repos.R
@@ -0,0 +1,52 @@
+#' @import httr
+#' @import jsonlite
+#'
+#' @title Returns all repositories of an instance
+#' @description Get a list of an instance's repositories
+#'
+#' @param base_url The base URL for your gitea server (no trailing '/')
+#' @param api_key The user's API token key for the gitea service
+#'
+#' @export
+#'
+#' @examples
+#' \dontrun{
+#' search_repos(base_url = "https://example.gitea.service.com",
+#' api_key = "ccaf5c9a22e854856d0c5b1b96c81e851bafb288")
+#' }
+search_repos <- function(base_url, api_key){
+ if (missing(base_url)) {
+ stop("Please add a valid URL")
+ } else if (missing(api_key)) {
+ stop("Please add a valid API token")
+ }
+
+ base_url <- sub("/$", "", base_url)
+ gitea_url <- file.path(base_url, "api/v1",
+ sub("^/", "", "/repos/search"))
+
+ authorization <- paste("token", api_key)
+ r <- tryCatch(
+ GET(
+ gitea_url,
+ add_headers(Authorization = authorization),
+ accept_json()
+ ),
+ error = function(cond) {
+ "Failure"
+ }
+ )
+
+ if (class(r) != "response") {
+ stop(paste0("Error consulting the url: ", gitea_url))
+ }
+
+ # To convert http errors to R errors
+ stop_for_status(r)
+
+ content_list_repos <- jsonlite::fromJSON(content(r, as = "text"))
+ content_list_repos <- as.data.frame(content_list_repos)
+
+ return(content_list_repos)
+
+}
diff --git a/README.Rmd b/README.Rmd
index 5c05c04..bb3d7b2 100644
--- a/README.Rmd
+++ b/README.Rmd
@@ -1,111 +1,111 @@
----
-output: github_document
----
-
-
-
-```{r, include = FALSE}
-knitr::opts_chunk$set(
- collapse = TRUE,
- comment = "#>",
- fig.path = "man/figures/README-",
- out.width = "100%"
-)
-library(gitear)
-library(dplyr)
-library(dplyr)
-library(jsonlite)
-library(mockery)
-```
-
-# gitear
-
-
-[![CRAN status](https://www.r-pkg.org/badges/version/gitear)](https://cran.r-project.org/package=gitear)
-[![Travis build status](https://travis-ci.org/ixpantia/gitear.svg?branch=master)](https://travis-ci.org/ixpantia/gitear)
-[![Codecov test coverage](https://codecov.io/gh/ixpantia/gitear/branch/master/graph/badge.svg)](https://codecov.io/gh/ixpantia/gitear?branch=master)
-
-
-The goal of gitear is to request your self-hosted Git service data and import
-it to R in a tidy data frame.
-
-`gitear` is a package that communicates with the
-[gitea](https://gitea.io/en-us/) API.
-
-## Installation
-
-You can install the development version from [GitHub](https://github.com/) with:
-
-``` r
-# install.packages("devtools")
-devtools::install_github("ixpantia/gitear")
-```
-## Usage
-
-First go to your gitea self hosted service and grab your API Token. Then you
-should be able to the following:
-
-```{r, echo = FALSE}
-
-r <- readRDS(system.file("helper_data/response_example.RDS",
- package = "gitear"))
-
-content_issues <- fromJSON(system.file("helper_data/get_issues.json",
- package = "gitear"))
-
-mockery::stub(where = get_issues,
- what = "GET",
- how = r)
-
-mockery::stub(where = get_issues,
- what = "fromJSON",
- how = content_issues)
-```
-
-```{r example}
-# Credentials
-
-api_token <- "gfdsgfd8ba18a866bsdfgsdfgs3a2dc9303453b0c92dcfb19"
-url_ixpantia <- "https://prueba.com"
-
-# Example function use
-
-issues <- get_issues(base_url = url_ixpantia,
- api_key = api_token,
- owner = "empresa",
- repo = "repo_prueba")
-
-
-issues
-```
-
-## **Environmental variables:**
-
-In order to work with environmental variables to make your scripts safer from
-somebody getting your credentials, you can follow the next workflow:
-
- 1. Create an .Renviron file with your credentials
- 2. Restart your R session
- 3. Store your credentials in an object for using it in your script
-
-Your script could look something like this:
-
-```{r example_2}
-# Storing credentials in an object
-
-example_key <- Sys.getenv("example_key")
-example_url <- Sys.getenv("example_url")
-
-# Using a function from gitear
-
-issues <- get_issues(base_url = example_url,
- api_key = example_key,
- owner = "empresa",
- repo = "repo_prueba")
-
-# Check the output
-
-glimpse(issues)
-```
-
-
+---
+output: github_document
+---
+
+
+
+```{r, include = FALSE}
+knitr::opts_chunk$set(
+ collapse = TRUE,
+ comment = "#>",
+ fig.path = "man/figures/README-",
+ out.width = "100%"
+)
+library(gitear)
+library(dplyr)
+library(dplyr)
+library(jsonlite)
+library(mockery)
+```
+
+# gitear
+
+
+[![CRAN status](https://www.r-pkg.org/badges/version/gitear)](https://cran.r-project.org/package=gitear)
+[![Travis build status](https://travis-ci.org/ixpantia/gitear.svg?branch=master)](https://travis-ci.org/ixpantia/gitear)
+[![Codecov test coverage](https://codecov.io/gh/ixpantia/gitear/branch/master/graph/badge.svg)](https://codecov.io/gh/ixpantia/gitear?branch=master)
+
+
+The goal of gitear is to request your self-hosted Git service data and import
+it to R in a tidy data frame.
+
+`gitear` is a package that communicates with the
+[gitea](https://gitea.io/en-us/) API.
+
+## Installation
+
+You can install the development version from [GitHub](https://github.com/) with:
+
+``` r
+# install.packages("devtools")
+devtools::install_github("ixpantia/gitear")
+```
+## Usage
+
+First go to your gitea self hosted service and grab your API Token. Then you
+should be able to the following:
+
+```{r, echo = FALSE}
+
+r <- readRDS(system.file("helper_data/response_example.RDS",
+ package = "gitear"))
+
+content_issues <- jsonlite::fromJSON(system.file("helper_data/get_issues.json",
+ package = "gitear"))
+
+mockery::stub(where = get_issues,
+ what = "GET",
+ how = r)
+
+mockery::stub(where = get_issues,
+ what = "fromJSON",
+ how = content_issues)
+```
+
+```{r example}
+# Credentials
+
+api_token <- "gfdsgfd8ba18a866bsdfgsdfgs3a2dc9303453b0c92dcfb19"
+url_ixpantia <- "https://prueba.com"
+
+# Example function use
+
+issues <- get_issues(base_url = url_ixpantia,
+ api_key = api_token,
+ owner = "empresa",
+ repo = "repo_prueba")
+
+
+issues
+```
+
+## **Environmental variables:**
+
+In order to work with environmental variables to make your scripts safer from
+somebody getting your credentials, you can follow the next workflow:
+
+ 1. Create an .Renviron file with your credentials
+ 2. Restart your R session
+ 3. Store your credentials in an object for using it in your script
+
+Your script could look something like this:
+
+```{r example_2}
+# Storing credentials in an object
+
+example_key <- Sys.getenv("example_key")
+example_url <- Sys.getenv("example_url")
+
+# Using a function from gitear
+
+issues <- get_issues(base_url = example_url,
+ api_key = example_key,
+ owner = "empresa",
+ repo = "repo_prueba")
+
+# Check the output
+
+glimpse(issues)
+```
+
+
diff --git a/README.md b/README.md
index b157fc1..05c53d1 100644
--- a/README.md
+++ b/README.md
@@ -1,99 +1,100 @@
-
-
-
-# gitear
-
-
-
-[![CRAN
-status](https://www.r-pkg.org/badges/version/gitear)](https://cran.r-project.org/package=gitear)
-[![Travis build
-status](https://travis-ci.org/ixpantia/gitear.svg?branch=master)](https://travis-ci.org/ixpantia/gitear)
-[![Codecov test
-coverage](https://codecov.io/gh/ixpantia/gitear/branch/master/graph/badge.svg)](https://codecov.io/gh/ixpantia/gitear?branch=master)
-
-
-The goal of gitear is to request your self-hosted Git service data and
-import it to R in a tidy data frame.
-
-`gitear` is a package that communicates with the
-[gitea](https://gitea.io/en-us/) API.
-
-## Installation
-
-You can install the development version from
-[GitHub](https://github.com/) with:
-
-``` r
-# install.packages("devtools")
-devtools::install_github("ixpantia/gitear")
-```
-
-## Usage
-
-First go to your gitea self hosted service and grab your API Token. Then
-you should be able to the following:
-
-``` r
-# Credentials
-
-api_token <- "gfdsgfd8ba18a866bsdfgsdfgs3a2dc9303453b0c92dcfb19"
-url_ixpantia <- "https://prueba.com"
-
-# Example function use
-
-issues <- get_issues(base_url = url_ixpantia,
- api_key = api_token,
- owner = "empresa",
- repo = "repo_prueba")
-
-
-issues
-#> number title created_date created_time updated_date
-#> 1 3 Primer tiquete para prueba 2020-07-15 23:43:42 2020-07-24
-#> 2 2 Primer tiquete para prueba 2020-07-15 23:12:37 2020-07-24
-#> updated_time due_date author assignee
-#> 1 14:41:47 2020-07-31T23:59:59Z juan juan
-#> 2 14:41:37 2020-07-31T23:59:59Z juan juan
-```
-
-## **Environmental variables:**
-
-In order to work with environmental variables to make your scripts safer
-from somebody getting your credentials, you can follow the next
-workflow:
-
-1. Create an .Renviron file with your credentials
-2. Restart your R session
-3. Store your credentials in an object for using it in your script
-
-Your script could look something like this:
-
-``` r
-# Storing credentials in an object
-
-example_key <- Sys.getenv("example_key")
-example_url <- Sys.getenv("example_url")
-
-# Using a function from gitear
-
-issues <- get_issues(base_url = example_url,
- api_key = example_key,
- owner = "empresa",
- repo = "repo_prueba")
-
-# Check the output
-
-glimpse(issues)
-#> Rows: 2
-#> Columns: 9
-#> $ number 3, 2
-#> $ title "Primer tiquete para prueba", "Primer tiquete para pru...
-#> $ created_date "2020-07-15", "2020-07-15"
-#> $ created_time "23:43:42", "23:12:37"
-#> $ updated_date "2020-07-24", "2020-07-24"
-#> $ updated_time "14:41:47", "14:41:37"
-#> $ due_date "2020-07-31T23:59:59Z", "2020-07-31T23:59:59Z"
-#> $ author "juan", "juan"
-#> $ assignee "juan", "juan"
-```
+
+
+
+# gitear
+
+
+
+[![CRAN
+status](https://www.r-pkg.org/badges/version/gitear)](https://cran.r-project.org/package=gitear)
+[![Travis build
+status](https://travis-ci.org/ixpantia/gitear.svg?branch=master)](https://travis-ci.org/ixpantia/gitear)
+[![Codecov test
+coverage](https://codecov.io/gh/ixpantia/gitear/branch/master/graph/badge.svg)](https://codecov.io/gh/ixpantia/gitear?branch=master)
+
+
+The goal of gitear is to request your self-hosted Git service data and
+import it to R in a tidy data frame.
+
+`gitear` is a package that communicates with the
+[gitea](https://gitea.io/en-us/) API.
+
+## Installation
+
+You can install the development version from
+[GitHub](https://github.com/) with:
+
+``` r
+# install.packages("devtools")
+devtools::install_github("ixpantia/gitear")
+```
+
+## Usage
+
+First go to your gitea self hosted service and grab your API Token. Then
+you should be able to the following:
+
+``` r
+# Credentials
+
+api_token <- "gfdsgfd8ba18a866bsdfgsdfgs3a2dc9303453b0c92dcfb19"
+url_ixpantia <- "https://prueba.com"
+
+# Example function use
+
+issues <- get_issues(base_url = url_ixpantia,
+ api_key = api_token,
+ owner = "empresa",
+ repo = "repo_prueba")
+
+
+issues
+#> number title body created_date
+#> 1 3 Primer tiquete para prueba Este es el cuerpo del tiquete 2020-07-15
+#> 2 2 Primer tiquete para prueba Este es el cuerpo del tiquete 2020-07-15
+#> created_time updated_date updated_time due_date author assignee
+#> 1 23:43:42 2020-07-24 14:41:47 2020-07-31T23:59:59Z juan juan
+#> 2 23:12:37 2020-07-24 14:41:37 2020-07-31T23:59:59Z juan juan
+```
+
+## **Environmental variables:**
+
+In order to work with environmental variables to make your scripts safer
+from somebody getting your credentials, you can follow the next
+workflow:
+
+1. Create an .Renviron file with your credentials
+2. Restart your R session
+3. Store your credentials in an object for using it in your script
+
+Your script could look something like this:
+
+``` r
+# Storing credentials in an object
+
+example_key <- Sys.getenv("example_key")
+example_url <- Sys.getenv("example_url")
+
+# Using a function from gitear
+
+issues <- get_issues(base_url = example_url,
+ api_key = example_key,
+ owner = "empresa",
+ repo = "repo_prueba")
+
+# Check the output
+
+glimpse(issues)
+#> Rows: 2
+#> Columns: 10
+#> $ number 3, 2
+#> $ title "Primer tiquete para prueba", "Primer tiquete para prueba"
+#> $ body "Este es el cuerpo del tiquete", "Este es el cuerpo del t…
+#> $ created_date "2020-07-15", "2020-07-15"
+#> $ created_time "23:43:42", "23:12:37"
+#> $ updated_date "2020-07-24", "2020-07-24"
+#> $ updated_time "14:41:47", "14:41:37"
+#> $ due_date "2020-07-31T23:59:59Z", "2020-07-31T23:59:59Z"
+#> $ author "juan", "juan"
+#> $ assignee "juan", "juan"
+```
diff --git a/tests/testthat/helper-data.R b/tests/testthat/helper-data.R
index c75bb85..c6ee8b3 100644
--- a/tests/testthat/helper-data.R
+++ b/tests/testthat/helper-data.R
@@ -19,122 +19,122 @@ r <- readRDS(system.file("helper_data/response_example.RDS",
# add tracked time issue
-content_tracked_time <- fromJSON(system.file("helper_data/tracked_time.json",
+content_tracked_time <- jsonlite::fromJSON(system.file("helper_data/tracked_time.json",
package = "gitear"))
# create comment issue
-add_comment_issue <- fromJSON(system.file("helper_data/comment_issue.json",
+add_comment_issue <- jsonlite::fromJSON(system.file("helper_data/comment_issue.json",
package = "gitear"))
# create issue
-content_create_issue <- fromJSON(system.file("helper_data/create_issue.json",
+content_create_issue <- jsonlite::fromJSON(system.file("helper_data/create_issue.json",
package = "gitear"))
# edit comment
-content_edited_comment <- fromJSON(system.file("helper_data/edit_comment.json",
+content_edited_comment <- jsonlite::fromJSON(system.file("helper_data/edit_comment.json",
package = "gitear"))
# edit issue
-content_edit_issue <- fromJSON(system.file("helper_data/edit_issue.json",
+content_edit_issue <- jsonlite::fromJSON(system.file("helper_data/edit_issue.json",
package = "gitear"))
# get an organization
-content_an_organization <- fromJSON(system.file("helper_data/get_an_org.json",
+content_an_organization <- jsonlite::fromJSON(system.file("helper_data/get_an_org.json",
package = "gitear"))
# get branches
-content_branches <- fromJSON(system.file("helper_data/get_branches.json",
+content_branches <- jsonlite::fromJSON(system.file("helper_data/get_branches.json",
package = "gitear"))
#get commits
-content_commits <- fromJSON(system.file("helper_data/get_commits.json",
+content_commits <- jsonlite::fromJSON(system.file("helper_data/get_commits.json",
package = "gitear"))
# get forks
-content_forks <- fromJSON(system.file("helper_data/get_forks.json",
+content_forks <- jsonlite::fromJSON(system.file("helper_data/get_forks.json",
package = "gitear"))
# get issues
-content_issues <- fromJSON(system.file("helper_data/get_issues.json",
+content_issues <- jsonlite::fromJSON(system.file("helper_data/get_issues.json",
package = "gitear"))
# get label issues
-content_label_issue <- fromJSON(system.file("helper_data/get_label_issue.json",
+content_label_issue <- jsonlite::fromJSON(system.file("helper_data/get_label_issue.json",
package = "gitear"))
# organization teams
-cont_list_an_org_teams <- fromJSON(system.file("helper_data/get_org_teams.json",
+cont_list_an_org_teams <- jsonlite::fromJSON(system.file("helper_data/get_org_teams.json",
package = "gitear"))
# comments issues
-content_list_comments_issue <- fromJSON(system.file("helper_data/get_comments_issue.json",
+content_list_comments_issue <- jsonlite::fromJSON(system.file("helper_data/get_comments_issue.json",
package = "gitear"))
# comments repository
-list_com_repository <- fromJSON(system.file("helper_data/get_comments_repo.json",
+list_com_repository <- jsonlite::fromJSON(system.file("helper_data/get_comments_repo.json",
package = "gitear"))
# organization members
-content_list_org_members <- fromJSON(system.file("helper_data/get_org_members.json",
+content_list_org_members <- jsonlite::fromJSON(system.file("helper_data/get_org_members.json",
package = "gitear"))
# repositories of a organization
-content_list_repos_org <- fromJSON(system.file("helper_data/get_repos_org.json",
+content_list_repos_org <- jsonlite::fromJSON(system.file("helper_data/get_repos_org.json",
package = "gitear"))
# list users
-content_list_users <- fromJSON(system.file("helper_data/get_users.json",
+content_list_users <- jsonlite::fromJSON(system.file("helper_data/get_users.json",
package = "gitear"))
# milestones
-content_milestones <- fromJSON(system.file("helper_data/get_milestones.json",
+content_milestones <- jsonlite::fromJSON(system.file("helper_data/get_milestones.json",
package = "gitear"))
# organizations
-content_organizations <- fromJSON(system.file("helper_data/get_organizations.json",
+content_organizations <- jsonlite::fromJSON(system.file("helper_data/get_organizations.json",
package = "gitear"))
# pull requests
-content_pull_req <- fromJSON(system.file("helper_data/get_pull_request.json",
+content_pull_req <- jsonlite::fromJSON(system.file("helper_data/get_pull_request.json",
package = "gitear"))
# releases
-content_releases <- fromJSON(system.file("helper_data/get_releases.json",
+content_releases <- jsonlite::fromJSON(system.file("helper_data/get_releases.json",
package = "gitear"))
# repositories
-content_repositories <- fromJSON(system.file("helper_data/get_repositories.json",
+content_repositories <- jsonlite::fromJSON(system.file("helper_data/get_repositories.json",
package = "gitear"))
# issue times
-content_issue_times <- fromJSON(system.file("helper_data/get_issue_times.json",
+content_issue_times <- jsonlite::fromJSON(system.file("helper_data/get_issue_times.json",
package = "gitear"))
# version gitea
-content_version <- fromJSON(system.file("helper_data/get_version.json",
+content_version <- jsonlite::fromJSON(system.file("helper_data/get_version.json",
package = "gitear"))
diff --git a/vignettes/Access-gitea-from-R.Rmd b/vignettes/Access-gitea-from-R.Rmd
index a2f22ae..bcf0043 100644
--- a/vignettes/Access-gitea-from-R.Rmd
+++ b/vignettes/Access-gitea-from-R.Rmd
@@ -1,193 +1,193 @@
----
-title: "Access Gitea from R"
-author: "ixpantia"
-date: "`r Sys.Date()`"
-output: rmarkdown::html_vignette
-vignette: >
- %\VignetteIndexEntry{Access Gitea from R}
- %\VignetteEngine{knitr::rmarkdown}
- \usepackage[utf8]{inputenc}
-editor_options:
- chunk_output_type: console
----
-
-```{r setup, include = FALSE}
-knitr::opts_chunk$set(
- collapse = TRUE,
- comment = "#>"
-)
-
-library(gitear)
-library(dplyr)
-library(jsonlite)
-
-r <- readRDS(system.file("helper_data/response_example.RDS",
- package = "gitear"))
-
-content_an_organization <- fromJSON(system.file("helper_data/get_an_org.json",
- package = "gitear"))
-
-content_issues <- fromJSON(system.file("helper_data/get_issues.json",
- package = "gitear"))
-
-content_list_repos_org <- fromJSON(system.file("helper_data/get_repos_org.json",
- package = "gitear"))
-
-content_list_users <- fromJSON(system.file("helper_data/get_users.json",
- package = "gitear"))
-
-content_commits <- fromJSON(system.file("helper_data/get_commits.json",
- package = "gitear"))
-
-```
-
-Gitea is a community managed, lightweight code hosting solution were projects
-and their respective git repositories can be managed . This
-package gives an interface to the 'Gitea' API to access and manage
-repositories, issues and organizations directly in R.
-
-## Starting with `gitear`
-
-If you want to start using the functions from `gitear` you should first go to
-your gitea service and create an API KEY. You will find this under your avatar,
-configuration, application and then generate a new token.
-
-Be aware that you should save this token somewhere because its shown just once.
-
-This is going to be your API TOKEN. Then you can use a function like this:
-
-```{r, echo = FALSE}
-mockery::stub(where = get_issues,
- what = "GET",
- how = r)
-
-mockery::stub(where = get_issues,
- what = "fromJSON",
- how = content_issues)
-```
-
-```{r}
-# Credentials
-
-api_token <- "gfdsgfd8ba18a866bsdfgsdfgs3a2dc9303453b0c92dcfb19"
-url_ixpantia <- "https://prueba.com"
-
-# Example function use:
-
-issues <- get_issues(base_url = url_ixpantia,
- api_key = api_token,
- owner = "empresa",
- repo = "repo_prueba")
-
-glimpse(issues)
-```
-
-
-For the examples below, we are going to use credentials stored in a .Renviron
-file, which we are going to call from this variables:
-
-```{r}
-example_key <- Sys.getenv("example_key")
-example_url <- Sys.getenv("example_url")
-```
-
-## Get information about your organization
-
-We can also obtain information from some organization defined in our gitea
-service:
-
-```{r, echo = FALSE}
-mockery::stub(where = get_an_organization,
- what = "GET",
- how = r)
-
-mockery::stub(where = get_an_organization,
- what = "fromJSON",
- how = content_an_organization)
-```
-
-```{r}
-# Example function use
-
-organizations <- get_an_organization(base_url = example_url,
- api_key = example_key,
- org = "empresa")
-
-glimpse(organizations)
-```
-
-## Get repositories information from one organization
-
-And we can also see which repositories are associated with that same organization:
-
-```{r, echo = FALSE}
-mockery::stub(where = get_list_repos_org,
- what = "GET",
- how = r)
-
-mockery::stub(where = get_list_repos_org,
- what = "fromJSON",
- how = content_list_repos_org)
-```
-
-```{r}
-# Example function use
-
-repos <- get_list_repos_org(base_url = example_url,
- api_key = example_key,
- org = "empresa")
-
-glimpse(repos)
-```
-
-## User information
-
-But we can not only get information about projects and repositories, we can
-also see specific information about users:
-
-```{r, echo = FALSE}
-mockery::stub(where = get_list_users,
- what = "GET",
- how = r)
-
-mockery::stub(where = get_list_users,
- what = "fromJSON",
- how = content_list_users)
-```
-
-```{r}
-# Example function use
-
-users <- get_list_users(base_url = example_url,
- api_key = example_key)
-
-glimpse(users)
-```
-
-## All commits from a specific repository
-
-We can also see the commits made to a certain repository in a very simple way
-
-```{r, echo = FALSE}
-mockery::stub(where = get_commits,
- what = "GET",
- how = r)
-
-mockery::stub(where = get_commits,
- what = "fromJSON",
- how = content_commits)
-```
-
-```{r}
-# Example function use
-
-commits <- get_commits(base_url = example_url,
- api_key = example_key,
- owner = "empresa",
- repo = "repo_prueba")
-
-head(commits)
-```
-
-These are just some of the functionality of gitea, there are other information
-that we can obtain about a gitea service.
+---
+title: "Access Gitea from R"
+author: "ixpantia"
+date: "`r Sys.Date()`"
+output: rmarkdown::html_vignette
+vignette: >
+ %\VignetteIndexEntry{Access Gitea from R}
+ \usepackage[utf8]{inputenc}
+ %\VignetteEngine{knitr::rmarkdown}
+editor_options:
+ chunk_output_type: console
+---
+
+```{r setup, include = FALSE}
+knitr::opts_chunk$set(
+ collapse = TRUE,
+ comment = "#>"
+)
+
+library(gitear)
+library(dplyr)
+library(jsonlite)
+
+r <- readRDS(system.file("helper_data/response_example.RDS",
+ package = "gitear"))
+
+content_an_organization <- jsonlite::fromJSON(system.file("helper_data/get_an_org.json",
+ package = "gitear"))
+
+content_issues <- jsonlite::fromJSON(system.file("helper_data/get_issues.json",
+ package = "gitear"))
+
+content_list_repos_org <- jsonlite::fromJSON(system.file("helper_data/get_repos_org.json",
+ package = "gitear"))
+
+content_list_users <- jsonlite::fromJSON(system.file("helper_data/get_users.json",
+ package = "gitear"))
+
+content_commits <- jsonlite::fromJSON(system.file("helper_data/get_commits.json",
+ package = "gitear"))
+
+```
+
+Gitea is a community managed, lightweight code hosting solution were projects
+and their respective git repositories can be managed . This
+package gives an interface to the 'Gitea' API to access and manage
+repositories, issues and organizations directly in R.
+
+## Starting with `gitear`
+
+If you want to start using the functions from `gitear` you should first go to
+your gitea service and create an API KEY. You will find this under your avatar,
+configuration, application and then generate a new token.
+
+Be aware that you should save this token somewhere because its shown just once.
+
+This is going to be your API TOKEN. Then you can use a function like this:
+
+```{r, echo = FALSE}
+mockery::stub(where = get_issues,
+ what = "GET",
+ how = r)
+
+mockery::stub(where = get_issues,
+ what = "fromJSON",
+ how = content_issues)
+```
+
+```{r}
+# Credentials
+
+api_token <- "gfdsgfd8ba18a866bsdfgsdfgs3a2dc9303453b0c92dcfb19"
+url_ixpantia <- "https://prueba.com"
+
+# Example function use:
+
+issues <- get_issues(base_url = url_ixpantia,
+ api_key = api_token,
+ owner = "empresa",
+ repo = "repo_prueba")
+
+glimpse(issues)
+```
+
+
+For the examples below, we are going to use credentials stored in a .Renviron
+file, which we are going to call from this variables:
+
+```{r}
+example_key <- Sys.getenv("example_key")
+example_url <- Sys.getenv("example_url")
+```
+
+## Get information about your organization
+
+We can also obtain information from some organization defined in our gitea
+service:
+
+```{r, echo = FALSE}
+mockery::stub(where = get_an_organization,
+ what = "GET",
+ how = r)
+
+mockery::stub(where = get_an_organization,
+ what = "fromJSON",
+ how = content_an_organization)
+```
+
+```{r}
+# Example function use
+
+organizations <- get_an_organization(base_url = example_url,
+ api_key = example_key,
+ org = "empresa")
+
+glimpse(organizations)
+```
+
+## Get repositories information from one organization
+
+And we can also see which repositories are associated with that same organization:
+
+```{r, echo = FALSE}
+mockery::stub(where = get_list_repos_org,
+ what = "GET",
+ how = r)
+
+mockery::stub(where = get_list_repos_org,
+ what = "fromJSON",
+ how = content_list_repos_org)
+```
+
+```{r}
+# Example function use
+
+repos <- get_list_repos_org(base_url = example_url,
+ api_key = example_key,
+ org = "empresa")
+
+glimpse(repos)
+```
+
+## User information
+
+But we can not only get information about projects and repositories, we can
+also see specific information about users:
+
+```{r, echo = FALSE}
+mockery::stub(where = get_list_users,
+ what = "GET",
+ how = r)
+
+mockery::stub(where = get_list_users,
+ what = "fromJSON",
+ how = content_list_users)
+```
+
+```{r}
+# Example function use
+
+users <- get_list_users(base_url = example_url,
+ api_key = example_key)
+
+glimpse(users)
+```
+
+## All commits from a specific repository
+
+We can also see the commits made to a certain repository in a very simple way
+
+```{r, echo = FALSE}
+mockery::stub(where = get_commits,
+ what = "GET",
+ how = r)
+
+mockery::stub(where = get_commits,
+ what = "fromJSON",
+ how = content_commits)
+```
+
+```{r}
+# Example function use
+
+commits <- get_commits(base_url = example_url,
+ api_key = example_key,
+ owner = "empresa",
+ repo = "repo_prueba")
+
+head(commits)
+```
+
+These are just some of the functionality of gitea, there are other information
+that we can obtain about a gitea service.