# sunagriAPI
#
# An instance of OpenSILEX WebService
#
# OpenAPI spec version: 3.3.0
#
# Generated by: https://github.com/swagger-api/swagger-codegen.git
#' @title Documents operations
#' @description phisWSClientRTools.Documents
#'
#' @field path Stores url path of the request.
#' @field apiClient Handles the client-server communication.
#' @field userAgent Set the user agent of the request.
#'
#' @importFrom R6 R6Class
#'
#' @section Methods:
#' \describe{
#'
#' get_document_by_uri Get a document (by receiving it's uri)
#'
#'
#' get_documents_metadata_by_search Get all documents metadata corresponding to the searched params given
#'
#'
#' get_documents_type Get all documents types
#'
#'
#' post_document_file Post data file
#'
#'
#' post_documents Save a file
#'
#'
#' put_document_metadata Update document metadata
#'
#' }
#'
#' @export
DocumentsApi <- R6::R6Class(
'DocumentsApi',
public = list(
userAgent = "Swagger-Codegen/3.3.0/r",
apiClient = NULL,
initialize = function(apiClient){
if (!missing(apiClient)) {
self$apiClient <- apiClient
}
else {
self$apiClient <- ApiClient$new()
}
},
get_document_by_uri = function(document_uri,...){
args <- list(...)
queryParams <- list()
headerParams <- character()
self$apiClient$basePath = sub("/$", "",get("BASE_PATH",opensilexWSClientR:::configWS))
if(self$apiClient$basePath == ""){
stop("Wrong you must first connect with connectToPHISWS")
}
#if (!missing(`authorization`)) {
# headerParams['Authorization'] <- authorization
#}
urlPath <- "/documents/{documentURI}"
if (!missing(`document_uri`)) {
urlPath <- gsub(paste0("\\{", "documentURI", "\\}"), `document_uri`, urlPath)
}
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
method = "GET",
queryParams = queryParams,
headerParams = headerParams,
body = body,
...)
method = "GET"
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
# void response, no need to return anything
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
return(Response$new(json$metadata, json, resp, FALSE))
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
return(Response$new(json$metadata, json, resp, FALSE))
}
},
get_documents_metadata_by_search = function(page_size,page,uri,document_type,creator,language,title,creation_date,extension,concerned_item,status,sort_by_date,...){
args <- list(...)
queryParams <- list()
headerParams <- character()
self$apiClient$basePath = sub("/$", "",get("BASE_PATH",opensilexWSClientR:::configWS))
if(self$apiClient$basePath == ""){
stop("Wrong you must first connect with connectToPHISWS")
}
#if (!missing(`authorization`)) {
# headerParams['Authorization'] <- authorization
#}
if (!missing(`page_size`)) {
queryParams['pageSize'] <- page_size
}
if (!missing(`page`)) {
queryParams['page'] <- page
}
if (!missing(`uri`)) {
queryParams['uri'] <- uri
}
if (!missing(`document_type`)) {
queryParams['documentType'] <- document_type
}
if (!missing(`creator`)) {
queryParams['creator'] <- creator
}
if (!missing(`language`)) {
queryParams['language'] <- language
}
if (!missing(`title`)) {
queryParams['title'] <- title
}
if (!missing(`creation_date`)) {
queryParams['creationDate'] <- creation_date
}
if (!missing(`extension`)) {
queryParams['extension'] <- extension
}
if (!missing(`concerned_item`)) {
queryParams['concernedItem'] <- concerned_item
}
if (!missing(`status`)) {
queryParams['status'] <- status
}
if (!missing(`sort_by_date`)) {
queryParams['sortByDate'] <- sort_by_date
}
urlPath <- "/documents"
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
method = "GET",
queryParams = queryParams,
headerParams = headerParams,
body = body,
...)
method = "GET"
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
if(method == "GET"){
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
data <- json$result$data
returnedOjects = list()
for(i in 1:nrow(data)){
row <- data[i,]
returnObject <- DocumentMetadataDTO$new()
returnObject$fromJSONObject(row)
returnedOjects = c(returnedOjects,returnObject)
}
return(Response$new(json$metadata,returnedOjects, resp, TRUE))
}
if(method == "POST" || method == "PUT"){
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
return(Response$new(json$metadata, json$result$datafiles, resp, TRUE))
}
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
return(Response$new(json$metadata, json, resp, FALSE))
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
return(Response$new(json$metadata, json, resp, FALSE))
}
},
get_documents_type = function(page_size,page,...){
args <- list(...)
queryParams <- list()
headerParams <- character()
self$apiClient$basePath = sub("/$", "",get("BASE_PATH",opensilexWSClientR:::configWS))
if(self$apiClient$basePath == ""){
stop("Wrong you must first connect with connectToPHISWS")
}
#if (!missing(`authorization`)) {
# headerParams['Authorization'] <- authorization
#}
if (!missing(`page_size`)) {
queryParams['pageSize'] <- page_size
}
if (!missing(`page`)) {
queryParams['page'] <- page
}
urlPath <- "/documents/types"
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
method = "GET",
queryParams = queryParams,
headerParams = headerParams,
body = body,
...)
method = "GET"
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
# void response, no need to return anything
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
return(Response$new(json$metadata, json, resp, FALSE))
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
return(Response$new(json$metadata, json, resp, FALSE))
}
},
post_document_file = function(body,uri,...){
args <- list(...)
queryParams <- list()
headerParams <- character()
self$apiClient$basePath = sub("/$", "",get("BASE_PATH",opensilexWSClientR:::configWS))
if(self$apiClient$basePath == ""){
stop("Wrong you must first connect with connectToPHISWS")
}
#if (!missing(`authorization`)) {
# headerParams['Authorization'] <- authorization
#}
if (!missing(`uri`)) {
queryParams['uri'] <- uri
}
if (!missing(`body`)) {
if(is.list(`body`)){
bodyList <- lapply(`body`, function(x){x$toJSONString()})
bodyListPaste <- paste(bodyList, collapse=', ' )
body <- paste('[',bodyListPaste,']')
}else{
body <- paste('[',`body`$toJSONString(),']')
}
} else {
body <- NULL
}
urlPath <- "/documents/upload"
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
method = "POST",
queryParams = queryParams,
headerParams = headerParams,
body = body,
...)
method = "POST"
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
if(method == "GET"){
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
data <- json$result$data
returnedOjects = list()
for(i in 1:nrow(data)){
row <- data[i,]
returnObject <- ResponseFormPOST$new()
returnObject$fromJSONObject(row)
returnedOjects = c(returnedOjects,returnObject)
}
return(Response$new(json$metadata,returnedOjects, resp, TRUE))
}
if(method == "POST" || method == "PUT"){
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
return(Response$new(json$metadata, json$result$datafiles, resp, TRUE))
}
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
return(Response$new(json$metadata, json, resp, FALSE))
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
return(Response$new(json$metadata, json, resp, FALSE))
}
},
post_documents = function(body,...){
args <- list(...)
queryParams <- list()
headerParams <- character()
self$apiClient$basePath = sub("/$", "",get("BASE_PATH",opensilexWSClientR:::configWS))
if(self$apiClient$basePath == ""){
stop("Wrong you must first connect with connectToPHISWS")
}
#if (!missing(`authorization`)) {
# headerParams['Authorization'] <- authorization
#}
if (!missing(`body`)) {
if(is.list(`body`)){
bodyList <- lapply(`body`, function(x){x$toJSONString()})
bodyListPaste <- paste(bodyList, collapse=', ' )
body <- paste('[',bodyListPaste,']')
}else{
body <- paste('[',`body`$toJSONString(),']')
}
} else {
body <- NULL
}
urlPath <- "/documents"
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
method = "POST",
queryParams = queryParams,
headerParams = headerParams,
body = body,
...)
method = "POST"
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
if(method == "GET"){
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
data <- json$result$data
returnedOjects = list()
for(i in 1:nrow(data)){
row <- data[i,]
returnObject <- DocumentMetadataDTO$new()
returnObject$fromJSONObject(row)
returnedOjects = c(returnedOjects,returnObject)
}
return(Response$new(json$metadata,returnedOjects, resp, TRUE))
}
if(method == "POST" || method == "PUT"){
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
return(Response$new(json$metadata, json$result$datafiles, resp, TRUE))
}
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
return(Response$new(json$metadata, json, resp, FALSE))
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
return(Response$new(json$metadata, json, resp, FALSE))
}
},
put_document_metadata = function(body,...){
args <- list(...)
queryParams <- list()
headerParams <- character()
self$apiClient$basePath = sub("/$", "",get("BASE_PATH",opensilexWSClientR:::configWS))
if(self$apiClient$basePath == ""){
stop("Wrong you must first connect with connectToPHISWS")
}
#if (!missing(`authorization`)) {
# headerParams['Authorization'] <- authorization
#}
if (!missing(`body`)) {
if(is.list(`body`)){
bodyList <- lapply(`body`, function(x){x$toJSONString()})
bodyListPaste <- paste(bodyList, collapse=', ' )
body <- paste('[',bodyListPaste,']')
}else{
body <- paste('[',`body`$toJSONString(),']')
}
} else {
body <- NULL
}
urlPath <- "/documents"
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
method = "PUT",
queryParams = queryParams,
headerParams = headerParams,
body = body,
...)
method = "PUT"
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
if(method == "GET"){
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
data <- json$result$data
returnedOjects = list()
for(i in 1:nrow(data)){
row <- data[i,]
returnObject <- ResponseFormPOST$new()
returnObject$fromJSONObject(row)
returnedOjects = c(returnedOjects,returnObject)
}
return(Response$new(json$metadata,returnedOjects, resp, TRUE))
}
if(method == "POST" || method == "PUT"){
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
return(Response$new(json$metadata, json$result$datafiles, resp, TRUE))
}
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
return(Response$new(json$metadata, json, resp, FALSE))
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
return(Response$new(json$metadata, json, resp, FALSE))
}
}
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.