Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smtlaissezfaire/df12ee5ad75dba86bc7d2c345ec192fa to your computer and use it in GitHub Desktop.
Save smtlaissezfaire/df12ee5ad75dba86bc7d2c345ec192fa to your computer and use it in GitHub Desktop.
# monkey patch to get uncompleted tasks from asana
# call with:
# options = {
# params: { completed_since: 'now' }
# }
# Asana::Resources::Task.find_by_project(client, projectId: project.id, options: options).each do |task|
# ...
# end
Asana::Resources::Task.module_eval do
class << self
alias_method :old_find_by_project, :find_by_project
def find_by_project(client, projectId: required("projectId"), per_page: 20, options: {})
params = { limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? }
if options[:params]
params.merge!(options[:params])
end
Asana::Resources::Collection.new(parse(client.get("/projects/#{projectId}/tasks", params: params, options: options)), type: self, client: client)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment