Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make functions type consistent #14

Open
richierocks opened this issue Jun 13, 2019 · 0 comments
Open

Make functions type consistent #14

richierocks opened this issue Jun 13, 2019 · 0 comments
Assignees

Comments

@richierocks
Copy link
Contributor

Some functions sometimes but not always convert their result to be a data frame, which make them difficult to program against and to reason about.

For example asn_tasks_find_by_project() will return a tibble if there are tasks in the project, but returns a list of class asana_api otherwise.

To reproduce,

library(asana)
library(dcasana)
library(dplyr)

team_content_quality_gid <- dc_get_teams() %>%
  filter(name == "Content Quality") %>%
  pull(gid)

test_project <- asn_projects_create_in_team(
  team = team_content_quality_gid,
  name = "test-autogenerated-project",
  notes = "This is a test. Please delete this project."
)
# There are no tasks in the project, so the return value is a list
test_project_gid <- test_project$content$data$gid
asn_tasks_find_by_project(project_id = test_project_gid)
#> <Asana /projects/1127053277614384/tasks>
#> List of 1
#>  $ data: list()

# Once you add a task, you get a tibble
test_task <- asn_tasks_create(
  projects = test_project$content$data$gid,
  name = 'Test Task 1'
)
asn_tasks_find_by_project(project_id = test_project_gid)
#> # A tibble: 1 x 4
#>   id               gid              name        resource_type
#>   <chr>            <chr>            <chr>       <chr>        
#> 1 1127053162816649 1127053162816649 Test Task 1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants