No flags found
Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.
e.g., #unittest #integration
#production #enterprise
#frontend #backend
a5ced8c
... +0 ...
2be3dd2
Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.
e.g., #unittest #integration
#production #enterprise
#frontend #backend
41 | 41 | #' get_parameters("TEMP") |
|
42 | 42 | #' @export |
|
43 | 43 | get_parameters <- function(data_item){ |
|
44 | - | return(get_parameters_list[[upper_case(data_item)]]) |
|
44 | + | get_parameters_list[[upper_case(data_item)]] |
|
45 | 45 | } |
|
46 | 46 | ||
47 | 47 |
71 | 71 | else { |
|
72 | 72 | stop("type parameter is not valid") |
|
73 | 73 | } |
|
74 | - | return(ret) |
|
74 | + | ret |
|
75 | 75 | } |
|
76 | 76 | ||
77 | 77 | #' Get a vector containing all of the permissible data items |
91 | 91 | } |
|
92 | 92 | ||
93 | 93 | } |
|
94 | - | return(ret) |
|
94 | + | ret |
|
95 | 95 | } |
|
96 | 96 | ||
97 | 97 | #' Get the column names for a returned CSV Legacy dataset |
105 | 105 | stop("Not a valid Legacy data item") |
|
106 | 106 | } |
|
107 | 107 | ||
108 | - | return(get_column_names_list[[data_item]]) |
|
108 | + | get_column_names_list[[data_item]] |
|
109 | 109 | } |
|
110 | 110 | ||
111 | 111 | #' Reformat date, time, and datetime columns |
132 | 132 | return(x) |
|
133 | 133 | } |
|
134 | 134 | ||
135 | + | ||
136 | + | #' Convert a parameter name to a different format |
|
137 | + | #' |
|
138 | + | #' The names of the parameters that are used in the R functions do not perfectly correspond with the parameter name expected by the API. This |
|
139 | + | #' function converts an argument parameter name (e.g. `settlement_date`) to the URL argument name (e.g. `SettlementDate`) or the other way around |
|
140 | + | #' @param parameter character; name of the parameter provided to the relevant `build()` function |
|
141 | + | #' @param from character; one of "argument" or "url" depending on whether `parameter` is in the argument or URL format |
|
142 | + | #' @param to character; one of "argument" or "url" |
|
143 | + | #' @return character; name of the parameter used in the URL request or `build()` function. If no match is found, `character(0)` |
|
144 | + | #' @export |
|
145 | + | change_parameter_name <- function(parameter, from = c("argument", "url"), to = c("url", "argument")) { |
|
146 | + | from <- match.arg(from) |
|
147 | + | to <- match.arg(to) |
|
148 | + | from_col <- rlang::sym(paste0(from, "_name")) |
|
149 | + | to_col <- rlang::sym(paste0(to, "_name")) |
|
150 | + | results <- dplyr::filter(parameter_name_map, {{ from_col }} == parameter) |
|
151 | + | dplyr::pull(results, {{ to_col }}) |
|
152 | + | } |
|
153 | + | ||
154 | + | #' Get the cleaning function required for a parameter |
|
155 | + | #' |
|
156 | + | #' Before a parameter can be added to a request, it often needs to be cleaned. This function returns the appropriate function for a parameter. |
|
157 | + | #' Parameters can be supplied with their name used in the `build()` functions ("argument") or in the URL |
|
158 | + | #' @param character; name of the parameter. Either the parameter as it's passed to the `build()` functions or the name of the parameter in the URL |
|
159 | + | #' depending on the value of `format` |
|
160 | + | #' @param format character; what format is `parameter` in? One of "argument" (default) or "url" |
|
161 | + | #' @return character; name of the cleaning function |
|
162 | + | #' @export |
|
163 | + | get_cleaning_function <- function(parameter, format = c("argument", "url")) { |
|
164 | + | format <- match.arg(format) |
|
165 | + | if (format == "url") { |
|
166 | + | parameter <- change_parameter_name(parameter, from = "url", to = "argument") |
|
167 | + | } |
|
168 | + | dplyr::filter(parameter_clean_functions_map, name == parameter)[["function"]] |
|
169 | + | } |
244 | 244 | #' Default is TRUE. |
|
245 | 245 | #' @param ... values to be passed to appropriate build_x_call function |
|
246 | 246 | #' @family call-building functions |
|
247 | - | #' @seealso \code{\link{build_b_call}} |
|
248 | - | #' @seealso \code{\link{build_remit_call}} |
|
249 | - | #' @seealso \code{\link{build_legacy_call}} |
|
247 | + | #' @seealso [build_b_call()] |
|
248 | + | #' @seealso [build_remit_call()] |
|
249 | + | #' @seealso [build_legacy_call()] |
|
250 | 250 | #' @examples |
|
251 | 251 | #' build_call(data_item = "TEMP", api_key = "12345", from_date = "12 Jun 2018", |
|
252 | 252 | #' to_date = "13 Jun 2018", service_type = "csv") |
72 | 72 | #' Parse a .csv response with a EOF tag left in |
|
73 | 73 | #' |
|
74 | 74 | #' Some .csv files returned from the API still have an EOF tag left at the bottom and contain 4 lines of nonsense. |
|
75 | - | #' This function is used to parse these files, whereas the \code{parse_clean_csv()} function is used to |
|
75 | + | #' This function is used to parse these files, whereas the `parse_clean_csv()` function is used to |
|
76 | 76 | #' parse .csv files without this tag and the junk lines. |
|
77 | 77 | #' @param content character; the original response object parsed as a single text string. |
|
78 | 78 | #' @return tibble; a tibble containing the data in the .csv file |
92 | 92 | #' Parse a 'clean' .csv response |
|
93 | 93 | #' |
|
94 | 94 | #' Some .csv files are returned without the EOF tag and with only 1 line before the data. This |
|
95 | - | #' function is used to parse these files, whereas the \code{parse_eof_csv()} function is used |
|
95 | + | #' function is used to parse these files, whereas the `parse_eof_csv()` function is used |
|
96 | 96 | #' to parse those files with the EOF tag and junk lines. |
|
97 | 97 | #' @param content character; the original response object parsed as a single text string. |
|
98 | 98 | #' @return tibble; a tibble containing the data in the .csv file |
111 | 111 | #' This simple wrapper returns an empty tibble on error and returns a custom warning message. |
|
112 | 112 | #' @param expr expression; expression to be evaluated for errors |
|
113 | 113 | #' @param error_message character; character string to be displayed as a warning on error |
|
114 | - | #' @param ... extra parameters to be passed to the \code{tryCatch()} function. |
|
114 | + | #' @param ... extra parameters to be passed to the `tryCatch()` function. |
|
115 | 115 | #' @return evaluated expression on success or empty tibble on error |
|
116 | 116 | try_parse <- function(expr, error_message, ...) { |
|
117 | 117 | tryCatch({ |
Learn more Showing 2 files with coverage changes found.
R/data_item.R
R/parameter.R
Files | Coverage |
---|---|
build.R | 100.00% |
data_item.R | 0.00% |
main.R | 100.00% |
non_export_util.R | 98.15% |
parameter.R | 0.00% |
parse.R | 27.08% |
send_receive.R | 100.00% |
utility.R | -21.14% 76.09% |
Folder Totals (8 files) | 78.31% |
Project Totals (8 files) | 78.31% |
2be3dd2
a5ced8c