Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into add_report_args
Browse files Browse the repository at this point in the history
  • Loading branch information
rcannood committed Feb 5, 2024
2 parents 3336d41 + 327f2b5 commit d14f50b
Show file tree
Hide file tree
Showing 20 changed files with 118 additions and 55 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ README.html
^\.github$
^\.lintr$
^\.pre-commit-config\.yaml$
^\.venv
docs/
pkgdown
test.R
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.1.3
current_version = 0.1.4
commit = True
tag = True

Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@ jobs:
- name: Install package
run: R CMD INSTALL .

- name: Check test coverage
run: |
covr::codecov()
shell: Rscript {0}

- name: Build {pkgdown} documentation
run: |
git config --local user.email "[email protected]"
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ README.html
clockify*.tar.gz
clockify*.tgz
docs/
.venv/
12 changes: 5 additions & 7 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
Package: clockify
Type: Package
Title: A Wrapper for the 'Clockify' API
Version: 0.1.3
Version: 0.1.4
Authors@R:
c(person(given = c("Andrew", "B."),
family = "Collier",
role = c("aut", "cre"),
email = "[email protected]"),
person(given = "Megan",
family = "Beckett",
role = "ctb",
email = "[email protected]"))
Description: A wrapper for the Clockify API <https://clockify.me/developers-api>, making it possible to query, insert and update time keeping data.
email = "[email protected]"))
Description: A wrapper for the Clockify API <https://docs.clockify.me/>, making it possible to query, insert and update time keeping data.
License: GPL-3
Encoding: UTF-8
LazyData: true
Expand All @@ -24,8 +20,10 @@ Imports:
janitor,
logger,
lubridate,
methods,
purrr,
rlist,
stringi,
tibble,
tidyr
Suggests:
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ import(janitor)
import(logger)
import(lubridate)
import(purrr)
import(stringi)
import(tibble)
import(tidyr)
importFrom(methods,is)
importFrom(stats,setNames)
19 changes: 14 additions & 5 deletions R/client.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
#' Parameters for client functions
#'
#' @name client-parameters
#'
#' @param client_id Client ID
#' @param concise Generate concise output
NULL

parse_client <- function(client, concise = TRUE) {
client <- client %$%
tibble(
Expand All @@ -19,7 +27,7 @@ parse_client <- function(client, concise = TRUE) {

#' Get clients
#'
#' @inheritParams users
#' @inheritParams client-parameters
#'
#' @return A data frame with one record per client.
#' @export
Expand All @@ -39,7 +47,7 @@ clients <- function(concise = TRUE) {

#' Get client
#'
#' @param client_id Client ID
#' @inheritParams client-parameters
#'
#' @return A data frame with one record per client
#' @export
Expand All @@ -51,16 +59,17 @@ clients <- function(concise = TRUE) {
client <- function(client_id, concise = TRUE) {
path <- sprintf("/workspaces/%s/clients/%s", workspace(), client_id)

clockify:::GET(path) %>%
GET(path) %>%
content() %>%
clockify:::parse_client(concise = concise)
parse_client(concise = concise)
}

#' Add a new client to workspace
#'
#' @inheritParams users
#'
#' @param name Client name
#' @inheritParams client-parameters
#'
#' @return A data frame with one row per record.
#' @export
Expand All @@ -81,7 +90,7 @@ client_create <- function(name, concise = TRUE) {

#' Update a client
#'
#' @param client_id Client ID
#' @inheritParams client-parameters
#' @param name Client name
#' @param note Note about client
#' @param archived Whether or not client is archived
Expand Down
10 changes: 10 additions & 0 deletions R/clockify.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@
#' @import anytime
#' @import lubridate
#' @import tibble
#' @import stringi
#' @importFrom stats setNames
#' @importFrom methods is
NULL

BASE_PATH <- "https://api.clockify.me/api/v1"
REPORTS_BASE_PATH <- "https://reports.api.clockify.me/v1"

globalVariables(
c(
"%$%",
".",
"address",
"amount",
Expand All @@ -32,13 +35,17 @@ globalVariables(
"error",
"fields",
"filters",
"fixed_date",
"groupOne",
"hourly_rate",
"is_public",
"link",
"memberships",
"name",
"project_color",
"project_id",
"public",
"report_author",
"start",
"status",
"template",
Expand All @@ -50,9 +57,12 @@ globalVariables(
"time_end",
"time_entry_id",
"time_start",
"type",
"user_id",
"user_ids",
"user_name",
"visible_to_users",
"visible_to_user_groups",
"workspace_id",
"workspaceId"
)
Expand Down
2 changes: 1 addition & 1 deletion R/http.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ check_response <- function(response) {

postfields <- response$request$options$postfields

if (!is.null(postfields) && class(postfields) == "raw") {
if (!is.null(postfields) && is(postfields, "raw")) {
log_debug("body: {rawToChar(postfields)}")
}
log_error("message: {content(response)$message}")
Expand Down
31 changes: 27 additions & 4 deletions R/reports-shared.R
Original file line number Diff line number Diff line change
@@ -1,20 +1,43 @@
EMPTY_SHARED_REPORTS <- tibble(
shared_report_id = character(),
workspace_id = character(),
user_id = character(),
report_author = character(),
name = character(),
link = character(),
visible_to_users = logical(),
visible_to_user_groups = logical(),
fixed_date = logical(),
type = character(),
visible_to_user_groups = logical(),
filter = logical(),
is_public = logical()
)

parse_shared_report_list <- function(reports) {
tibble(reports) %>%
reports <- tibble(reports) %>%
unnest_wider(reports) %>%
clean_names() %>%
select(shared_report_id = id, everything())
clean_names()

if (!("report_author" %in% names(reports))) reports$report_author <- NA
if (!("link" %in% names(reports))) reports$link <- NA
if (!("workspace_id" %in% names(reports))) reports$workspace_id <- NA
if (!("user_id" %in% names(reports))) reports$user_id <- NA
if (!("filter" %in% names(reports))) reports$filter <- NA

reports %>% select(
shared_report_id = id,
workspace_id,
user_id,
report_author,
name,
link,
visible_to_users,
visible_to_user_groups,
fixed_date,
type,
filter,
is_public
)
}

parse_shared_report <- function(report) {
Expand Down
4 changes: 4 additions & 0 deletions R/user.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ simplify_membership <- function(membership) {
} else {
m$hourlyRate <- list(as_tibble(m$hourlyRate))
}
if (is.null(m$costRate)) {
} else {
m$costRate <- list(as_tibble(m$costRate))
}
m
}) %>%
clean_names()
Expand Down
1 change: 1 addition & 0 deletions R/workspace.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ unpack_workspace <- function(workspace) {
workspace$featureSubscriptionType <- NULL
workspace$workspaceSettings <- NULL
workspace$hourlyRate <- NULL
workspace$costRate <- NULL

workspace$memberships <- list(simplify_membership(workspace$memberships))

Expand Down
4 changes: 2 additions & 2 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ library(dplyr)

<!-- badges: start -->
[![CRAN status](https://www.r-pkg.org/badges/version/clockify)](https://cran.r-project.org/package=clockify)
[![Codecov test coverage](https://img.shields.io/codecov/c/github/datawookie/clockify.svg)](https://codecov.io/github/datawookie/clockify)
[![Codecov test coverage](https://img.shields.io/codecov/c/github/datawookie/clockify.svg)](https://app.codecov.io/github/datawookie/clockify)
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html)<!-- badges: end -->

An R wrapper around the [Clockify API](https://clockify.me/developers-api).
An R wrapper around the [Clockify API](https://docs.clockify.me/).

The documentation for `{clockify}` is hosted at https://datawookie.github.io/clockify/.

Expand Down
46 changes: 22 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@
[![CRAN
status](https://www.r-pkg.org/badges/version/clockify)](https://cran.r-project.org/package=clockify)
[![Codecov test
coverage](https://img.shields.io/codecov/c/github/datawookie/clockify.svg)](https://codecov.io/github/datawookie/clockify)
coverage](https://img.shields.io/codecov/c/github/datawookie/clockify.svg)](https://app.codecov.io/github/datawookie/clockify)
[![Lifecycle:
experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html)<!-- badges: end -->

An R wrapper around the [Clockify
API](https://clockify.me/developers-api).
An R wrapper around the [Clockify API](https://docs.clockify.me/).

The documentation for `{clockify}` is hosted at
<https://datawookie.github.io/clockify/>.
Expand Down Expand Up @@ -65,7 +64,7 @@ workspaces()
# A tibble: 3 × 3
workspace_id name memberships
<chr> <chr> <list>
1 5ef46294df73063139f60bfc Fathom Data <tibble [18 × 6]>
1 5ef46294df73063139f60bfc Fathom Data <tibble [22 × 6]>
2 61343c45ab05e02be2c8c1fd Personal <tibble [2 × 4]>
3 630c61ba9c3a3c3112812332 {clockify} sandbox <tibble [5 × 6]>

Expand All @@ -86,9 +85,9 @@ user()
```

# A tibble: 1 × 3
user_id user_name status
<chr> <chr> <chr>
1 5f227e0cd7176a0e6e754409 Andrew ACTIVE
user_id user_name status
<chr> <chr> <chr>
1 5f227e0cd7176a0e6e754409 Andrew Collier ACTIVE

Get a list of users.

Expand All @@ -97,13 +96,13 @@ users()
```

# A tibble: 5 × 3
user_id user_name status
<chr> <chr> <chr>
1 5f227e0cd7176a0e6e754409 Andrew ACTIVE
2 630f17f04a05b20faf7e0afc Bob Smith ACTIVE
3 630f16ab90cfd878937a7997 <NA> NOT_REGISTERED
4 630f1cb9cb18da61cfd58659 Carol Brown PENDING_EMAIL_VERIFICATION
5 630f15d3b59c366b0e3ae2e6 Alice Jones ACTIVE
user_id user_name status
<chr> <chr> <chr>
1 5f227e0cd7176a0e6e754409 Andrew Collier ACTIVE
2 630f17f04a05b20faf7e0afc Bob Smith ACTIVE
3 630f16ab90cfd878937a7997 <NA> NOT_REGISTERED
4 630f1cb9cb18da61cfd58659 Carol Brown PENDING_EMAIL_VERIFICATION
5 630f15d3b59c366b0e3ae2e6 Alice Jones ACTIVE

## Clients

Expand All @@ -127,12 +126,11 @@ projects()
```

# A tibble: 3 × 5
project_id project_name client_id billa…¹ archi…²
<chr> <chr> <chr> <lgl> <lgl>
1 632a94f8d801fa1178d366b8 test <NA> TRUE FALSE
2 630ce53290cfd8789366fd49 {clockify} 63a55695db26c25e9d4e2d02 TRUE FALSE
3 630ce53cb59c366b0e27743f {emayili} 63a55695db26c25e9d4e2d02 TRUE FALSE
# … with abbreviated variable names ¹​billable, ²​archived
project_id project_name client_id billable archived
<chr> <chr> <chr> <lgl> <lgl>
1 632a94f8d801fa1178d366b8 test <NA> TRUE FALSE
2 630ce53290cfd8789366fd49 {clockify} 63a55695db26c25e9d4e2… TRUE FALSE
3 630ce53cb59c366b0e27743f {emayili} 63a55695db26c25e9d4e2… TRUE FALSE

## Time Entries

Expand Down Expand Up @@ -167,7 +165,7 @@ Check on the ID for this new time entry.
prepare_cran_entry$time_entry_id
```

[1] "63b1d732f19c8f67dc9d0973"
[1] "64f21f2ad397e5503bef3bb4"

Confirm that it has been inserted.

Expand All @@ -179,7 +177,7 @@ time_entries(concise = FALSE) %>%
# A tibble: 1 × 4
time_entry_id description time_start time_end
<chr> <chr> <dttm> <dttm>
1 63b1d732f19c8f67dc9d0973 Prepare for … 2021-08-30 08:00:00 2021-08-30 10:30:00
1 64f21f2ad397e5503bef3bb4 Prepare for … 2021-08-30 08:00:00 2021-08-30 10:30:00

### Delete Time Entry

Expand All @@ -197,8 +195,8 @@ time_entries(concise = FALSE) %>%
```

# A tibble: 0 × 4
# … with 4 variables: time_entry_id <chr>, description <chr>,
# time_start <dttm>, time_end <dttm>
# 4 variables: time_entry_id <chr>, description <chr>, time_start <dttm>,
# time_end <dttm>

## Endpoints

Expand Down
1 change: 1 addition & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ downlit
dplyr
fathomdata
github
gmail
https
httr
io
Expand Down
13 changes: 13 additions & 0 deletions man/client-parameters.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d14f50b

Please sign in to comment.