diff --git a/NAMESPACE b/NAMESPACE index 4593fd5..9b487dc 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,8 +1,6 @@ # Generated by roxygen2: do not edit by hand -export(companyInfo) export(getData) import(httr) importFrom(dplyr,bind_rows) -importFrom(httr,GET) importFrom(magrittr,`%>%`) diff --git a/R/vndirect.R b/R/vndirect.R index c7b337f..a9ec99a 100644 --- a/R/vndirect.R +++ b/R/vndirect.R @@ -77,44 +77,4 @@ getData <- function(.tickers = NULL, .size = 100) { } -#' Company Information -#' -#' Retrieves company information from the VNDIRECT API for a given ticker. -#' -#' @param .ticker Ticker with 3 characters. Pass this parameter if you want to return information for a specific company. -#' @return A data frame containing company information. -#' @importFrom httr GET -#' @importFrom magrittr `%>%` -#' @export -#' -#' @examples -#' # Retrieve information for a specific company -#' cpn_info <- companyInfo() -#' -#' @export -companyInfo <- function(.ticker = NULL) { - # Check if .ticker is valid - if (is.null(.ticker) || nchar(.ticker) != 3) { - stop('Invalid or missing .ticker. Please provide a valid 3-character ticker.') - } - - # Define the base URL and endpoint - base <- 'https://finfo-api.vndirect.com.vn/v4/stocks' - endpoint <- paste0(base, "code:", .ticker) - - # Send the HTTP request - res <- httr::GET(url = base, query = params) - - # Check if the HTTP request was successful - if (httr::http_error(res)) { - stop(paste('Failed to retrieve data for ticker:', .ticker)) - } - - # Extract and process the data - df_company_info <- httr::content(res, "parsed")$data %>% - purrr::map_dfr(bind_rows) - - return(df_company_info) -} - diff --git a/README.md b/README.md index 663e01f..6938ff9 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,7 @@ dplyr::glimpse(dt) ## $ adChange 0.5, -0.6, -0.2, -1.6, 0.1, -0.6, 0.2, -0.3, 0.5, 0.0, 1.~ ## $ pctChange 0.5917, -0.7051, -0.2345, -1.8412, 0.1152, -0.6865, 0.229~ + ``` vndirect ├─ cran-comments.md @@ -68,9 +69,7 @@ vndirect ├─ DESCRIPTION ├─ LICENSE ├─ man -│ ├─ vnd_company_info.Rd -│ ├─ vnd_get_data.Rd -│ └─ vnd_get_list_data.Rd +│ └─ getData.Rd ├─ NAMESPACE ├─ R │ └─ vndirect.R diff --git a/man/companyInfo.Rd b/man/companyInfo.Rd deleted file mode 100644 index 1b1b2be..0000000 --- a/man/companyInfo.Rd +++ /dev/null @@ -1,22 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/vndirect.R -\name{companyInfo} -\alias{companyInfo} -\title{Company Information} -\usage{ -companyInfo(.ticker = NULL) -} -\arguments{ -\item{.ticker}{Ticker with 3 characters. Pass this parameter if you want to return information for a specific company.} -} -\value{ -A data frame containing company information. -} -\description{ -Retrieves company information from the VNDIRECT API for a given ticker. -} -\examples{ -# Retrieve information for a specific company -cpn_info <- companyInfo() - -}