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

Decide how faithful we want to be to the API #3

Open
richierocks opened this issue Jun 21, 2018 · 1 comment
Open

Decide how faithful we want to be to the API #3

richierocks opened this issue Jun 21, 2018 · 1 comment

Comments

@richierocks
Copy link
Contributor

richierocks commented Jun 21, 2018

If we want to be strict about having exact 1 to 1 mappings with the API, we should have

  1. list_projects() that calls GET /projects, and
  2. get_project() that calls GET /projects/project-id

The latter isn't that useful for data science, since I suspect you'll actually want to retrieve lots of projects at once to compare. I suggest instead having a higher level get_projects() that can return multiple projects at once. I think the pattern is:

#' @export
list_projects <- function(workspace, team, archived = FALSE) {
  # some input checking
  results <- call_asana_api("projects/", workspace = workspace, team = team, archived = archived)
  # some flattening ...
  flat_results
}

# internal only
get_project <- function(project_id) {
  # checks
  results <- call_asana_api("projects/", project_id)
  # flattening
  a_single_row_data_frame
}

#' @importFrom purrr map_df
#' @export
get_projects <- function(project_ids) {
  map_df(project_ids, get_project)
}
@chriscardillo
Copy link
Contributor

chriscardillo commented Jun 21, 2018

I agree!

I have a question for this specific example - there are three options for querying projects:

  1. Query all projects via /projects endpoint
  2. Query workspace-specific projects via /workspaces/workspace-id/projects
  3. Query team-specific projects via /teams/team-id/projects

So would we then have 3 functions, specifically:

  1. get_all_projects() for endpoint /projects
  2. get_workspace_projects() for endpoint /workspaces/workspace-id/projects
  3. get_team_projects() for endpoint /teams/team-id/projects

Where 2 & 3 would take some workspace_id and team_id param accordingly, as well as the archived param?

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