Created
May 24, 2018 01:55
-
-
Save smtlaissezfaire/df12ee5ad75dba86bc7d2c345ec192fa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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