Skip to content
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
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: objr
Title: Wrapper for Objective APIs
Version: 0.1.1.9000
Version: 0.2.0
Authors@R: c(
person("Scottish Government", , , "[email protected]", role = "cph"),
person("Alice", "Hannah", , "[email protected]", role = c("aut", "cre"))
Expand Down
36 changes: 20 additions & 16 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,39 @@
# objr (development version)
# objr 0.2.0

* Added `CONTRIBUTING.md` and `SUPPORT.md` (#36).
## New features

* `download_file()` now returns file path (invisibly) (#38).

* `download_file()` now accepts custom file name in `file_name` argument (#37).
* New `mobile_auth_status()` and `mobile_auth_login()` support use of
[mobile authentication](https://secure.objectiveconnect.co.uk/publicapi/1/swagger-ui/index.html?configUrl=/publicapi/1/v3/api-docs/swagger-config#/MobileAuth)
(#52).

* `download_file()` now writes files with percent-decoded names
(e.g. `file%20name.csv` is now `file name.csv`) (#34).
* New `workgroup_mandate_2fa()` provides ability to enable or disable mandatory
two-factor authentication (2FA) in workgroups (#65).

* Fixed an issue where temporary files sometimes persisted after running
`download_file()` or `read_data()` (#39).
* `read_data()` and `write_data()` now support reading and writing of parquet
files (#54).

* Added support for parquet files in `read/write_data` and
`read/write_data_version()`(#54).
* `download_file()` gains a `file_name` argument to supply a custom name (#37).

* Added support for [mobile authentication](https://secure.objectiveconnect.co.uk/publicapi/1/swagger-ui/index.html?configUrl=/publicapi/1/v3/api-docs/swagger-config#/MobileAuth)
to view status (`mobile_auth_staus()`) and to login (`mobile_auth_login()`)
(#52).
## Lifecycle changes

* In `assets()`, `type` now expects a string instead of a list. This was
prompted by a change to the underlying API, where results can now only be
filtered by one asset type at a time (#53).

* New `workgroup_mandate_2fa()` provides ability to enable or disable mandatory
two-factor authentication (2FA) in workgroups (#65).
## Minor improvements and bug fixes

* Expiry time is now stored alongside the authentication token (`token`). If a
token is expired, it will be removed from the Global Environment and
authentication will be attempted with username and password instead (#35).

* `download_file()` now returns file path (invisibly) (#38).

* `download_file()` now writes files with percent-decoded names
(e.g. `file%20name.csv` is now `file name.csv`) (#34).

* Fixed an issue where temporary files sometimes persisted after running
`download_file()` or `read_data()` (#39).

# objr 0.1.1

* Set minimum versions for `dplyr` and `tidyr` dependencies (#32).
Expand Down
5 changes: 4 additions & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ convert_to_epoch <- function(date_time,
#' Convert number of milliseconds to epoch to date or datetime object
#'
#' @param x Numeric.
#' @param tz Character string, passed to `as.POSIXct`. Default value of "" uses
#' current time zone.
#'
#' @details If NULL is supplied, NULL is returned.
#'
Expand All @@ -298,6 +300,7 @@ convert_to_epoch <- function(date_time,
#' @noRd

convert_from_epoch <- function(x,
tz = "",
error_arg = rlang::caller_arg(x),
error_call = rlang::caller_env()) {

Expand All @@ -313,6 +316,6 @@ convert_from_epoch <- function(x,
)
}

as.POSIXct(x / 1000, origin = "1970-01-01")
as.POSIXct(x / 1000, origin = "1970-01-01", tz = tz)

}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ library(objr)
```

Help files for each function in the package can be found on the
[References](https://ScotGovAnalysis.github.io/objr/reference) page of the package website. Alternatively, type `?function_name` into the
[References](https://ScotGovAnalysis.github.io/objr/reference/) page of the package website. Alternatively, type `?function_name` into the
RStudio console. For example:

``` r
Expand Down
8 changes: 4 additions & 4 deletions tests/testthat/test-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,12 @@ test_that("Error produced if not NULL or POSIXct", {
test_that("Correct value returned", {

expect_equal(
convert_to_epoch(as.POSIXct("2024-01-01 09:00:00")),
convert_to_epoch(as.POSIXct("2024-01-01 09:00:00", tz = "GMT")),
1704099600000
)

expect_equal(
convert_to_epoch(as.POSIXct("2024-01-01")),
convert_to_epoch(as.POSIXct("2024-01-01", tz = "GMT")),
1704067200000
)

Expand All @@ -234,8 +234,8 @@ test_that("Error produced if not NULL or numeric", {
test_that("Correct value returned", {

expect_equal(
convert_from_epoch(1704099600000),
as.POSIXct("2024-01-01 09:00:00")
convert_from_epoch(1704099600000, tz = "GMT"),
as.POSIXct("2024-01-01 09:00:00", tz = "GMT")
)

expect_equal(convert_from_epoch(NULL), NULL)
Expand Down