asana-0.10.3/0000755000175100017510000000000014002345121011674 5ustar pravipraviasana-0.10.3/CODE_OF_CONDUCT.md0000644000175100017510000000261514002345121014477 0ustar pravipravi# Contributor Code of Conduct As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities. We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion. Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct. Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team. Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers. This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/) asana-0.10.3/.rubocop.yml0000644000175100017510000000037114002345121014147 0ustar pravipraviAllCops: Include: - '**/Rakefile' Exclude: - 'bin/**/*' - 'examples/**/*' - 'lib/asana/resources/*' - 'spec/templates/unicorn.rb' - 'spec/templates/world.rb' - 'test.rb' LineLength: Max: 120 require: rubocop-rspec asana-0.10.3/.rspec0000644000175100017510000000007514002345121013013 0ustar pravipravi--color --require spec_helper --require asana --order random asana-0.10.3/.ruby-version0000644000175100017510000000000614002345121014335 0ustar pravipravi2.4.0 asana-0.10.3/swagger_templates/0000755000175100017510000000000014002345121015411 5ustar pravipraviasana-0.10.3/swagger_templates/api.mustache0000644000175100017510000000605514002345121017723 0ustar pravipravi### WARNING: This file is auto-generated by our OpenAPI spec. Do not ### edit it manually. require_relative '../../resource_includes/response_helper' {{#operations}} module Asana module Resources class {{classname}}Base < Resource def self.inherited(base) Registry.register(base) end class << self {{#operation}}{{^formParams}} {{#contents}} # {{#summary}}{{{.}}}{{/summary}}{{^summary}}{{operationId}}{{/summary}} # {{#pathParams}} # {{paramName}} - [{{dataType}}] {{#required}} (required){{/required}}{{#optional}}(optional){{/optional}}{{#description}} {{{description}}}{{/description}}{{/pathParams}}{{#queryParams}}{{#neq baseName 'opt_pretty' 'opt_fields' 'offset' 'limit'}} # {{paramName}} - [{{~dataType~}}] {{#required}} (required){{/required}}{{#optional}}(optional){{/optional}}{{#description}} {{{description}}}{{/description}}{{/neq}}{{/queryParams}} # options - [Hash] the request I/O options{{#queryParams}}{{#eq baseName 'opt_pretty' 'opt_fields' 'offset' 'limit'}} # > {{paramName}} - [{{~dataType~}}] {{#required}} (required){{/required}}{{#optional}}(optional){{/optional}}{{#description}} {{{description}}}{{/description}}{{/eq}}{{/queryParams}} {{#eq httpMethod 'POST' 'PUT'}} # data - [Hash] the attributes to {{httpMethod}} {{/eq}} def {{operationId}}(client, {{#pathParams}}{{paramName}}: required("{{paramName}}"), {{/pathParams}}{{#queryParams}}{{#neq baseName 'opt_pretty' 'opt_fields' 'offset' 'limit'}}{{paramName}}: nil, {{/neq}}{{/queryParams}}options: {}{{#eq httpMethod 'POST' 'PUT'}}, **data{{/eq}}) path = "{{path}}"{{#pathParams}} path["{ {{~baseName~}} }"] = {{paramName}}{{/pathParams}}{{^moreThanCommon queryParams}} params = { {{#queryParams}}{{#neq baseName 'opt_pretty' 'opt_fields' 'offset' 'limit'}}{{#unless @first}}, {{/unless}}{{#neq paramName (fixSearchParams paramName)}}"{{/neq}}{{fixSearchParams paramName}}{{#neq paramName (fixSearchParams paramName)}}"{{/neq}}: {{paramName}}{{/neq}}{{/queryParams}} }.reject { |_,v| v.nil? || Array(v).empty? }{{/moreThanCommon}} {{#returnContainer}}Collection.new({{/returnContainer}}{{^returnContainer}}{{#firstClassResponseObject returnType}}{{firstClassResponseObject returnType}}.new({{/firstClassResponseObject}}{{/returnContainer}}parse(client.{{toLowerCase httpMethod}}(path, {{^moreThanCommon queryParams}}params: params, {{/moreThanCommon}}{{#eq httpMethod 'POST' 'PUT'}}body: data, {{/eq}}{{#queryParams.length}}params: params, {{/queryParams.length}}options: options)){{^returnContainer}}.first{{/returnContainer}}{{#returnContainer}}, type: {{#if (firstClassResponseObject returnType)}}{{firstClassResponseObject returnType}}{{else}}Resource{{/if}}{{/returnContainer}}{{#returnContainer}}, client: client){{/returnContainer}}{{^returnContainer}}{{#firstClassResponseObject returnType}}, client: client){{/firstClassResponseObject}}{{/returnContainer}} end {{/contents}} {{/formParams}}{{/operation}} end end end end {{/operations}} asana-0.10.3/swagger_templates/ruby-config.json0000644000175100017510000000017414002345121020532 0ustar pravipravi{ "packageName" : "asana", "templateDir": "swagger_templates", "hideGenerationTimestamp": true, "apiTests": false } asana-0.10.3/swagger_templates/api_doc.mustache0000644000175100017510000000122614002345121020543 0ustar pravipravi{{#operations}}{{toLowerCase classname}}: {{#operation}}{{#contents}} {{operationId}}: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.{{toLowerCase baseName}}.{{operationId}}({{#pathParams}}{{paramName}}: '{{paramName}}', {{/pathParams}}{{#queryParams}}{{#eq required true}}{{paramName}}: '{{example}}', {{/eq}}{{/queryParams}}{{#eq httpMethod 'GET'}}param: "value", param: "value", {{/eq}}{{#eq httpMethod 'POST' 'PUT'}}field: "value", field: "value", {{/eq}}options: {pretty: true}){{/contents}}{{/operation}} {{/operations}} asana-0.10.3/Guardfile0000644000175100017510000000527714002345121013534 0ustar pravipravi# A sample Guardfile # More info at https://github.com/guard/guard#readme ## Uncomment and set this to only include directories you want to watch # directories %w(app lib config test spec features) ## Uncomment to clear the screen before every task # clearing :on ## Guard internally checks for changes in the Guardfile and exits. ## If you want Guard to automatically start up again, run guard in a ## shell loop, e.g.: ## ## $ while bundle exec guard; do echo "Restarting Guard..."; done ## ## Note: if you are using the `directories` clause above and you are not ## watching the project directory ('.'), then you will want to move ## the Guardfile to a watched dir and symlink it back, e.g. # # $ mkdir config # $ mv Guardfile config/ # $ ln -s config/Guardfile . # # and, you'll have to watch "config/Guardfile" instead of "Guardfile" # Note: The cmd option is now required due to the increasing number of ways # rspec may be run, below are examples of the most common uses. # * bundler: 'bundle exec rspec' # * bundler binstubs: 'bin/rspec' # * spring: 'bin/rspec' (This will use spring if running and you have # installed the spring binstubs per the docs) # * zeus: 'zeus rspec' (requires the server to be started separately) # * 'just' rspec: 'rspec' guard :rspec, cmd: "bundle exec rspec" do require "guard/rspec/dsl" dsl = Guard::RSpec::Dsl.new(self) # Feel free to open issues for suggestions and improvements # RSpec files rspec = dsl.rspec watch(rspec.spec_helper) { rspec.spec_dir } watch(rspec.spec_support) { rspec.spec_dir } watch(rspec.spec_files) watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } # Rails files rails = dsl.rails(view_extensions: %w(erb haml slim)) dsl.watch_spec_files_for(rails.app_files) dsl.watch_spec_files_for(rails.views) watch(rails.controllers) do |m| [ rspec.spec.("routing/#{m[1]}_routing"), rspec.spec.("controllers/#{m[1]}_controller"), rspec.spec.("acceptance/#{m[1]}") ] end # Rails config changes watch(rails.spec_helper) { rspec.spec_dir } watch(rails.routes) { "#{rspec.spec_dir}/routing" } watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" } # Capybara features specs watch(rails.view_dirs) { |m| rspec.spec.("features/#{m[1]}") } # Turnip features and steps watch(%r{^spec/acceptance/(.+)\.feature$}) watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m| Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance" end end guard :rubocop do watch(%r{.+\.rb$}) watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) } end guard 'yard' do watch(%r{app/.+\.rb}) watch(%r{lib/.+\.rb}) watch(%r{ext/.+\.c}) end asana-0.10.3/examples/0000755000175100017510000000000014002345121013512 5ustar pravipraviasana-0.10.3/examples/personal_access_token.rb0000644000175100017510000000107414002345121020405 0ustar pravipravirequire 'bundler' Bundler.require require 'asana' access_token = ENV['ASANA_ACCESS_TOKEN'] unless access_token abort "Run this program with the env var ASANA_ACCESS_TOKEN.\n" \ "Go to http://app.asana.com/-/account_api to create a personal access token." end client = Asana::Client.new do |c| c.authentication :access_token, access_token end puts "My Workspaces:" client.workspaces.find_all.each do |workspace| puts "\t* #{workspace.name} - tags:" client.tags.find_by_workspace(workspace: workspace.id).each do |tag| puts "\t\t- #{tag.name}" end end asana-0.10.3/examples/events.rb0000644000175100017510000000214114002345121015341 0ustar pravipravi# -*- coding: utf-8 -*- require 'bundler' Bundler.require require 'asana' access_token = ENV['ASANA_ACCESS_TOKEN'] unless access_token abort "Run this program with the env var ASANA_ACCESS_TOKEN.\n" \ "Go to http://app.asana.com/-/account_api to create a personal access token." end client = Asana::Client.new do |c| c.authentication :access_token, access_token end workspace = client.workspaces.find_all.first task = client.tasks.find_all(assignee: "me", workspace: workspace.id).first unless task task = client.tasks.create(workspace: workspace.id, name: "Hello world!", assignee: "me") end Thread.abort_on_exception = true Thread.new do puts "Listening for 'changed' events on #{task} in one thread..." task.events(wait: 2).lazy.select { |event| event.action == 'changed' }.each do |event| puts "#{event.user.name} changed #{event.resource}" end end Thread.new do puts "Listening for non-'changed' events on #{task} in another thread..." task.events(wait: 1).lazy.reject { |event| event.action == 'changed' }.each do |event| puts "'#{event.action}' event: #{event}" end end sleep asana-0.10.3/examples/Gemfile.lock0000644000175100017510000000133314002345121015734 0ustar pravipraviPATH remote: .. specs: asana (0.10.3) faraday (~> 1.0) faraday_middleware (~> 1.0) faraday_middleware-multi_json (~> 0.0) oauth2 (~> 1.4) GEM remote: https://rubygems.org/ specs: faraday (1.0.1) multipart-post (>= 1.2, < 3) faraday_middleware (1.0.0) faraday (~> 1.0) faraday_middleware-multi_json (0.0.6) faraday_middleware multi_json jwt (2.2.1) multi_json (1.15.0) multi_xml (0.6.0) multipart-post (2.1.1) oauth2 (1.4.4) faraday (>= 0.8, < 2.0) jwt (>= 1.0, < 3.0) multi_json (~> 1.3) multi_xml (~> 0.5) rack (>= 1.2, < 3) rack (2.2.3) PLATFORMS ruby DEPENDENCIES asana! BUNDLED WITH 1.17.3 asana-0.10.3/examples/cli_app.rb0000644000175100017510000000157414002345121015455 0ustar pravipravirequire 'bundler' Bundler.require require 'asana' id, secret = ENV['ASANA_CLIENT_ID'], ENV['ASANA_CLIENT_SECRET'] unless id && secret abort "Run this program with the env vars ASANA_CLIENT_ID and ASANA_CLIENT_SECRET.\n" \ "Refer to https://asana.com/developers/documentation/getting-started/authentication "\ "to get your credentials." \ "The redirect URI for your application should be \"urn:ietf:wg:oauth:2.0:oob\"." end access_token = Asana::Authentication::OAuth2.offline_flow(client_id: id, client_secret: secret) client = Asana::Client.new do |c| c.authentication :oauth2, access_token end puts "My Workspaces:" client.workspaces.find_all.each do |workspace| puts "\t* #{workspace.name} - tags:" client.tags.find_by_workspace(workspace: workspace.id).each do |tag| puts "\t\t- #{tag.name}" end end asana-0.10.3/examples/Gemfile0000644000175100017510000000007014002345121015002 0ustar pravipravisource 'https://rubygems.org' gem 'asana', path: '../' asana-0.10.3/.travis.yml0000644000175100017510000000155414002345121014012 0ustar pravipravilanguage: ruby rvm: - 2.3.6 - 2.4.3 - 2.5.0 - 2.7.1 - 3.0.0 deploy: provider: rubygems api_key: secure: ZFzExKt6auBOcQyg8955GwlZW2OaS64Q+XHGSay2MzjALw1iiy5uuMdwkueCKrGWSv6/eBe9jjsmYBe3OfkUIpIBbUacnbEYeaC70AyucNjvFrrl0YVYHb7neojarJUmKz9bz9Pkju/jdxksaYaj58xfq5YPQDfjFtdmylvuNEYpujT6goPEbxG4U4PpIhhQOZRDRXXAPS+f7jHejTSK06kvJjiJw0d51VJtBbp+0TKNKL6BDKdOKjKeHuebuUmSw8crDyaYdnwYwmNg1cJrGOv2t76M08zoKkkIO2lwPMHisi1/+cbVcZfxM4SfdHJeU6cQuRdb0uCUbbj6GsGwT8vWP2mGUrLe4UV/GfZDmvK3MKeKIlkgig31a3Qny9yjn8EjSnKHYuHBbJvPQDPPpFUfgEneUxn2t4P6m+epkd1gldWqTWf8mhMR/6xAFT4s+BaxnMMJsTC3Ea+dZZ30EqCw/kx5B2Z1KVLgsxHeMN/Q+AeOcbOvlGDsFL0Mjk/PqDTW1AWKLs/D1ohcxjSmlNJGWR6JHa/Ei0GqjDE2+/ZGsKsRfcDD4kU5qnKdqdzDlbL3cL4tChzuWVcguYdrg1yZzqPrCPzmy+2D7Hphyaj9CPKEh7qwT+IQU5o/V2peOJUjKrMlJS4gFq6MvTDh5U59J88Kkg72DXhcEUcySkU= gem: asana on: tags: true repo: Asana/ruby-asana ruby: '2.5.0' asana-0.10.3/VERSION0000644000175100017510000000000714002345121012741 0ustar pravipravi0.10.3 asana-0.10.3/.gitignore0000644000175100017510000000020514002345121013661 0ustar pravipravi.idea /.bundle/ /.yardoc /Gemfile.lock /_yardoc/ /coverage/ /doc/ /pkg/ /spec/reports/ /tmp/ /bin/ test.rb /node_modules/ /gemfiles/ asana-0.10.3/lib/0000755000175100017510000000000014002345121012442 5ustar pravipraviasana-0.10.3/lib/templates/0000755000175100017510000000000014002345121014440 5ustar pravipraviasana-0.10.3/lib/templates/resource.ejs0000644000175100017510000002167614002345121017006 0ustar pravipravi<% var singularName = resource.name, pluralName = plural(singularName), mixins = { task: ["AttachmentUploading", "EventSubscription"], project: ["EventSubscription"] }, skip = { attachment: ["createOnTask"] }, formatComment = function formatComment(text, indentation) { var indent = Array(indentation + 1).join(" ") return text.trim().split("\n").map(function(line) { return indent + (line.length > 0 ? "# " : "#") + line }).join("\n") } function Action(action) { var that = this this.action = action this.collection = action.collection == true this.requiresData = action.method == "POST" || action.method == "PUT" this.isInstanceAction = (action.method == "PUT" || action.method == "DELETE") this.method = action.method this.methodName = snake(action.name) this.clientMethod = action.method.toLowerCase() this.returnsUpdatedRecord = action.method == 'PUT' || action.comment.match(/Returns[a-z\W]+updated/) !== null this.returnsNothing = action.comment.match(/Returns an empty/) !== null // Params and idParams var params = action.params || [] this.idParams = _.filter(params, function(p) { return p.type == "Id" }) // If it looks like an instance action but it's not, make it one if (!this.isInstanceAction) { var mainIdParam = _.find(this.idParams, function(p) { return p.name == singularName }) if (mainIdParam !== undefined && !action.name.match(/Id/)) { this.isInstanceAction = true this.mainIdParam = mainIdParam } } if (this.idParams.length == 1 && action.path.match(/%d/) && (action.name.match(/Id/) || (this.isInstanceAction && this.mainIdParam == undefined))) { var mainIdParam = this.idParams[0] this.mainIdParam = mainIdParam this.inferredReturnType = this.isInstanceAction ? 'self.class' : 'self' } if (mainIdParam !== undefined) { this.params = _.reject(params, function(p) { return p.name == mainIdParam.name }) } else { this.params = params } if (!this.inferredReturnType) { // Infer return type var name = action.path.match(/\/([a-zA-Z]+)$/) if (name !== null) { name = name[1] // Desugarize 'addProject' to 'project' var camelCaseTail = name.match(/.*([A-Z][a-z]+)$/) if (camelCaseTail !== null) { name = decap(camelCaseTail[1]) } name = single(name) var explicit = _.find(resources, function(p) { return p == name }) if (name == singularName || name == 'parent' || name == 'children' || name.match(/^sub/) !== null) { this.inferredReturnType = this.isInstanceAction ? 'self.class' : 'self' } else if (explicit !== undefined) { this.inferredReturnType = cap(explicit) } else { this.inferredReturnType = 'Resource' } } else { this.inferredReturnType = 'Resource' } } // Endpoint path this.path = _.reduce(this.idParams, function(acc, id) { var localName = that.mainIdParam == id ? "id" : id.name return acc.replace("\%d", "#{" + localName + "}") }, action.path) // Extra params (not in the URL) to be passed in the body of the call this.extraParams = _.reject(this.params, function(p) { return that.path.match(new RegExp("#{" + p.name + "}")) }) // Params processing var paramsLocal = "data" if (this.collection) { this.extraParams.push({ name: "per_page", apiParamName: "limit" }) } if (this.extraParams.length > 0) { var paramNames = _.map(this.extraParams, function(p) { return (p.apiParamName || p.name) + ": " + p.name }) if (this.requiresData) { var paramsProcessing = "with_params = data.merge(" + paramNames.join(", ") + ")" paramsLocal = "with_params" } else { var paramsProcessing = "params = { " + paramNames.join(", ") + " }" paramsLocal = "params" } paramsProcessing += ".reject { |_,v| v.nil? || Array(v).empty? }" } this.paramsProcessing = paramsProcessing this.paramsLocal = paramsLocal // Method argument names var argumentNames = Array() if (!this.isInstanceAction) { argumentNames.push("client") } if (this.mainIdParam !== undefined && !this.isInstanceAction) { argumentNames.push("id") } _.forEach(this.params, function(param) { argumentNames.push(param.name + ":" + (param.required ? " required(\"" + param.name + "\")" : " nil")) }) if (this.collection) { argumentNames.push("per_page: 20") } if (this.method != 'DELETE') { argumentNames.push("options: {}") } if (this.requiresData) { argumentNames.push("**data") } this.argumentNames = argumentNames // API request params var requestParams = Array() requestParams.push('"' + this.path + '"') if (this.paramsProcessing || this.argumentNames.indexOf("**data") != -1) { var argument = this.requiresData ? "body" : "params" requestParams.push(argument + ": " + paramsLocal) } if (this.method != 'DELETE') { requestParams.push("options: options") } this.requestParams = requestParams this.documentation = this.renderDocumentation() // Constructor this.constructor = function(body) { var pre = '', post = '' var wrapWithParsing = function(body) { var pre = '', post = '' if (!that.returnsNothing) { pre = 'parse(' post = ')' + (that.collection ? '' : '.first') } return pre + body + post } if (!that.returnsNothing) { if (that.isInstanceAction && that.returnsUpdatedRecord) { pre = "refresh_with(" post = ')' } else { pre = that.collection ? "Collection.new(" : that.inferredReturnType + ".new(" post = (that.collection ? ', type: ' + that.inferredReturnType : '') + ', client: client)' } } else { post = ' && true' } return pre + wrapWithParsing(body) + post } this.request = this.constructor("client." + this.clientMethod + "(" + this.requestParams.join(", ") + ")") } Action.prototype.renderDocumentation = function () { var formatParamNotes = function(params) { var trimmed = _.flatten(_.map(params, function(p) { return _.map(p.notes, function(note) { return note.trim() }) })) return (trimmed.length > 0 ? "\nNotes:\n\n" + trimmed.join("\n\n") : "") } var formatParam = function(p, name) { return (name !== undefined ? name : p.name) + " - [" + p.type + "] " + p.comment } var lines = _.map(this.params, function(p) { return formatParam(p) }) if (this.mainIdParam !== undefined && !this.isInstanceAction) { lines.unshift(formatParam(this.mainIdParam, "id")) } if (this.collection) { lines.push("per_page - [Integer] the number of records to fetch per page.") } if (this.method != 'DELETE') { lines.push("options - [Hash] the request I/O options.") } if (this.requiresData) { lines.push("data - [Hash] the attributes to post.") } return this.action.comment + "\n" + lines.join("\n") + formatParamNotes(this.params) } var actionsToSkip = skip[resource.name] || [] var actionsToGen = _.reject(resource.actions, function(action) { return actionsToSkip.indexOf(action.name) != -1 }) var allActions = _.map(actionsToGen, function(action) { return new Action(action) }), instanceActions = _.filter(allActions, function(action) { return action.isInstanceAction }), classActions = _.reject(allActions, function(action) { return action.isInstanceAction }) var mixinsToInclude = mixins[resource.name] || [] %>### WARNING: This file is auto-generated by the asana-api-meta repo. Do not ### edit it manually. module Asana module Resources <%= formatComment(resource.comment, 4) %> class <%= cap(singularName) %> < Resource <% _.forEach(mixinsToInclude, function(mixin) { %> include <%= mixin %> <% }) %> <% _.forEach(resource.properties, function(property) { %> attr_reader :<%= property.name %> <% }) %> class << self # Returns the plural name of the resource. def plural_name '<%= pluralName %>' end <% _.forEach(classActions, function(action) { %> <%= formatComment(action.documentation, 8) %> def <%= action.methodName %>(<%= action.argumentNames.join(", ") %>) <% if (action.paramsProcessing) { %> <%= action.paramsProcessing %><% } %> <%= action.request %> end <% }) %> end <% _.forEach(instanceActions, function(action) { %> <%= formatComment(action.documentation, 6) %> def <%= action.methodName %>(<%= action.argumentNames.join(", ") %>) <% if (action.paramsProcessing) { %> <%= action.paramsProcessing %><% } %> <%= action.request %> end <% }) %> end end end asana-0.10.3/lib/templates/index.js0000644000175100017510000000023414002345121016104 0ustar pravipravimodule.exports = { resource: { template: 'resource.ejs', filename: function(resource, helpers) { return resource.name + '.rb'; } } }; asana-0.10.3/lib/asana/0000755000175100017510000000000014002345121013525 5ustar pravipraviasana-0.10.3/lib/asana/client.rb0000644000175100017510000001046014002345121015331 0ustar pravipravirequire_relative 'authentication' require_relative 'client/configuration' require_relative 'resources' module Asana # Public: A client to interact with the Asana API. It exposes all the # available resources of the Asana API in idiomatic Ruby. # # Examples # # # Authentication with a personal access token # Asana::Client.new do |client| # client.authentication :access_token, '...' # end # # # OAuth2 with a plain bearer token (doesn't support auto-refresh) # Asana::Client.new do |client| # client.authentication :oauth2, bearer_token: '...' # end # # # OAuth2 with a plain refresh token and client credentials # Asana::Client.new do |client| # client.authentication :oauth2, # refresh_token: '...', # client_id: '...', # client_secret: '...', # redirect_uri: '...' # end # # # OAuth2 with an ::OAuth2::AccessToken object # Asana::Client.new do |client| # client.authentication :oauth2, my_oauth2_access_token_object # end # # # Use a custom Faraday network adapter # Asana::Client.new do |client| # client.authentication ... # client.adapter :typhoeus # end # # # Use a custom user agent string # Asana::Client.new do |client| # client.authentication ... # client.user_agent '...' # end # # # Pass in custom configuration to the Faraday connection # Asana::Client.new do |client| # client.authentication ... # client.configure_faraday { |conn| conn.use MyMiddleware } # end # class Client # Internal: Proxies Resource classes to implement a fluent API on the Client # instances. class ResourceProxy def initialize(client: required('client'), resource: required('resource')) @client = client @resource = resource end def method_missing(m, *args, **kwargs, &block) @resource.public_send(m, *([@client] + args), **kwargs, &block) end def respond_to_missing?(m, *) @resource.respond_to?(m) end end # Public: Initializes a new client. # # Yields a {Asana::Client::Configuration} object as a configuration # DSL. See {Asana::Client} for usage examples. def initialize config = Configuration.new.tap { |c| yield c }.to_h @http_client = HttpClient.new(authentication: config.fetch(:authentication), adapter: config[:faraday_adapter], user_agent: config[:user_agent], debug_mode: config[:debug_mode], log_asana_change_warnings: config[:log_asana_change_warnings], default_headers: config[:default_headers], &config[:faraday_configuration]) end # Public: Performs a GET request against an arbitrary Asana URL. Allows for # the user to interact with the API in ways that haven't been # reflected/foreseen in this library. def get(url, **args) @http_client.get(url, **args) end # Public: Performs a POST request against an arbitrary Asana URL. Allows for # the user to interact with the API in ways that haven't been # reflected/foreseen in this library. def post(url, **args) @http_client.post(url, **args) end # Public: Performs a PUT request against an arbitrary Asana URL. Allows for # the user to interact with the API in ways that haven't been # reflected/foreseen in this library. def put(url, **args) @http_client.put(url, **args) end # Public: Performs a DELETE request against an arbitrary Asana URL. Allows # for the user to interact with the API in ways that haven't been # reflected/foreseen in this library. def delete(url, **args) @http_client.delete(url, **args) end # Public: Exposes queries for all top-evel endpoints. # # E.g. #users will query /users and return a # Asana::Resources::Collection. Resources::Registry.resources.each do |resource_class| define_method(resource_class.plural_name) do ResourceProxy.new(client: @http_client, resource: resource_class) end end end end asana-0.10.3/lib/asana/authentication/0000755000175100017510000000000014002345121016544 5ustar pravipraviasana-0.10.3/lib/asana/authentication/token_authentication.rb0000644000175100017510000000076414002345121023317 0ustar pravipravimodule Asana module Authentication # Public: Represents an API token authentication mechanism. class TokenAuthentication def initialize(token) @token = token end # Public: Configures a Faraday connection injecting its token as # basic auth. # # builder - [Faraday::Connection] the Faraday connection instance. # # Returns nothing. def configure(connection) connection.basic_auth(@token, '') end end end end asana-0.10.3/lib/asana/authentication/oauth2/0000755000175100017510000000000014002345121017746 5ustar pravipraviasana-0.10.3/lib/asana/authentication/oauth2/client.rb0000644000175100017510000000365414002345121021561 0ustar pravipravirequire 'oauth2' module Asana module Authentication module OAuth2 # Public: Deals with the details of obtaining an OAuth2 authorization URL # and obtaining access tokens from either authorization codes or refresh # tokens. class Client # Public: Initializes a new client with client credentials associated # with a registered Asana API application. # # client_id - [String] a client id from the registered application # client_secret - [String] a client secret from the registered # application # redirect_uri - [String] a redirect uri from the registered # application def initialize(client_id: required('client_id'), client_secret: required('client_secret'), redirect_uri: required('redirect_uri')) @client = ::OAuth2::Client.new(client_id, client_secret, site: 'https://app.asana.com', authorize_url: '/-/oauth_authorize', token_url: '/-/oauth_token') @redirect_uri = redirect_uri end # Public: # Returns the [String] OAuth2 authorize URL. def authorize_url @client.auth_code.authorize_url(redirect_uri: @redirect_uri) end # Public: Retrieves a token from an authorization code. # # Returns the [::OAuth2::AccessToken] token. def token_from_auth_code(auth_code) @client.auth_code.get_token(auth_code, redirect_uri: @redirect_uri) end # Public: Retrieves a token from a refresh token. # # Returns the refreshed [::OAuth2::AccessToken] token. def token_from_refresh_token(token) ::OAuth2::AccessToken.new(@client, '', refresh_token: token).refresh! end end end end end asana-0.10.3/lib/asana/authentication/oauth2/access_token_authentication.rb0000644000175100017510000000406714002345121026042 0ustar pravipravimodule Asana module Authentication module OAuth2 # Public: A mechanism to authenticate with an OAuth2 access token (a # bearer token and a refresh token) or just a refresh token. class AccessTokenAuthentication # Public: Builds an AccessTokenAuthentication from a refresh token and # client credentials, by refreshing into a new one. # # refresh_token - [String] a refresh token # client_id - [String] the client id of the registered Asana API # Application. # client_secret - [String] the client secret of the registered Asana API # Application. # redirect_uri - [String] the redirect uri of the registered Asana API # Application. # # Returns an [AccessTokenAuthentication] instance with a refreshed # access token. def self.from_refresh_token(refresh_token, client_id: required('client_id'), client_secret: required('client_secret'), redirect_uri: required('redirect_uri')) client = Client.new(client_id: client_id, client_secret: client_secret, redirect_uri: redirect_uri) new(client.token_from_refresh_token(refresh_token)) end # Public: Initializes a new AccessTokenAuthentication. # # access_token - [::OAuth2::AccessToken] An ::OAuth2::AccessToken # object. def initialize(access_token) @token = access_token end # Public: Configures a Faraday connection injecting a bearer token, # auto-refreshing it when needed. # # connection - [Faraday::Connection] the Faraday connection instance. # # Returns nothing. def configure(connection) @token = @token.refresh! if @token.expired? connection.request :oauth2, @token.token end end end end end asana-0.10.3/lib/asana/authentication/oauth2/bearer_token_authentication.rb0000644000175100017510000000223014002345121026027 0ustar pravipravimodule Asana module Authentication module OAuth2 # Public: A mechanism to authenticate with an OAuth2 bearer token obtained # somewhere, for instance through omniauth-asana. # # Note: This authentication mechanism doesn't support token refreshing. If # you'd like refreshing and you have a refresh token as well as a bearer # token, you can generate a proper access token with # {AccessTokenAuthentication.from_refresh_token}. class BearerTokenAuthentication # Public: Initializes a new BearerTokenAuthentication with a plain # bearer token. # # bearer_token - [String] a plain bearer token. def initialize(bearer_token) @token = bearer_token end # Public: Configures a Faraday connection injecting its token as an # OAuth2 bearer token. # # connection - [Faraday::Connection] the Faraday connection instance. # # Returns nothing. def configure(connection) connection.authorization :Bearer, @token connection.request :oauth2, token_type: 'bearer' end end end end end asana-0.10.3/lib/asana/authentication/oauth2.rb0000644000175100017510000000341614002345121020277 0ustar pravipravirequire_relative 'oauth2/bearer_token_authentication' require_relative 'oauth2/access_token_authentication' require_relative 'oauth2/client' module Asana module Authentication # Public: Deals with OAuth2 authentication. Contains a function to get an # access token throught a browserless authentication flow, needed for some # applications such as CLI applications. module OAuth2 module_function # Public: Retrieves an access token through an offline authentication # flow. If your application can receive HTTP requests, you might want to # opt for a browser-based flow and use the omniauth-asana gem instead. # # Your registered application's redirect_uri should be exactly # "urn:ietf:wg:oauth:2.0:oob". # # client_id - [String] the client id of the registered Asana API # application. # client_secret - [String] the client secret of the registered Asana API # application. # # Returns an ::OAuth2::AccessToken object. # # Note: This function reads from STDIN and writes to STDOUT. It is meant # to be used only within the context of a CLI application. def offline_flow(client_id: required('client_id'), client_secret: required('client_secret')) client = Client.new(client_id: client_id, client_secret: client_secret, redirect_uri: 'urn:ietf:wg:oauth:2.0:oob') STDOUT.puts '1. Go to the following URL to authorize the ' \ " application: #{client.authorize_url}" STDOUT.puts '2. Paste the authorization code here: ' auth_code = STDIN.gets.chomp client.token_from_auth_code(auth_code) end end end end asana-0.10.3/lib/asana/ruby2_0_0_compatibility.rb0000644000175100017510000000013014002345121020476 0ustar pravipravidef required(name) raise(ArgumentError, "#{name} is a required keyword argument") end asana-0.10.3/lib/asana/http_client/0000755000175100017510000000000014002345121016042 5ustar pravipraviasana-0.10.3/lib/asana/http_client/error_handling.rb0000644000175100017510000000762314002345121021374 0ustar pravipravirequire 'multi_json' require_relative '../errors' module Asana class HttpClient # Internal: Handles errors from the API and re-raises them as proper # exceptions. module ErrorHandling include Errors module_function MAX_TIMEOUTS = 5 # Public: Perform a request handling any API errors correspondingly. # # request - [Proc] a block that will execute the request. # # Returns a [Faraday::Response] object. # # Raises [Asana::Errors::InvalidRequest] for invalid requests. # Raises [Asana::Errors::NotAuthorized] for unauthorized requests. # Raises [Asana::Errors::Forbidden] for forbidden requests. # Raises [Asana::Errors::NotFound] when a resource can't be found. # Raises [Asana::Errors::RateLimitEnforced] when the API is throttling. # Raises [Asana::Errors::ServerError] when there's a server problem. # Raises [Asana::Errors::APIError] when the API returns an unknown error. # # rubocop:disable all def handle(num_timeouts=0, &request) request.call rescue Faraday::ClientError => e raise e unless e.response case e.response[:status] when 400 then raise invalid_request(e.response) when 401 then raise not_authorized(e.response) when 402 then raise payment_required(e.response) when 403 then raise forbidden(e.response) when 404 then raise not_found(e.response) when 412 then recover_response(e.response) when 429 then raise rate_limit_enforced(e.response) when 500 then raise server_error(e.response) else raise api_error(e.response) end rescue Net::ReadTimeout => e if num_timeouts < MAX_TIMEOUTS handle(num_timeouts + 1, &request) else raise e end end # rubocop:enable all # Internal: Returns an InvalidRequest exception including a list of # errors. def invalid_request(response) errors = body(response).fetch('errors', []).map { |e| e['message'] } InvalidRequest.new(errors).tap do |exception| exception.response = response end end # Internal: Returns a NotAuthorized exception. def not_authorized(response) NotAuthorized.new.tap { |exception| exception.response = response } end # Internal: Returns a PremiumOnly exception. def payment_required(response) PremiumOnly.new.tap { |exception| exception.response = response } end # Internal: Returns a Forbidden exception. def forbidden(response) Forbidden.new.tap { |exception| exception.response = response } end # Internal: Returns a NotFound exception. def not_found(response) NotFound.new.tap { |exception| exception.response = response } end # Internal: Returns a RateLimitEnforced exception with a retry after # field. def rate_limit_enforced(response) retry_after_seconds = response[:headers]['Retry-After'] RateLimitEnforced.new(retry_after_seconds).tap do |exception| exception.response = response end end # Internal: Returns a ServerError exception with a unique phrase. def server_error(response) phrase = body(response).fetch('errors', []).first['phrase'] ServerError.new(phrase).tap do |exception| exception.response = response end end # Internal: Returns an APIError exception. def api_error(response) APIError.new.tap { |exception| exception.response = response } end # Internal: Parser a response body from JSON. def body(response) MultiJson.load(response[:body]) end def recover_response(response) r = response.dup.tap { |res| res[:body] = body(response) } Response.new(OpenStruct.new(env: OpenStruct.new(r))) end end end end asana-0.10.3/lib/asana/http_client/environment_info.rb0000644000175100017510000000265714002345121021760 0ustar pravipravirequire_relative '../version' require 'openssl' module Asana class HttpClient # Internal: Adds environment information to a Faraday request. class EnvironmentInfo # Internal: The default user agent to use in all requests to the API. USER_AGENT = "ruby-asana v#{Asana::VERSION}".freeze def initialize(user_agent = nil) @user_agent = user_agent || USER_AGENT @openssl_version = OpenSSL::OPENSSL_VERSION @client_version = Asana::VERSION @os = os end # Public: Augments a Faraday connection with information about the # environment. def configure(builder) builder.headers[:user_agent] = @user_agent builder.headers[:"X-Asana-Client-Lib"] = header end private def header { os: @os, language: 'ruby', language_version: RUBY_VERSION, version: @client_version, openssl_version: @openssl_version } .map { |k, v| "#{k}=#{v}" }.join('&') end # rubocop:disable Metrics/MethodLength def os if RUBY_PLATFORM =~ /win32/ || RUBY_PLATFORM =~ /mingw/ 'windows' elsif RUBY_PLATFORM =~ /linux/ 'linux' elsif RUBY_PLATFORM =~ /darwin/ 'darwin' elsif RUBY_PLATFORM =~ /freebsd/ 'freebsd' else 'unknown' end end # rubocop:enable Metrics/MethodLength end end end asana-0.10.3/lib/asana/http_client/response.rb0000644000175100017510000000206214002345121020225 0ustar pravipravimodule Asana class HttpClient # Internal: Represents a response from the Asana API. class Response # Public: # Returns a [Faraday::Env] object for debugging. attr_reader :faraday_env # Public: # Returns the [Integer] status code of the response. attr_reader :status # Public: # Returns the [Hash] representing the parsed JSON body. attr_reader :body # Public: # Returns the [Hash] of attribute headers. attr_reader :headers # Public: Wraps a Faraday response. # # faraday_response - [Faraday::Response] the Faraday response to wrap. def initialize(faraday_response) @faraday_env = faraday_response.env @status = faraday_env.status @body = faraday_env.body @headers = faraday_response.headers end # Public: # Returns a [String] representation of the response. def to_s "#" end alias inspect to_s end end end asana-0.10.3/lib/asana/authentication.rb0000644000175100017510000000031114002345121017064 0ustar pravipravirequire_relative 'authentication/oauth2' require_relative 'authentication/token_authentication' module Asana # Public: Authentication strategies for the Asana API. module Authentication end end asana-0.10.3/lib/asana/http_client.rb0000644000175100017510000002117414002345121016374 0ustar pravipravirequire 'faraday' require 'faraday_middleware' require 'faraday_middleware/multi_json' require_relative 'http_client/error_handling' require_relative 'http_client/environment_info' require_relative 'http_client/response' module Asana # Internal: Wrapper over Faraday that abstracts authentication, request # parsing and common options. class HttpClient # Internal: The API base URI. BASE_URI = 'https://app.asana.com/api/1.0'.freeze # Public: Initializes an HttpClient to make requests to the Asana API. # # authentication - [Asana::Authentication] An authentication strategy. # adapter - [Symbol, Proc] A Faraday adapter, eiter a Symbol for # registered adapters or a Proc taking a builder for a # custom one. Defaults to Faraday.default_adapter. # user_agent - [String] The user agent. Defaults to "ruby-asana vX.Y.Z". # config - [Proc] An optional block that yields the Faraday builder # object for customization. def initialize(authentication: required('authentication'), adapter: nil, user_agent: nil, debug_mode: false, log_asana_change_warnings: true, default_headers: nil, &config) @authentication = authentication @adapter = adapter || Faraday.default_adapter @environment_info = EnvironmentInfo.new(user_agent) @debug_mode = debug_mode @log_asana_change_warnings = log_asana_change_warnings @default_headers = default_headers @config = config end # Public: Performs a GET request against the API. # # resource_uri - [String] the resource URI relative to the base Asana API # URL, e.g "/users/me". # params - [Hash] the request parameters # options - [Hash] the request I/O options # # Returns an [Asana::HttpClient::Response] if everything went well. # Raises [Asana::Errors::APIError] if anything went wrong. def get(resource_uri, params: {}, options: {}) opts = options.reduce({}) do |acc, (k, v)| acc.tap do |hash| hash[:"opt_#{k}"] = v.is_a?(Array) ? v.join(',') : v end end perform_request(:get, resource_uri, params.merge(opts), options[:headers]) end # Public: Performs a PUT request against the API. # # resource_uri - [String] the resource URI relative to the base Asana API # URL, e.g "/users/me". # body - [Hash] the body to PUT. # options - [Hash] the request I/O options # # Returns an [Asana::HttpClient::Response] if everything went well. # Raises [Asana::Errors::APIError] if anything went wrong. def put(resource_uri, body: {}, options: {}) opts = options.reduce({}) do |acc, (k, v)| acc.tap do |hash| hash[:"opt_#{k}"] = v.is_a?(Array) ? v.join(',') : v end end options.merge(opts) params = { data: body }.merge(options.empty? ? {} : { options: options }) perform_request(:put, resource_uri, params, options[:headers]) end # Public: Performs a POST request against the API. # # resource_uri - [String] the resource URI relative to the base Asana API # URL, e.g "/tags". # body - [Hash] the body to POST. # upload - [Faraday::UploadIO] an upload object to post as multipart. # Defaults to nil. # options - [Hash] the request I/O options # # Returns an [Asana::HttpClient::Response] if everything went well. # Raises [Asana::Errors::APIError] if anything went wrong. def post(resource_uri, body: {}, upload: nil, options: {}) opts = options.reduce({}) do |acc, (k, v)| acc.tap do |hash| hash[:"opt_#{k}"] = v.is_a?(Array) ? v.join(',') : v end end options.merge(opts) params = { data: body }.merge(options.empty? ? {} : { options: options }) if upload perform_request(:post, resource_uri, params.merge(file: upload), options[:headers]) do |c| c.request :multipart end else perform_request(:post, resource_uri, params, options[:headers]) end end # Public: Performs a DELETE request against the API. # # resource_uri - [String] the resource URI relative to the base Asana API # URL, e.g "/tags". # options - [Hash] the request I/O options # # Returns an [Asana::HttpClient::Response] if everything went well. # Raises [Asana::Errors::APIError] if anything went wrong. def delete(resource_uri, params: {}, options: {}) opts = options.reduce({}) do |acc, (k, v)| acc.tap do |hash| hash[:"opt_#{k}"] = v.is_a?(Array) ? v.join(',') : v end end perform_request(:delete, resource_uri, params.merge(opts), options[:headers]) end private def connection(&request_config) Faraday.new do |builder| @authentication.configure(builder) @environment_info.configure(builder) yield builder if request_config configure_format(builder) add_middleware(builder) @config.call(builder) if @config use_adapter(builder, @adapter) end end def perform_request(method, resource_uri, body = {}, headers = {}, &request_config) handling_errors do url = BASE_URI + resource_uri headers = (@default_headers || {}).merge(headers || {}) log_request(method, url, body) if @debug_mode result = Response.new(connection(&request_config).public_send(method, url, body, headers)) log_asana_change_headers(headers, result.headers) if @log_asana_change_warnings result end end def configure_format(builder) builder.request :multi_json builder.response :multi_json end def add_middleware(builder) builder.use Faraday::Response::RaiseError builder.use FaradayMiddleware::FollowRedirects end def use_adapter(builder, adapter) case adapter when Symbol builder.adapter(adapter) when Proc adapter.call(builder) end end def handling_errors(&request) ErrorHandling.handle(&request) end def log_request(method, url, body) STDERR.puts format('[%s] %s %s (%s)', self.class, method.to_s.upcase, url, body.inspect) end def log_asana_change_headers(request_headers, response_headers) change_header_key = nil response_headers.each_key do |key| if key.downcase == 'asana-change' change_header_key = key end end if change_header_key != nil accounted_for_flags = Array.new if request_headers == nil request_headers = {} end # Grab the request's asana-enable flags request_headers.each_key do |req_header| if req_header.downcase == 'asana-enable' request_headers[req_header].split(',').each do |flag| accounted_for_flags.push(flag) end elsif req_header.downcase == 'asana-disable' request_headers[req_header].split(',').each do |flag| accounted_for_flags.push(flag) end end end changes = response_headers[change_header_key].split(',') changes.each do |unsplit_change| change = unsplit_change.split(';') name = nil info = nil affected = nil change.each do |unsplit_field| field = unsplit_field.split('=') field[0].strip! field[1].strip! if field[0] == 'name' name = field[1] elsif field[0] == 'info' info = field[1] elsif field[0] == 'affected' affected = field[1] end # Only show the error if the flag was not in the request's asana-enable header if !(accounted_for_flags.include? name) && (affected == 'true') message1 = 'This request is affected by the "%s"' + ' deprecation. Please visit this url for more info: %s' message2 = 'Adding "%s" to your "Asana-Enable" or ' + '"Asana-Disable" header will opt in/out to this deprecation ' + 'and suppress this warning.' STDERR.puts format(message1, name, info) STDERR.puts format(message2, name) end end end end end end end asana-0.10.3/lib/asana/resources.rb0000644000175100017510000000064114002345121016065 0ustar pravipravirequire_relative 'resource_includes/resource' require_relative 'resource_includes/collection' Dir[File.join(File.dirname(__FILE__), 'resource_includes', '*.rb')] .each { |resource| require resource } Dir[File.join(File.dirname(__FILE__), 'resources', '*.rb')] .each { |resource| require resource } module Asana # Public: Contains all the resources that the Asana API can return. module Resources end end asana-0.10.3/lib/asana/client/0000755000175100017510000000000014002345121015003 5ustar pravipraviasana-0.10.3/lib/asana/client/configuration.rb0000644000175100017510000001336114002345121020203 0ustar pravipravimodule Asana class Client # Internal: Represents a configuration DSL for an Asana::Client. # # Examples # # config = Configuration.new # config.authentication :access_token, 'personal_access_token' # config.adapter :typhoeus # config.configure_faraday { |conn| conn.use MyMiddleware } # config.to_h # # => { authentication: #, # faraday_adapter: :typhoeus, # faraday_configuration: # } # class Configuration # Public: Initializes an empty configuration object. def initialize @configuration = { :log_asana_change_warnings => true } end # Public: Sets an authentication strategy. # # type - [:oauth2, :api_token] the kind of authentication strategy to use # value - [::OAuth2::AccessToken, String, Hash] the configuration for the # chosen authentication strategy. # # Returns nothing. # # Raises ArgumentError if the arguments are invalid. def authentication(type, value) auth = case type when :oauth2 then oauth2(value) when :access_token then from_bearer_token(value) else error "unsupported authentication type #{type}" end @configuration[:authentication] = auth end # Public: Sets a custom network adapter for Faraday. # # adapter - [Symbol, Proc] the adapter. # # Returns nothing. def faraday_adapter(adapter) @configuration[:faraday_adapter] = adapter end # Public: Sets a custom configuration block for the Faraday connection. # # config - [Proc] the configuration block. # # Returns nothing. def configure_faraday(&config) @configuration[:faraday_configuration] = config end # Public: Configures the client in debug mode, which will print verbose # information on STDERR. # # Returns nothing. def debug_mode @configuration[:debug_mode] = true end # Public: Configures the client to log Asana-Change warnings on STDERR. # # Returns nothing. def log_asana_change_warnings(value) @configuration[:log_asana_change_warnings] = !!value end # Public: Configures the client to always send the given headers # # Returns nothing. def default_headers(value) @configuration[:default_headers] = value end # Public: # Returns the configuration [Hash]. def to_h @configuration end private # Internal: Configures an OAuth2 authentication strategy from either an # OAuth2 access token object, or a plain refresh token, or a plain bearer # token. # # value - [::OAuth::AccessToken, String] the value to configure the # strategy from. # # Returns [Asana::Authentication::OAuth2::AccessTokenAuthentication, # Asana::Authentication::OAuth2::BearerTokenAuthentication] # the OAuth2 authentication strategy. # # Raises ArgumentError if the OAuth2 configuration arguments are invalid. # # rubocop:disable Metrics/MethodLength def oauth2(value) case value when ::OAuth2::AccessToken from_access_token(value) when ->(v) { v.is_a?(Hash) && v[:refresh_token] } from_refresh_token(value) when ->(v) { v.is_a?(Hash) && v[:bearer_token] } from_bearer_token(value[:bearer_token]) else error 'Invalid OAuth2 configuration: pass in either an ' \ '::OAuth2::AccessToken object of your own or a hash ' \ 'containing :refresh_token or :bearer_token.' end end # Internal: Configures an OAuth2 AccessTokenAuthentication strategy. # # access_token - [::OAuth2::AccessToken] the OAuth2 access token object # # Returns a [Authentication::OAuth2::AccessTokenAuthentication] strategy. def from_access_token(access_token) Authentication::OAuth2::AccessTokenAuthentication .new(access_token) end # Internal: Configures an OAuth2 AccessTokenAuthentication strategy. # # hash - The configuration hash: # :refresh_token - [String] the OAuth2 refresh token # :client_id - [String] the OAuth2 client id # :client_secret - [String] the OAuth2 client secret # :redirect_uri - [String] the OAuth2 redirect URI # # Returns a [Authentication::OAuth2::AccessTokenAuthentication] strategy. def from_refresh_token(hash) refresh_token, client_id, client_secret, redirect_uri = requiring(hash, :refresh_token, :client_id, :client_secret, :redirect_uri) Authentication::OAuth2::AccessTokenAuthentication .from_refresh_token(refresh_token, client_id: client_id, client_secret: client_secret, redirect_uri: redirect_uri) end # Internal: Configures an OAuth2 BearerTokenAuthentication strategy. # # bearer_token - [String] the plain OAuth2 bearer token # # Returns a [Authentication::OAuth2::BearerTokenAuthentication] strategy. def from_bearer_token(bearer_token) Authentication::OAuth2::BearerTokenAuthentication .new(bearer_token) end def requiring(hash, *keys) missing_keys = keys.select { |k| !hash.key?(k) } missing_keys.any? && error("Missing keys: #{missing_keys.join(', ')}") keys.map { |k| hash[k] } end def error(msg) raise ArgumentError, msg end end end end asana-0.10.3/lib/asana/resource_includes/0000755000175100017510000000000014002345121017242 5ustar pravipraviasana-0.10.3/lib/asana/resource_includes/collection.rb0000644000175100017510000000430314002345121021722 0ustar pravipravirequire_relative 'response_helper' module Asana module Resources # Public: Represents a paginated collection of Asana resources. class Collection include Enumerable include ResponseHelper attr_reader :elements # Public: Initializes a collection representing a page of resources of a # given type. # # (elements, extra) - [Array] an (String, Hash) tuple coming from the # response parser. # type - [Class] the type of resource that the collection # contains. Defaults to the generic Resource. # client - [Asana::Client] the client to perform requests. def initialize((elements, extra), type: Resource, client: required('client')) @elements = elements.map { |elem| type.new(elem, client: client) } @type = type @next_page_data = extra['next_page'] @client = client end # Public: Iterates over the elements of the collection. def each(&block) if block @elements.each(&block) (next_page || []).each(&block) else to_enum end end # Public: Returns the last item in the collection. def last @elements.last end # Public: Returns the size of the collection. def size to_a.size end alias length size # Public: Returns a String representation of the collection. def to_s "# " \ "[#{@elements.map(&:inspect).join(', ')}" + (@next_page_data ? ', ...' : '') + ']>' end alias inspect to_s # Public: Returns a new Asana::Resources::Collection with the next page # or nil if there are no more pages. Caches the result. def next_page if defined?(@next_page) @next_page else @next_page = if @next_page_data response = parse(@client.get(@next_page_data['path'])) self.class.new(response, type: @type, client: @client) end end end end end end asana-0.10.3/lib/asana/resource_includes/resource.rb0000644000175100017510000000534714002345121021427 0ustar pravipravirequire_relative 'registry' require_relative 'response_helper' module Asana module Resources # Public: The base resource class which provides some sugar over common # resource functionality. class Resource include ResponseHelper extend ResponseHelper def initialize(data, client: required('client')) @_client = client @_data = data data.each do |k, v| instance_variable_set(:"@#{k}", v) if respond_to?(k) end end # If it has findById, it implements #refresh def refresh raise "#{self.class.name} does not respond to #find_by_id" unless \ self.class.respond_to?(:find_by_id) self.class.find_by_id(client, gid) end # Internal: Proxies method calls to the data, wrapping it accordingly and # caching the result by defining a real reader method. # # Returns the value for the requested property. # # Raises a NoMethodError if the property doesn't exist. def method_missing(m, *args) super unless respond_to_missing?(m, *args) cache(m, wrapped(to_h[m.to_s])) end # Internal: Guard for the method_missing proxy. Checks if the resource # actually has a specific piece of data at all. # # Returns true if the resource has the property, false otherwise. def respond_to_missing?(m, *) to_h.key?(m.to_s) end # Public: # Returns the raw Hash representation of the data. def to_h @_data end def to_s attrs = to_h.map { |k, _| "#{k}: #{public_send(k).inspect}" }.join(', ') "#" end alias inspect to_s private # Internal: The Asana::Client instance. def client @_client end # Internal: Caches a property and a value by defining a reader method for # it. # # property - [#to_s] the property # value - [Object] the corresponding value # # Returns the value. def cache(property, value) field = :"@#{property}" instance_variable_set(field, value) define_singleton_method(property) { instance_variable_get(field) } value end # Internal: Wraps a value in a more useful class if possible, namely a # Resource or a Collection. # # Returns the wrapped value or the plain value if it couldn't be wrapped. def wrapped(value) case value when Hash then Resource.new(value, client: client) when Array then value.map(&method(:wrapped)) else value end end def refresh_with(data) self.class.new(data, client: @_client) end end end end asana-0.10.3/lib/asana/resource_includes/events.rb0000644000175100017510000000666014002345121021103 0ustar pravipravirequire_relative 'event' module Asana module Resources # Public: An infinite collection of events. # # Since they are infinite, if you want to filter or do other collection # operations without blocking indefinitely you should call #lazy on them to # turn them into a lazy collection. # # Examples: # # # Subscribes to an event stream and blocks indefinitely, printing # # information of every event as it comes in. # events = Events.new(resource: 'someresourceID', client: client) # events.each do |event| # puts [event.type, event.action] # end # # # Lazily filters events as they come in and prints them. # events = Events.new(resource: 'someresourceID', client: client) # events.lazy.select { |e| e.type == 'task' }.each do |event| # puts [event.type, event.action] # end # class Events include Enumerable # Public: Initializes a new Events instance, subscribed to a resource ID. # # resource - [String] a resource ID. Can be a task id or a workspace id. # client - [Asana::Client] a client to perform the requests. # wait - [Integer] the number of seconds to wait between each poll. # options - [Hash] the request I/O options def initialize(resource: required('resource'), client: required('client'), wait: 1, options: {}) @resource = resource @client = client @events = [] @wait = wait @options = options @sync = nil @last_poll = nil end # Public: Iterates indefinitely over all events happening to a particular # resource from the @sync timestamp or from now if it is nil. def each(&block) if block loop do poll if @events.empty? event = @events.shift yield event if event end else to_enum end end private # Internal: Polls and fetches all events that have occurred since the sync # token was created. Updates the sync token as it comes back from the # response. # # If we polled less than @wait seconds ago, we don't do anything. # # Notes: # # On the first request, the sync token is not passed (because it is # nil). The response will be the same as for an expired sync token, and # will include a new valid sync token. # # If the sync token is too old (which may happen from time to time) # the API will return a `412 Precondition Failed` error, and include # a fresh `sync` token in the response. def poll rate_limiting do body = @client.get('/events', params: params, options: @options).body @sync = body['sync'] @events += body.fetch('data', []).map do |event_data| Event.new(event_data, client: @client) end end end # Internal: Returns the formatted params for the poll request. def params { resource: @resource, sync: @sync }.reject { |_, v| v.nil? } end # Internal: Executes a block if at least @wait seconds have passed since # @last_poll. def rate_limiting return if @last_poll && Time.now - @last_poll <= @wait yield.tap { @last_poll = Time.now } end end end end asana-0.10.3/lib/asana/resource_includes/attachment_uploading.rb0000644000175100017510000000303314002345121023760 0ustar pravipravimodule Asana module Resources # Internal: Mixin to add the ability to upload an attachment to a specific # Asana resource (a Task, really). module AttachmentUploading # Uploads a new attachment to the resource. # # filename - [String] the absolute path of the file to upload OR the desired filename when using +io+ # mime - [String] the MIME type of the file # io - [IO] an object which returns the file's content on +#read+, e.g. a +::StringIO+ # options - [Hash] the request I/O options # data - [Hash] extra attributes to post # # rubocop:disable Metrics/AbcSize # rubocop:disable Metrics/MethodLength def attach(filename: required('filename'), mime: required('mime'), io: nil, options: {}, **data) upload = if io.nil? path = File.expand_path(filename) raise ArgumentError, "file #{filename} doesn't exist" unless File.exist?(path) Faraday::FilePart.new(path, mime) else Faraday::FilePart.new(io, mime, filename) end response = client.post("/#{self.class.plural_name}/#{gid}/attachments", body: data, upload: upload, options: options) Attachment.new(parse(response).first, client: client) end # rubocop:enable Metrics/MethodLength # rubocop:enable Metrics/AbcSize end end end asana-0.10.3/lib/asana/resource_includes/response_helper.rb0000644000175100017510000000057114002345121022767 0ustar pravipravimodule Asana module Resources # Internal: A helper to make response body parsing easier. module ResponseHelper def parse(response) data = response.body.fetch('data') do raise("Unexpected response body: #{response.body}") end extra = response.body.reject { |k, _| k == 'data' } [data, extra] end end end end asana-0.10.3/lib/asana/resource_includes/event.rb0000644000175100017510000000372314002345121020715 0ustar pravipravirequire_relative 'events' module Asana module Resources # An _event_ is an object representing a change to a resource that was # observed by an event subscription. # # In general, requesting events on a resource is faster and subject to # higher rate limits than requesting the resource itself. Additionally, # change events bubble up - listening to events on a project would include # when stories are added to tasks in the project, even on subtasks. # # Establish an initial sync token by making a request with no sync token. # The response will be a `412` error - the same as if the sync token had # expired. # # Subsequent requests should always provide the sync token from the # immediately preceding call. # # Sync tokens may not be valid if you attempt to go 'backward' in the # history by requesting previous tokens, though re-requesting the current # sync token is generally safe, and will always return the same results. # # When you receive a `412 Precondition Failed` error, it means that the sync # token is either invalid or expired. If you are attempting to keep a set of # data in sync, this signals you may need to re-crawl the data. # # Sync tokens always expire after 24 hours, but may expire sooner, depending # on load on the service. class Event < Resource attr_reader :type class << self # Returns the plural name of the resource. def plural_name 'events' end # Public: Returns an infinite collection of events on a particular # resource. # # client - [Asana::Client] the client to perform the requests. # id - [String] the id of the resource to get events from. # wait - [Integer] the number of seconds to wait between each poll. def for(client, id, wait: 1) Events.new(resource: id, client: client, wait: wait) end end end end end asana-0.10.3/lib/asana/resource_includes/registry.rb0000644000175100017510000000350414002345121021441 0ustar pravipravirequire_relative 'resource' require 'set' module Asana module Resources # Internal: Global registry of Resource subclasses. It provides lookup from # singular and plural names to the actual class objects. # # Examples # # class Unicorn < Asana::Resources::Resource # path '/unicorns' # end # # Registry.lookup(:unicorn) # => Unicorn # Registry.lookup_many(:unicorns) # => Unicorn # module Registry class << self # Public: Registers a new resource class. # # resource_klass - [Class] the resource class. # # Returns nothing. def register(resource_klass) resources << resource_klass end # Public: Looks up a resource class by its singular name. # # singular_name - [#to_s] the name of the resource, e.g :unicorn. # # Returns the resource class or {Asana::Resources::Resource}. def lookup(singular_name) resources.detect do |klass| klass.singular_name.to_s == singular_name.to_s end || Resource end # Public: Looks up a resource class by its plural name. # # plural_name - [#to_s] the plural name of the resource, e.g :unicorns. # # Returns the resource class or {Asana::Resources::Resource}. def lookup_many(plural_name) resources.detect do |klass| klass.plural_name.to_s == plural_name.to_s end || Resource end # Internal: A set of Resource classes. # # Returns the Set, defaulting to the empty set. # # Note: this object is a mutable singleton, so it should not be accessed # from multiple threads. def resources @resources ||= Set.new end end end end end asana-0.10.3/lib/asana/resource_includes/event_subscription.rb0000644000175100017510000000062314002345121023515 0ustar pravipravirequire_relative 'events' module Asana module Resources # Public: Mixin to enable a resource with the ability to fetch events about # itself. module EventSubscription # Public: Returns an infinite collection of events on the resource. def events(wait: 1, options: {}) Events.new(resource: gid, client: client, wait: wait, options: options) end end end end asana-0.10.3/lib/asana/resources/0000755000175100017510000000000014002345121015537 5ustar pravipraviasana-0.10.3/lib/asana/resources/organization_export.rb0000644000175100017510000000435314002345121022176 0ustar pravipravirequire_relative 'gen/organization_exports_base' module Asana module Resources # An _organization_export_ object represents a request to export the complete data of an Organization # in JSON format. # # To export an Organization using this API: # # * Create an `organization_export` [request](#create) and store the id that is returned.\ # * Request the `organization_export` every few minutes, until the `state` field contains 'finished'.\ # * Download the file located at the URL in the `download_url` field. # # Exports can take a long time, from several minutes to a few hours for large Organizations. # # **Note:** These endpoints are only available to [Service Accounts](/guide/help/premium/service-accounts) # of an [Enterprise](/enterprise) Organization. class OrganizationExport < OrganizationExportsBase attr_reader :gid attr_reader :created_at attr_reader :download_url attr_reader :state attr_reader :organization class << self # Returns the plural name of the resource. def plural_name 'organization_exports' end # Returns details of a previously-requested Organization export. # # id - [Gid] Globally unique identifier for the Organization export. # # options - [Hash] the request I/O options. def find_by_id(client, id, options: {}) self.new(parse(client.get("/organization_exports/#{id}", options: options)).first, client: client) end # This method creates a request to export an Organization. Asana will complete the export at some # point after you create the request. # # organization - [Gid] Globally unique identifier for the workspace or organization. # # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def create(client, organization: required("organization"), options: {}, **data) with_params = data.merge(organization: organization).reject { |_,v| v.nil? || Array(v).empty? } Resource.new(parse(client.post("/organization_exports", body: with_params, options: options)).first, client: client) end end end end end asana-0.10.3/lib/asana/resources/team_membership.rb0000644000175100017510000000065414002345121021232 0ustar pravipravirequire_relative 'gen/team_memberships_base' module Asana module Resources class TeamMembership < TeamMembershipsBase attr_reader :gid attr_reader :resource_type attr_reader :user attr_reader :team attr_reader :is_guest class << self # Returns the plural name of the resource. def plural_name 'team_memberships' end end end end end asana-0.10.3/lib/asana/resources/gen/0000755000175100017510000000000014002345121016310 5ustar pravipraviasana-0.10.3/lib/asana/resources/gen/team_memberships_base.rb0000644000175100017510000001702014002345121023153 0ustar pravipravi### WARNING: This file is auto-generated by our OpenAPI spec. Do not ### edit it manually. require_relative '../../resource_includes/response_helper' module Asana module Resources class TeamMembershipsBase < Resource def self.inherited(base) Registry.register(base) end class << self # Get a team membership # # team_membership_gid - [str] (required) # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_team_membership(client, team_membership_gid: required("team_membership_gid"), options: {}) path = "/team_memberships/{team_membership_gid}" path["{team_membership_gid}"] = team_membership_gid parse(client.get(path, options: options)).first end # Get team memberships # # team - [str] Globally unique identifier for the team. # user - [str] A string identifying a user. This can either be the string \"me\", an email, or the gid of a user. This parameter must be used with the workspace parameter. # workspace - [str] Globally unique identifier for the workspace. This parameter must be used with the user parameter. # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_team_memberships(client, team: nil, user: nil, workspace: nil, options: {}) path = "/team_memberships" params = { team: team, user: user, workspace: workspace }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get(path, params: params, options: options)), type: Resource, client: client) end # Get memberships from a team # # team_gid - [str] (required) Globally unique identifier for the team. # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_team_memberships_for_team(client, team_gid: required("team_gid"), options: {}) path = "/teams/{team_gid}/team_memberships" path["{team_gid}"] = team_gid Collection.new(parse(client.get(path, options: options)), type: Resource, client: client) end # Get memberships from a user # # user_gid - [str] (required) A string identifying a user. This can either be the string \"me\", an email, or the gid of a user. # workspace - [str] (required) Globally unique identifier for the workspace. # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_team_memberships_for_user(client, user_gid: required("user_gid"), workspace: nil, options: {}) path = "/users/{user_gid}/team_memberships" path["{user_gid}"] = user_gid params = { workspace: workspace }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get(path, params: params, options: options)), type: Resource, client: client) end end end end end asana-0.10.3/lib/asana/resources/gen/teams_base.rb0000644000175100017510000002074014002345121020743 0ustar pravipravi### WARNING: This file is auto-generated by our OpenAPI spec. Do not ### edit it manually. require_relative '../../resource_includes/response_helper' module Asana module Resources class TeamsBase < Resource def self.inherited(base) Registry.register(base) end class << self # Add a user to a team # # team_gid - [str] (required) Globally unique identifier for the team. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def add_user_for_team(client, team_gid: required("team_gid"), options: {}, **data) path = "/teams/{team_gid}/addUser" path["{team_gid}"] = team_gid User.new(parse(client.post(path, body: data, options: options)).first, client: client) end # Get a team # # team_gid - [str] (required) Globally unique identifier for the team. # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_team(client, team_gid: required("team_gid"), options: {}) path = "/teams/{team_gid}" path["{team_gid}"] = team_gid Team.new(parse(client.get(path, options: options)).first, client: client) end # Get teams in an organization # # workspace_gid - [str] (required) Globally unique identifier for the workspace or organization. # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_teams_for_organization(client, workspace_gid: required("workspace_gid"), options: {}) path = "/organizations/{workspace_gid}/teams" path["{workspace_gid}"] = workspace_gid Collection.new(parse(client.get(path, options: options)), type: Team, client: client) end # Get teams for a user # # user_gid - [str] (required) A string identifying a user. This can either be the string \"me\", an email, or the gid of a user. # organization - [str] (required) The workspace or organization to filter teams on. # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_teams_for_user(client, user_gid: required("user_gid"), organization: nil, options: {}) path = "/users/{user_gid}/teams" path["{user_gid}"] = user_gid params = { organization: organization }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get(path, params: params, options: options)), type: Team, client: client) end # Remove a user from a team # # team_gid - [str] (required) Globally unique identifier for the team. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def remove_user_for_team(client, team_gid: required("team_gid"), options: {}, **data) path = "/teams/{team_gid}/removeUser" path["{team_gid}"] = team_gid parse(client.post(path, body: data, options: options)).first end end end end end asana-0.10.3/lib/asana/resources/gen/events_base.rb0000644000175100017510000000422514002345121021136 0ustar pravipravi### WARNING: This file is auto-generated by our OpenAPI spec. Do not ### edit it manually. require_relative '../../resource_includes/response_helper' module Asana module Resources class EventsBase < Resource def self.inherited(base) Registry.register(base) end class << self # Get events on a resource # # resource - [str] (required) A resource ID to subscribe to. The resource can be a task or project. # sync - [str] A sync token received from the last request, or none on first sync. Events will be returned from the point in time that the sync token was generated. *Note: On your first request, omit the sync token. The response will be the same as for an expired sync token, and will include a new valid sync token.If the sync token is too old (which may happen from time to time) the API will return a `412 Precondition Failed` error, and include a fresh sync token in the response.* # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_events(client, resource: nil, sync: nil, options: {}) path = "/events" params = { resource: resource, sync: sync }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get(path, params: params, options: options)), type: Resource, client: client) end end end end end asana-0.10.3/lib/asana/resources/gen/users_base.rb0000644000175100017510000002113014002345121020765 0ustar pravipravi### WARNING: This file is auto-generated by our OpenAPI spec. Do not ### edit it manually. require_relative '../../resource_includes/response_helper' module Asana module Resources class UsersBase < Resource def self.inherited(base) Registry.register(base) end class << self # Get a user's favorites # # user_gid - [str] (required) A string identifying a user. This can either be the string \"me\", an email, or the gid of a user. # resource_type - [str] (required) The resource type of favorites to be returned. # workspace - [str] (required) The workspace in which to get favorites. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_favorites_for_user(client, user_gid: required("user_gid"), resource_type: nil, workspace: nil, options: {}) path = "/users/{user_gid}/favorites" path["{user_gid}"] = user_gid params = { resource_type: resource_type, workspace: workspace }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get(path, params: params, options: options)), type: Resource, client: client) end # Get a user # # user_gid - [str] (required) A string identifying a user. This can either be the string \"me\", an email, or the gid of a user. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_user(client, user_gid: required("user_gid"), options: {}) path = "/users/{user_gid}" path["{user_gid}"] = user_gid User.new(parse(client.get(path, options: options)).first, client: client) end # Get multiple users # # workspace - [str] The workspace or organization ID to filter users on. # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_users(client, workspace: nil, options: {}) path = "/users" params = { workspace: workspace }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get(path, params: params, options: options)), type: User, client: client) end # Get users in a team # # team_gid - [str] (required) Globally unique identifier for the team. # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_users_for_team(client, team_gid: required("team_gid"), options: {}) path = "/teams/{team_gid}/users" path["{team_gid}"] = team_gid Collection.new(parse(client.get(path, options: options)), type: User, client: client) end # Get users in a workspace or organization # # workspace_gid - [str] (required) Globally unique identifier for the workspace or organization. # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_users_for_workspace(client, workspace_gid: required("workspace_gid"), options: {}) path = "/workspaces/{workspace_gid}/users" path["{workspace_gid}"] = workspace_gid Collection.new(parse(client.get(path, options: options)), type: User, client: client) end end end end end asana-0.10.3/lib/asana/resources/gen/custom_field_settings_base.rb0000644000175100017510000001001214002345121024216 0ustar pravipravi### WARNING: This file is auto-generated by our OpenAPI spec. Do not ### edit it manually. require_relative '../../resource_includes/response_helper' module Asana module Resources class CustomFieldSettingsBase < Resource def self.inherited(base) Registry.register(base) end class << self # Get a portfolio's custom fields # # portfolio_gid - [str] (required) Globally unique identifier for the portfolio. # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_custom_field_settings_for_portfolio(client, portfolio_gid: required("portfolio_gid"), options: {}) path = "/portfolios/{portfolio_gid}/custom_field_settings" path["{portfolio_gid}"] = portfolio_gid Collection.new(parse(client.get(path, options: options)), type: CustomFieldSetting, client: client) end # Get a project's custom fields # # project_gid - [str] (required) Globally unique identifier for the project. # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_custom_field_settings_for_project(client, project_gid: required("project_gid"), options: {}) path = "/projects/{project_gid}/custom_field_settings" path["{project_gid}"] = project_gid Collection.new(parse(client.get(path, options: options)), type: CustomFieldSetting, client: client) end end end end end asana-0.10.3/lib/asana/resources/gen/webhooks_base.rb0000644000175100017510000001352314002345121021454 0ustar pravipravi### WARNING: This file is auto-generated by our OpenAPI spec. Do not ### edit it manually. require_relative '../../resource_includes/response_helper' module Asana module Resources class WebhooksBase < Resource def self.inherited(base) Registry.register(base) end class << self # Establish a webhook # # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def create_webhook(client, options: {}, **data) path = "/webhooks" Webhook.new(parse(client.post(path, body: data, options: options)).first, client: client) end # Delete a webhook # # webhook_gid - [str] (required) Globally unique identifier for the webhook. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def delete_webhook(client, webhook_gid: required("webhook_gid"), options: {}) path = "/webhooks/{webhook_gid}" path["{webhook_gid}"] = webhook_gid parse(client.delete(path, options: options)).first end # Get a webhook # # webhook_gid - [str] (required) Globally unique identifier for the webhook. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_webhook(client, webhook_gid: required("webhook_gid"), options: {}) path = "/webhooks/{webhook_gid}" path["{webhook_gid}"] = webhook_gid Webhook.new(parse(client.get(path, options: options)).first, client: client) end # Get multiple webhooks # # workspace - [str] (required) The workspace to query for webhooks in. # resource - [str] Only return webhooks for the given resource. # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_webhooks(client, workspace: nil, resource: nil, options: {}) path = "/webhooks" params = { workspace: workspace, resource: resource }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get(path, params: params, options: options)), type: Webhook, client: client) end end end end end asana-0.10.3/lib/asana/resources/gen/tasks_base.rb0000644000175100017510000013276514002345121020772 0ustar pravipravi### WARNING: This file is auto-generated by our OpenAPI spec. Do not ### edit it manually. require_relative '../../resource_includes/response_helper' module Asana module Resources class TasksBase < Resource def self.inherited(base) Registry.register(base) end class << self # Set dependencies for a task # # task_gid - [str] (required) The task to operate on. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def add_dependencies_for_task(client, task_gid: required("task_gid"), options: {}, **data) path = "/tasks/{task_gid}/addDependencies" path["{task_gid}"] = task_gid parse(client.post(path, body: data, options: options)).first end # Set dependents for a task # # task_gid - [str] (required) The task to operate on. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def add_dependents_for_task(client, task_gid: required("task_gid"), options: {}, **data) path = "/tasks/{task_gid}/addDependents" path["{task_gid}"] = task_gid Collection.new(parse(client.post(path, body: data, options: options)), type: Task, client: client) end # Add followers to a task # # task_gid - [str] (required) The task to operate on. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def add_followers_for_task(client, task_gid: required("task_gid"), options: {}, **data) path = "/tasks/{task_gid}/addFollowers" path["{task_gid}"] = task_gid parse(client.post(path, body: data, options: options)).first end # Add a project to a task # # task_gid - [str] (required) The task to operate on. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def add_project_for_task(client, task_gid: required("task_gid"), options: {}, **data) path = "/tasks/{task_gid}/addProject" path["{task_gid}"] = task_gid parse(client.post(path, body: data, options: options)).first end # Add a tag to a task # # task_gid - [str] (required) The task to operate on. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def add_tag_for_task(client, task_gid: required("task_gid"), options: {}, **data) path = "/tasks/{task_gid}/addTag" path["{task_gid}"] = task_gid parse(client.post(path, body: data, options: options)).first end # Create a subtask # # task_gid - [str] (required) The task to operate on. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def create_subtask_for_task(client, task_gid: required("task_gid"), options: {}, **data) path = "/tasks/{task_gid}/subtasks" path["{task_gid}"] = task_gid Task.new(parse(client.post(path, body: data, options: options)).first, client: client) end # Create a task # # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def create_task(client, options: {}, **data) path = "/tasks" Task.new(parse(client.post(path, body: data, options: options)).first, client: client) end # Delete a task # # task_gid - [str] (required) The task to operate on. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def delete_task(client, task_gid: required("task_gid"), options: {}) path = "/tasks/{task_gid}" path["{task_gid}"] = task_gid parse(client.delete(path, options: options)).first end # Duplicate a task # # task_gid - [str] (required) The task to operate on. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def duplicate_task(client, task_gid: required("task_gid"), options: {}, **data) path = "/tasks/{task_gid}/duplicate" path["{task_gid}"] = task_gid Job.new(parse(client.post(path, body: data, options: options)).first, client: client) end # Get dependencies from a task # # task_gid - [str] (required) The task to operate on. # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_dependencies_for_task(client, task_gid: required("task_gid"), options: {}) path = "/tasks/{task_gid}/dependencies" path["{task_gid}"] = task_gid Collection.new(parse(client.get(path, options: options)), type: Task, client: client) end # Get dependents from a task # # task_gid - [str] (required) The task to operate on. # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_dependents_for_task(client, task_gid: required("task_gid"), options: {}) path = "/tasks/{task_gid}/dependents" path["{task_gid}"] = task_gid Collection.new(parse(client.get(path, options: options)), type: Task, client: client) end # Get subtasks from a task # # task_gid - [str] (required) The task to operate on. # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_subtasks_for_task(client, task_gid: required("task_gid"), options: {}) path = "/tasks/{task_gid}/subtasks" path["{task_gid}"] = task_gid Collection.new(parse(client.get(path, options: options)), type: Task, client: client) end # Get a task # # task_gid - [str] (required) The task to operate on. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_task(client, task_gid: required("task_gid"), options: {}) path = "/tasks/{task_gid}" path["{task_gid}"] = task_gid Task.new(parse(client.get(path, options: options)).first, client: client) end # Get multiple tasks # # assignee - [str] The assignee to filter tasks on. *Note: If you specify `assignee`, you must also specify the `workspace` to filter on.* # project - [str] The project to filter tasks on. # section - [str] The section to filter tasks on. *Note: Currently, this is only supported in board views.* # workspace - [str] The workspace to filter tasks on. *Note: If you specify `workspace`, you must also specify the `assignee` to filter on.* # completed_since - [datetime] Only return tasks that are either incomplete or that have been completed since this time. # modified_since - [datetime] Only return tasks that have been modified since the given time. *Note: A task is considered “modified” if any of its properties change, or associations between it and other objects are modified (e.g. a task being added to a project). A task is not considered modified just because another object it is associated with (e.g. a subtask) is modified. Actions that count as modifying the task include assigning, renaming, completing, and adding stories.* # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_tasks(client, assignee: nil, project: nil, section: nil, workspace: nil, completed_since: nil, modified_since: nil, options: {}) path = "/tasks" params = { assignee: assignee, project: project, section: section, workspace: workspace, completed_since: completed_since, modified_since: modified_since }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get(path, params: params, options: options)), type: Task, client: client) end # Get tasks from a project # # project_gid - [str] (required) Globally unique identifier for the project. # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_tasks_for_project(client, project_gid: required("project_gid"), options: {}) path = "/projects/{project_gid}/tasks" path["{project_gid}"] = project_gid Collection.new(parse(client.get(path, options: options)), type: Task, client: client) end # Get tasks from a section # # section_gid - [str] (required) The globally unique identifier for the section. # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_tasks_for_section(client, section_gid: required("section_gid"), options: {}) path = "/sections/{section_gid}/tasks" path["{section_gid}"] = section_gid Collection.new(parse(client.get(path, options: options)), type: Task, client: client) end # Get tasks from a tag # # tag_gid - [str] (required) Globally unique identifier for the tag. # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_tasks_for_tag(client, tag_gid: required("tag_gid"), options: {}) path = "/tags/{tag_gid}/tasks" path["{tag_gid}"] = tag_gid Collection.new(parse(client.get(path, options: options)), type: Task, client: client) end # Get tasks from a user task list # # user_task_list_gid - [str] (required) Globally unique identifier for the user task list. # completed_since - [str] Only return tasks that are either incomplete or that have been completed since this time. Accepts a date-time string or the keyword *now*. # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_tasks_for_user_task_list(client, user_task_list_gid: required("user_task_list_gid"), completed_since: nil, options: {}) path = "/user_task_lists/{user_task_list_gid}/tasks" path["{user_task_list_gid}"] = user_task_list_gid params = { completed_since: completed_since }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get(path, params: params, options: options)), type: Task, client: client) end # Unlink dependencies from a task # # task_gid - [str] (required) The task to operate on. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def remove_dependencies_for_task(client, task_gid: required("task_gid"), options: {}, **data) path = "/tasks/{task_gid}/removeDependencies" path["{task_gid}"] = task_gid Collection.new(parse(client.post(path, body: data, options: options)), type: Resource, client: client) end # Unlink dependents from a task # # task_gid - [str] (required) The task to operate on. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def remove_dependents_for_task(client, task_gid: required("task_gid"), options: {}, **data) path = "/tasks/{task_gid}/removeDependents" path["{task_gid}"] = task_gid Collection.new(parse(client.post(path, body: data, options: options)), type: Resource, client: client) end # Remove followers from a task # # task_gid - [str] (required) The task to operate on. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def remove_follower_for_task(client, task_gid: required("task_gid"), options: {}, **data) path = "/tasks/{task_gid}/removeFollowers" path["{task_gid}"] = task_gid parse(client.post(path, body: data, options: options)).first end # Remove a project from a task # # task_gid - [str] (required) The task to operate on. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def remove_project_for_task(client, task_gid: required("task_gid"), options: {}, **data) path = "/tasks/{task_gid}/removeProject" path["{task_gid}"] = task_gid parse(client.post(path, body: data, options: options)).first end # Remove a tag from a task # # task_gid - [str] (required) The task to operate on. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def remove_tag_for_task(client, task_gid: required("task_gid"), options: {}, **data) path = "/tasks/{task_gid}/removeTag" path["{task_gid}"] = task_gid parse(client.post(path, body: data, options: options)).first end # Search tasks in a workspace # # workspace_gid - [str] (required) Globally unique identifier for the workspace or organization. # text - [str] Performs full-text search on both task name and description # resource_subtype - [str] Filters results by the task's resource_subtype # assignee_any - [str] Comma-separated list of user identifiers # assignee_not - [str] Comma-separated list of user identifiers # assignee_status - [str] One of `inbox`, `today`, `upcoming`, or `later` # portfolios_any - [str] Comma-separated list of portfolio IDs # projects_any - [str] Comma-separated list of project IDs # projects_not - [str] Comma-separated list of project IDs # projects_all - [str] Comma-separated list of project IDs # sections_any - [str] Comma-separated list of section or column IDs # sections_not - [str] Comma-separated list of section or column IDs # sections_all - [str] Comma-separated list of section or column IDs # tags_any - [str] Comma-separated list of tag IDs # tags_not - [str] Comma-separated list of tag IDs # tags_all - [str] Comma-separated list of tag IDs # teams_any - [str] Comma-separated list of team IDs # followers_any - [str] Comma-separated list of user identifiers # followers_not - [str] Comma-separated list of user identifiers # created_by_any - [str] Comma-separated list of user identifiers # created_by_not - [str] Comma-separated list of user identifiers # assigned_by_any - [str] Comma-separated list of user identifiers # assigned_by_not - [str] Comma-separated list of user identifiers # liked_by_any - [str] Comma-separated list of user identifiers # liked_by_not - [str] Comma-separated list of user identifiers # commented_on_by_any - [str] Comma-separated list of user identifiers # commented_on_by_not - [str] Comma-separated list of user identifiers # due_on_before - [date] ISO 8601 date string # due_on_after - [date] ISO 8601 date string # due_on - [date] ISO 8601 date string or `null` # due_at_before - [datetime] ISO 8601 datetime string # due_at_after - [datetime] ISO 8601 datetime string # start_on_before - [date] ISO 8601 date string # start_on_after - [date] ISO 8601 date string # start_on - [date] ISO 8601 date string or `null` # created_on_before - [date] ISO 8601 date string # created_on_after - [date] ISO 8601 date string # created_on - [date] ISO 8601 date string or `null` # created_at_before - [datetime] ISO 8601 datetime string # created_at_after - [datetime] ISO 8601 datetime string # completed_on_before - [date] ISO 8601 date string # completed_on_after - [date] ISO 8601 date string # completed_on - [date] ISO 8601 date string or `null` # completed_at_before - [datetime] ISO 8601 datetime string # completed_at_after - [datetime] ISO 8601 datetime string # modified_on_before - [date] ISO 8601 date string # modified_on_after - [date] ISO 8601 date string # modified_on - [date] ISO 8601 date string or `null` # modified_at_before - [datetime] ISO 8601 datetime string # modified_at_after - [datetime] ISO 8601 datetime string # is_blocking - [bool] Filter to incomplete tasks with dependents # is_blocked - [bool] Filter to tasks with incomplete dependencies # has_attachment - [bool] Filter to tasks with attachments # completed - [bool] Filter to completed tasks # is_subtask - [bool] Filter to subtasks # sort_by - [str] One of `due_date`, `created_at`, `completed_at`, `likes`, or `modified_at`, defaults to `modified_at` # sort_ascending - [bool] Default `false` # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def search_tasks_for_workspace(client, workspace_gid: required("workspace_gid"), text: nil, resource_subtype: nil, assignee_any: nil, assignee_not: nil, assignee_status: nil, portfolios_any: nil, projects_any: nil, projects_not: nil, projects_all: nil, sections_any: nil, sections_not: nil, sections_all: nil, tags_any: nil, tags_not: nil, tags_all: nil, teams_any: nil, followers_any: nil, followers_not: nil, created_by_any: nil, created_by_not: nil, assigned_by_any: nil, assigned_by_not: nil, liked_by_any: nil, liked_by_not: nil, commented_on_by_any: nil, commented_on_by_not: nil, due_on_before: nil, due_on_after: nil, due_on: nil, due_at_before: nil, due_at_after: nil, start_on_before: nil, start_on_after: nil, start_on: nil, created_on_before: nil, created_on_after: nil, created_on: nil, created_at_before: nil, created_at_after: nil, completed_on_before: nil, completed_on_after: nil, completed_on: nil, completed_at_before: nil, completed_at_after: nil, modified_on_before: nil, modified_on_after: nil, modified_on: nil, modified_at_before: nil, modified_at_after: nil, is_blocking: nil, is_blocked: nil, has_attachment: nil, completed: nil, is_subtask: nil, sort_by: nil, sort_ascending: nil, options: {}) path = "/workspaces/{workspace_gid}/tasks/search" path["{workspace_gid}"] = workspace_gid params = { text: text, resource_subtype: resource_subtype, "assignee.any": assignee_any, "assignee.not": assignee_not, assignee_status: assignee_status, "portfolios.any": portfolios_any, "projects.any": projects_any, "projects.not": projects_not, "projects.all": projects_all, "sections.any": sections_any, "sections.not": sections_not, "sections.all": sections_all, "tags.any": tags_any, "tags.not": tags_not, "tags.all": tags_all, "teams.any": teams_any, "followers.any": followers_any, "followers.not": followers_not, "created_by.any": created_by_any, "created_by.not": created_by_not, "assigned_by.any": assigned_by_any, "assigned_by.not": assigned_by_not, "liked_by.any": liked_by_any, "liked_by.not": liked_by_not, "commented_on_by.any": commented_on_by_any, "commented_on_by.not": commented_on_by_not, due_on_before: due_on_before, due_on_after: due_on_after, due_on: due_on, due_at_before: due_at_before, due_at_after: due_at_after, start_on_before: start_on_before, start_on_after: start_on_after, start_on: start_on, created_on_before: created_on_before, created_on_after: created_on_after, created_on: created_on, created_at_before: created_at_before, created_at_after: created_at_after, completed_on_before: completed_on_before, completed_on_after: completed_on_after, completed_on: completed_on, completed_at_before: completed_at_before, completed_at_after: completed_at_after, modified_on_before: modified_on_before, modified_on_after: modified_on_after, modified_on: modified_on, modified_at_before: modified_at_before, modified_at_after: modified_at_after, is_blocking: is_blocking, is_blocked: is_blocked, has_attachment: has_attachment, completed: completed, is_subtask: is_subtask, sort_by: sort_by, sort_ascending: sort_ascending }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get(path, params: params, options: options)), type: Task, client: client) end # Set the parent of a task # # task_gid - [str] (required) The task to operate on. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def set_parent_for_task(client, task_gid: required("task_gid"), options: {}, **data) path = "/tasks/{task_gid}/setParent" path["{task_gid}"] = task_gid Task.new(parse(client.post(path, body: data, options: options)).first, client: client) end # Update a task # # task_gid - [str] (required) The task to operate on. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to PUT def update_task(client, task_gid: required("task_gid"), options: {}, **data) path = "/tasks/{task_gid}" path["{task_gid}"] = task_gid Task.new(parse(client.put(path, body: data, options: options)).first, client: client) end end end end end asana-0.10.3/lib/asana/resources/gen/project_statuses_base.rb0000644000175100017510000001414614002345121023236 0ustar pravipravi### WARNING: This file is auto-generated by our OpenAPI spec. Do not ### edit it manually. require_relative '../../resource_includes/response_helper' module Asana module Resources class ProjectStatusesBase < Resource def self.inherited(base) Registry.register(base) end class << self # Create a project status # # project_gid - [str] (required) Globally unique identifier for the project. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def create_project_status_for_project(client, project_gid: required("project_gid"), options: {}, **data) path = "/projects/{project_gid}/project_statuses" path["{project_gid}"] = project_gid ProjectStatus.new(parse(client.post(path, body: data, options: options)).first, client: client) end # Delete a project status # # project_status_gid - [str] (required) The project status update to get. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def delete_project_status(client, project_status_gid: required("project_status_gid"), options: {}) path = "/project_statuses/{project_status_gid}" path["{project_status_gid}"] = project_status_gid parse(client.delete(path, options: options)).first end # Get a project status # # project_status_gid - [str] (required) The project status update to get. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_project_status(client, project_status_gid: required("project_status_gid"), options: {}) path = "/project_statuses/{project_status_gid}" path["{project_status_gid}"] = project_status_gid ProjectStatus.new(parse(client.get(path, options: options)).first, client: client) end # Get statuses from a project # # project_gid - [str] (required) Globally unique identifier for the project. # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_project_statuses_for_project(client, project_gid: required("project_gid"), options: {}) path = "/projects/{project_gid}/project_statuses" path["{project_gid}"] = project_gid Collection.new(parse(client.get(path, options: options)), type: ProjectStatus, client: client) end end end end end asana-0.10.3/lib/asana/resources/gen/attachments_base.rb0000644000175100017510000001117714002345121022151 0ustar pravipravi### WARNING: This file is auto-generated by our OpenAPI spec. Do not ### edit it manually. require_relative '../../resource_includes/response_helper' module Asana module Resources class AttachmentsBase < Resource def self.inherited(base) Registry.register(base) end class << self # Delete an attachment # # attachment_gid - [str] (required) Globally unique identifier for the attachment. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def delete_attachment(client, attachment_gid: required("attachment_gid"), options: {}) path = "/attachments/{attachment_gid}" path["{attachment_gid}"] = attachment_gid parse(client.delete(path, options: options)).first end # Get an attachment # # attachment_gid - [str] (required) Globally unique identifier for the attachment. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_attachment(client, attachment_gid: required("attachment_gid"), options: {}) path = "/attachments/{attachment_gid}" path["{attachment_gid}"] = attachment_gid Attachment.new(parse(client.get(path, options: options)).first, client: client) end # Get attachments for a task # # task_gid - [str] (required) The task to operate on. # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_attachments_for_task(client, task_gid: required("task_gid"), options: {}) path = "/tasks/{task_gid}/attachments" path["{task_gid}"] = task_gid Collection.new(parse(client.get(path, options: options)), type: Attachment, client: client) end end end end end asana-0.10.3/lib/asana/resources/gen/workspace_memberships_base.rb0000644000175100017510000001310714002345121024225 0ustar pravipravi### WARNING: This file is auto-generated by our OpenAPI spec. Do not ### edit it manually. require_relative '../../resource_includes/response_helper' module Asana module Resources class WorkspaceMembershipsBase < Resource def self.inherited(base) Registry.register(base) end class << self # Get a workspace membership # # workspace_membership_gid - [str] (required) # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_workspace_membership(client, workspace_membership_gid: required("workspace_membership_gid"), options: {}) path = "/workspace_memberships/{workspace_membership_gid}" path["{workspace_membership_gid}"] = workspace_membership_gid parse(client.get(path, options: options)).first end # Get workspace memberships for a user # # user_gid - [str] (required) A string identifying a user. This can either be the string \"me\", an email, or the gid of a user. # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_workspace_memberships_for_user(client, user_gid: required("user_gid"), options: {}) path = "/users/{user_gid}/workspace_memberships" path["{user_gid}"] = user_gid Collection.new(parse(client.get(path, options: options)), type: Resource, client: client) end # Get the workspace memberships for a workspace # # workspace_gid - [str] (required) Globally unique identifier for the workspace or organization. # user - [str] A string identifying a user. This can either be the string \"me\", an email, or the gid of a user. # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_workspace_memberships_for_workspace(client, workspace_gid: required("workspace_gid"), user: nil, options: {}) path = "/workspaces/{workspace_gid}/workspace_memberships" path["{workspace_gid}"] = workspace_gid params = { user: user }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get(path, params: params, options: options)), type: Resource, client: client) end end end end end asana-0.10.3/lib/asana/resources/gen/sections_base.rb0000644000175100017510000002364314002345121021466 0ustar pravipravi### WARNING: This file is auto-generated by our OpenAPI spec. Do not ### edit it manually. require_relative '../../resource_includes/response_helper' module Asana module Resources class SectionsBase < Resource def self.inherited(base) Registry.register(base) end class << self # Add task to section # # section_gid - [str] (required) The globally unique identifier for the section. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def add_task_for_section(client, section_gid: required("section_gid"), options: {}, **data) path = "/sections/{section_gid}/addTask" path["{section_gid}"] = section_gid parse(client.post(path, body: data, options: options)).first end # Create a section in a project # # project_gid - [str] (required) Globally unique identifier for the project. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def create_section_for_project(client, project_gid: required("project_gid"), options: {}, **data) path = "/projects/{project_gid}/sections" path["{project_gid}"] = project_gid Section.new(parse(client.post(path, body: data, options: options)).first, client: client) end # Delete a section # # section_gid - [str] (required) The globally unique identifier for the section. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def delete_section(client, section_gid: required("section_gid"), options: {}) path = "/sections/{section_gid}" path["{section_gid}"] = section_gid parse(client.delete(path, options: options)).first end # Get a section # # section_gid - [str] (required) The globally unique identifier for the section. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_section(client, section_gid: required("section_gid"), options: {}) path = "/sections/{section_gid}" path["{section_gid}"] = section_gid Section.new(parse(client.get(path, options: options)).first, client: client) end # Get sections in a project # # project_gid - [str] (required) Globally unique identifier for the project. # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_sections_for_project(client, project_gid: required("project_gid"), options: {}) path = "/projects/{project_gid}/sections" path["{project_gid}"] = project_gid Collection.new(parse(client.get(path, options: options)), type: Section, client: client) end # Move or Insert sections # # project_gid - [str] (required) Globally unique identifier for the project. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def insert_section_for_project(client, project_gid: required("project_gid"), options: {}, **data) path = "/projects/{project_gid}/sections/insert" path["{project_gid}"] = project_gid parse(client.post(path, body: data, options: options)).first end # Update a section # # section_gid - [str] (required) The globally unique identifier for the section. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to PUT def update_section(client, section_gid: required("section_gid"), options: {}, **data) path = "/sections/{section_gid}" path["{section_gid}"] = section_gid Section.new(parse(client.put(path, body: data, options: options)).first, client: client) end end end end end asana-0.10.3/lib/asana/resources/gen/user_task_lists_base.rb0000644000175100017510000000627714002345121023061 0ustar pravipravi### WARNING: This file is auto-generated by our OpenAPI spec. Do not ### edit it manually. require_relative '../../resource_includes/response_helper' module Asana module Resources class UserTaskListsBase < Resource def self.inherited(base) Registry.register(base) end class << self # Get a user task list # # user_task_list_gid - [str] (required) Globally unique identifier for the user task list. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_user_task_list(client, user_task_list_gid: required("user_task_list_gid"), options: {}) path = "/user_task_lists/{user_task_list_gid}" path["{user_task_list_gid}"] = user_task_list_gid UserTaskList.new(parse(client.get(path, options: options)).first, client: client) end # Get a user's task list # # user_gid - [str] (required) A string identifying a user. This can either be the string \"me\", an email, or the gid of a user. # workspace - [str] (required) The workspace in which to get the user task list. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_user_task_list_for_user(client, user_gid: required("user_gid"), workspace: nil, options: {}) path = "/users/{user_gid}/user_task_list" path["{user_gid}"] = user_gid params = { workspace: workspace }.reject { |_,v| v.nil? || Array(v).empty? } UserTaskList.new(parse(client.get(path, params: params, options: options)).first, client: client) end end end end end asana-0.10.3/lib/asana/resources/gen/tags_base.rb0000644000175100017510000003235514002345121020575 0ustar pravipravi### WARNING: This file is auto-generated by our OpenAPI spec. Do not ### edit it manually. require_relative '../../resource_includes/response_helper' module Asana module Resources class TagsBase < Resource def self.inherited(base) Registry.register(base) end class << self # Create a tag # # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def create_tag(client, options: {}, **data) path = "/tags" Tag.new(parse(client.post(path, body: data, options: options)).first, client: client) end # Create a tag in a workspace # # workspace_gid - [str] (required) Globally unique identifier for the workspace or organization. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def create_tag_for_workspace(client, workspace_gid: required("workspace_gid"), options: {}, **data) path = "/workspaces/{workspace_gid}/tags" path["{workspace_gid}"] = workspace_gid Tag.new(parse(client.post(path, body: data, options: options)).first, client: client) end # Delete a tag # # tag_gid - [str] (required) Globally unique identifier for the tag. # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def delete_tag(client, tag_gid: required("tag_gid"), options: {}) path = "/tags/{tag_gid}" path["{tag_gid}"] = tag_gid parse(client.delete(path, options: options)).first end # Get a tag # # tag_gid - [str] (required) Globally unique identifier for the tag. # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_tag(client, tag_gid: required("tag_gid"), options: {}) path = "/tags/{tag_gid}" path["{tag_gid}"] = tag_gid Tag.new(parse(client.get(path, options: options)).first, client: client) end # Get multiple tags # # workspace - [str] The workspace to filter tags on. # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_tags(client, workspace: nil, options: {}) path = "/tags" params = { workspace: workspace }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get(path, params: params, options: options)), type: Tag, client: client) end # Get a task's tags # # task_gid - [str] (required) The task to operate on. # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_tags_for_task(client, task_gid: required("task_gid"), options: {}) path = "/tasks/{task_gid}/tags" path["{task_gid}"] = task_gid Collection.new(parse(client.get(path, options: options)), type: Tag, client: client) end # Get tags in a workspace # # workspace_gid - [str] (required) Globally unique identifier for the workspace or organization. # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_tags_for_workspace(client, workspace_gid: required("workspace_gid"), options: {}) path = "/workspaces/{workspace_gid}/tags" path["{workspace_gid}"] = workspace_gid Collection.new(parse(client.get(path, options: options)), type: Tag, client: client) end # Update a tag # # tag_gid - [str] (required) Globally unique identifier for the tag. # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to PUT def update_tag(client, tag_gid: required("tag_gid"), options: {}, **data) path = "/tags/{tag_gid}" path["{tag_gid}"] = tag_gid Tag.new(parse(client.put(path, body: data, options: options)).first, client: client) end end end end end asana-0.10.3/lib/asana/resources/gen/project_memberships_base.rb0000644000175100017510000000730714002345121023702 0ustar pravipravi### WARNING: This file is auto-generated by our OpenAPI spec. Do not ### edit it manually. require_relative '../../resource_includes/response_helper' module Asana module Resources class ProjectMembershipsBase < Resource def self.inherited(base) Registry.register(base) end class << self # Get a project membership # # project_membership_gid - [str] (required) # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_project_membership(client, project_membership_gid: required("project_membership_gid"), options: {}) path = "/project_memberships/{project_membership_gid}" path["{project_membership_gid}"] = project_membership_gid ProjectMembership.new(parse(client.get(path, options: options)).first, client: client) end # Get memberships from a project # # project_gid - [str] (required) Globally unique identifier for the project. # user - [str] A string identifying a user. This can either be the string \"me\", an email, or the gid of a user. # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_project_memberships_for_project(client, project_gid: required("project_gid"), user: nil, options: {}) path = "/projects/{project_gid}/project_memberships" path["{project_gid}"] = project_gid params = { user: user }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get(path, params: params, options: options)), type: ProjectMembership, client: client) end end end end end asana-0.10.3/lib/asana/resources/gen/stories_base.rb0000644000175100017510000001713414002345121021325 0ustar pravipravi### WARNING: This file is auto-generated by our OpenAPI spec. Do not ### edit it manually. require_relative '../../resource_includes/response_helper' module Asana module Resources class StoriesBase < Resource def self.inherited(base) Registry.register(base) end class << self # Create a story on a task # # task_gid - [str] (required) The task to operate on. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def create_story_for_task(client, task_gid: required("task_gid"), options: {}, **data) path = "/tasks/{task_gid}/stories" path["{task_gid}"] = task_gid Story.new(parse(client.post(path, body: data, options: options)).first, client: client) end # Delete a story # # story_gid - [str] (required) Globally unique identifier for the story. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def delete_story(client, story_gid: required("story_gid"), options: {}) path = "/stories/{story_gid}" path["{story_gid}"] = story_gid parse(client.delete(path, options: options)).first end # Get stories from a task # # task_gid - [str] (required) The task to operate on. # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_stories_for_task(client, task_gid: required("task_gid"), options: {}) path = "/tasks/{task_gid}/stories" path["{task_gid}"] = task_gid Collection.new(parse(client.get(path, options: options)), type: Story, client: client) end # Get a story # # story_gid - [str] (required) Globally unique identifier for the story. # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_story(client, story_gid: required("story_gid"), options: {}) path = "/stories/{story_gid}" path["{story_gid}"] = story_gid Story.new(parse(client.get(path, options: options)).first, client: client) end # Update a story # # story_gid - [str] (required) Globally unique identifier for the story. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to PUT def update_story(client, story_gid: required("story_gid"), options: {}, **data) path = "/stories/{story_gid}" path["{story_gid}"] = story_gid Story.new(parse(client.put(path, body: data, options: options)).first, client: client) end end end end end asana-0.10.3/lib/asana/resources/gen/typeahead_base.rb0000644000175100017510000000525514002345121021602 0ustar pravipravi### WARNING: This file is auto-generated by our OpenAPI spec. Do not ### edit it manually. require_relative '../../resource_includes/response_helper' module Asana module Resources class TypeaheadBase < Resource def self.inherited(base) Registry.register(base) end class << self # Get objects via typeahead # # workspace_gid - [str] (required) Globally unique identifier for the workspace or organization. # resource_type - [str] (required) The type of values the typeahead should return. You can choose from one of the following: `custom_field`, `project`, `portfolio`, `tag`, `task`, and `user`. Note that unlike in the names of endpoints, the types listed here are in singular form (e.g. `task`). Using multiple types is not yet supported. # type - [str] *Deprecated: new integrations should prefer the resource_type field.* # query - [str] The string that will be used to search for relevant objects. If an empty string is passed in, the API will currently return an empty result set. # count - [int] The number of results to return. The default is 20 if this parameter is omitted, with a minimum of 1 and a maximum of 100. If there are fewer results found than requested, all will be returned. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def typeahead_for_workspace(client, workspace_gid: required("workspace_gid"), resource_type: nil, type: nil, query: nil, count: nil, options: {}) path = "/workspaces/{workspace_gid}/typeahead" path["{workspace_gid}"] = workspace_gid params = { resource_type: resource_type, type: type, query: query, count: count }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get(path, params: params, options: options)), type: Resource, client: client) end end end end end asana-0.10.3/lib/asana/resources/gen/organization_exports_base.rb0000644000175100017510000000665214002345121024130 0ustar pravipravi### WARNING: This file is auto-generated by our OpenAPI spec. Do not ### edit it manually. require_relative '../../resource_includes/response_helper' module Asana module Resources class OrganizationExportsBase < Resource def self.inherited(base) Registry.register(base) end class << self # Create an organization export request # # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def create_organization_export(client, options: {}, **data) path = "/organization_exports" OrganizationExport.new(parse(client.post(path, body: data, options: options)).first, client: client) end # Get details on an org export request # # organization_export_gid - [str] (required) Globally unique identifier for the organization export. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_organization_export(client, organization_export_gid: required("organization_export_gid"), options: {}) path = "/organization_exports/{organization_export_gid}" path["{organization_export_gid}"] = organization_export_gid OrganizationExport.new(parse(client.get(path, options: options)).first, client: client) end end end end end asana-0.10.3/lib/asana/resources/gen/jobs_base.rb0000644000175100017510000000305014002345121020562 0ustar pravipravi### WARNING: This file is auto-generated by our OpenAPI spec. Do not ### edit it manually. require_relative '../../resource_includes/response_helper' module Asana module Resources class JobsBase < Resource def self.inherited(base) Registry.register(base) end class << self # Get a job by id # # job_gid - [str] (required) Globally unique identifier for the job. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_job(client, job_gid: required("job_gid"), options: {}) path = "/jobs/{job_gid}" path["{job_gid}"] = job_gid Job.new(parse(client.get(path, options: options)).first, client: client) end end end end end asana-0.10.3/lib/asana/resources/gen/portfolio_memberships_base.rb0000644000175100017510000001345514002345121024252 0ustar pravipravi### WARNING: This file is auto-generated by our OpenAPI spec. Do not ### edit it manually. require_relative '../../resource_includes/response_helper' module Asana module Resources class PortfolioMembershipsBase < Resource def self.inherited(base) Registry.register(base) end class << self # Get a portfolio membership # # portfolio_membership_gid - [str] (required) # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_portfolio_membership(client, portfolio_membership_gid: required("portfolio_membership_gid"), options: {}) path = "/portfolio_memberships/{portfolio_membership_gid}" path["{portfolio_membership_gid}"] = portfolio_membership_gid PortfolioMembership.new(parse(client.get(path, options: options)).first, client: client) end # Get multiple portfolio memberships # # portfolio - [str] The portfolio to filter results on. # workspace - [str] The workspace to filter results on. # user - [str] A string identifying a user. This can either be the string \"me\", an email, or the gid of a user. # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_portfolio_memberships(client, portfolio: nil, workspace: nil, user: nil, options: {}) path = "/portfolio_memberships" params = { portfolio: portfolio, workspace: workspace, user: user }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get(path, params: params, options: options)), type: PortfolioMembership, client: client) end # Get memberships from a portfolio # # portfolio_gid - [str] (required) Globally unique identifier for the portfolio. # user - [str] A string identifying a user. This can either be the string \"me\", an email, or the gid of a user. # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_portfolio_memberships_for_portfolio(client, portfolio_gid: required("portfolio_gid"), user: nil, options: {}) path = "/portfolios/{portfolio_gid}/portfolio_memberships" path["{portfolio_gid}"] = portfolio_gid params = { user: user }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get(path, params: params, options: options)), type: PortfolioMembership, client: client) end end end end end asana-0.10.3/lib/asana/resources/gen/projects_base.rb0000644000175100017510000006355214002345121021473 0ustar pravipravi### WARNING: This file is auto-generated by our OpenAPI spec. Do not ### edit it manually. require_relative '../../resource_includes/response_helper' module Asana module Resources class ProjectsBase < Resource def self.inherited(base) Registry.register(base) end class << self # Add a custom field to a project # # project_gid - [str] (required) Globally unique identifier for the project. # options - [Hash] the request I/O options # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def add_custom_field_setting_for_project(client, project_gid: required("project_gid"), options: {}, **data) path = "/projects/{project_gid}/addCustomFieldSetting" path["{project_gid}"] = project_gid CustomFieldSetting.new(parse(client.post(path, body: data, options: options)).first, client: client) end # Add followers to a project # # project_gid - [str] (required) Globally unique identifier for the project. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def add_followers_for_project(client, project_gid: required("project_gid"), options: {}, **data) path = "/projects/{project_gid}/addFollowers" path["{project_gid}"] = project_gid parse(client.post(path, body: data, options: options)).first end # Add users to a project # # project_gid - [str] (required) Globally unique identifier for the project. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def add_members_for_project(client, project_gid: required("project_gid"), options: {}, **data) path = "/projects/{project_gid}/addMembers" path["{project_gid}"] = project_gid parse(client.post(path, body: data, options: options)).first end # Create a project # # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def create_project(client, options: {}, **data) path = "/projects" Project.new(parse(client.post(path, body: data, options: options)).first, client: client) end # Create a project in a team # # team_gid - [str] (required) Globally unique identifier for the team. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def create_project_for_team(client, team_gid: required("team_gid"), options: {}, **data) path = "/teams/{team_gid}/projects" path["{team_gid}"] = team_gid Project.new(parse(client.post(path, body: data, options: options)).first, client: client) end # Create a project in a workspace # # workspace_gid - [str] (required) Globally unique identifier for the workspace or organization. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def create_project_for_workspace(client, workspace_gid: required("workspace_gid"), options: {}, **data) path = "/workspaces/{workspace_gid}/projects" path["{workspace_gid}"] = workspace_gid Project.new(parse(client.post(path, body: data, options: options)).first, client: client) end # Delete a project # # project_gid - [str] (required) Globally unique identifier for the project. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def delete_project(client, project_gid: required("project_gid"), options: {}) path = "/projects/{project_gid}" path["{project_gid}"] = project_gid parse(client.delete(path, options: options)).first end # Duplicate a project # # project_gid - [str] (required) Globally unique identifier for the project. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def duplicate_project(client, project_gid: required("project_gid"), options: {}, **data) path = "/projects/{project_gid}/duplicate" path["{project_gid}"] = project_gid Job.new(parse(client.post(path, body: data, options: options)).first, client: client) end # Get a project # # project_gid - [str] (required) Globally unique identifier for the project. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_project(client, project_gid: required("project_gid"), options: {}) path = "/projects/{project_gid}" path["{project_gid}"] = project_gid Project.new(parse(client.get(path, options: options)).first, client: client) end # Get multiple projects # # workspace - [str] The workspace or organization to filter projects on. # team - [str] The team to filter projects on. # archived - [bool] Only return projects whose `archived` field takes on the value of this parameter. # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_projects(client, workspace: nil, team: nil, archived: nil, options: {}) path = "/projects" params = { workspace: workspace, team: team, archived: archived }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get(path, params: params, options: options)), type: Project, client: client) end # Get projects a task is in # # task_gid - [str] (required) The task to operate on. # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_projects_for_task(client, task_gid: required("task_gid"), options: {}) path = "/tasks/{task_gid}/projects" path["{task_gid}"] = task_gid Collection.new(parse(client.get(path, options: options)), type: Project, client: client) end # Get a team's projects # # team_gid - [str] (required) Globally unique identifier for the team. # archived - [bool] Only return projects whose `archived` field takes on the value of this parameter. # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_projects_for_team(client, team_gid: required("team_gid"), archived: nil, options: {}) path = "/teams/{team_gid}/projects" path["{team_gid}"] = team_gid params = { archived: archived }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get(path, params: params, options: options)), type: Project, client: client) end # Get all projects in a workspace # # workspace_gid - [str] (required) Globally unique identifier for the workspace or organization. # archived - [bool] Only return projects whose `archived` field takes on the value of this parameter. # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_projects_for_workspace(client, workspace_gid: required("workspace_gid"), archived: nil, options: {}) path = "/workspaces/{workspace_gid}/projects" path["{workspace_gid}"] = workspace_gid params = { archived: archived }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get(path, params: params, options: options)), type: Project, client: client) end # Get task count of a project # # project_gid - [str] (required) Globally unique identifier for the project. # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_task_counts_for_project(client, project_gid: required("project_gid"), options: {}) path = "/projects/{project_gid}/task_counts" path["{project_gid}"] = project_gid parse(client.get(path, options: options)).first end # Remove a custom field from a project # # project_gid - [str] (required) Globally unique identifier for the project. # options - [Hash] the request I/O options # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def remove_custom_field_setting_for_project(client, project_gid: required("project_gid"), options: {}, **data) path = "/projects/{project_gid}/removeCustomFieldSetting" path["{project_gid}"] = project_gid parse(client.post(path, body: data, options: options)).first end # Remove followers from a project # # project_gid - [str] (required) Globally unique identifier for the project. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def remove_followers_for_project(client, project_gid: required("project_gid"), options: {}, **data) path = "/projects/{project_gid}/removeFollowers" path["{project_gid}"] = project_gid parse(client.post(path, body: data, options: options)).first end # Remove users from a project # # project_gid - [str] (required) Globally unique identifier for the project. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def remove_members_for_project(client, project_gid: required("project_gid"), options: {}, **data) path = "/projects/{project_gid}/removeMembers" path["{project_gid}"] = project_gid parse(client.post(path, body: data, options: options)).first end # Update a project # # project_gid - [str] (required) Globally unique identifier for the project. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to PUT def update_project(client, project_gid: required("project_gid"), options: {}, **data) path = "/projects/{project_gid}" path["{project_gid}"] = project_gid Project.new(parse(client.put(path, body: data, options: options)).first, client: client) end end end end end asana-0.10.3/lib/asana/resources/gen/custom_fields_base.rb0000644000175100017510000003053514002345121022475 0ustar pravipravi### WARNING: This file is auto-generated by our OpenAPI spec. Do not ### edit it manually. require_relative '../../resource_includes/response_helper' module Asana module Resources class CustomFieldsBase < Resource def self.inherited(base) Registry.register(base) end class << self # Create a custom field # # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def create_custom_field(client, options: {}, **data) path = "/custom_fields" CustomField.new(parse(client.post(path, body: data, options: options)).first, client: client) end # Create an enum option # # custom_field_gid - [str] (required) Globally unique identifier for the custom field. # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def create_enum_option_for_custom_field(client, custom_field_gid: required("custom_field_gid"), options: {}, **data) path = "/custom_fields/{custom_field_gid}/enum_options" path["{custom_field_gid}"] = custom_field_gid parse(client.post(path, body: data, options: options)).first end # Delete a custom field # # custom_field_gid - [str] (required) Globally unique identifier for the custom field. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def delete_custom_field(client, custom_field_gid: required("custom_field_gid"), options: {}) path = "/custom_fields/{custom_field_gid}" path["{custom_field_gid}"] = custom_field_gid parse(client.delete(path, options: options)).first end # Get a custom field # # custom_field_gid - [str] (required) Globally unique identifier for the custom field. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_custom_field(client, custom_field_gid: required("custom_field_gid"), options: {}) path = "/custom_fields/{custom_field_gid}" path["{custom_field_gid}"] = custom_field_gid CustomField.new(parse(client.get(path, options: options)).first, client: client) end # Get a workspace's custom fields # # workspace_gid - [str] (required) Globally unique identifier for the workspace or organization. # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_custom_fields_for_workspace(client, workspace_gid: required("workspace_gid"), options: {}) path = "/workspaces/{workspace_gid}/custom_fields" path["{workspace_gid}"] = workspace_gid Collection.new(parse(client.get(path, options: options)), type: CustomField, client: client) end # Reorder a custom field's enum # # custom_field_gid - [str] (required) Globally unique identifier for the custom field. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def insert_enum_option_for_custom_field(client, custom_field_gid: required("custom_field_gid"), options: {}, **data) path = "/custom_fields/{custom_field_gid}/enum_options/insert" path["{custom_field_gid}"] = custom_field_gid parse(client.post(path, body: data, options: options)).first end # Update a custom field # # custom_field_gid - [str] (required) Globally unique identifier for the custom field. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to PUT def update_custom_field(client, custom_field_gid: required("custom_field_gid"), options: {}, **data) path = "/custom_fields/{custom_field_gid}" path["{custom_field_gid}"] = custom_field_gid CustomField.new(parse(client.put(path, body: data, options: options)).first, client: client) end # Update an enum option # # enum_option_gid - [str] (required) Globally unique identifier for the enum option. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to PUT def update_enum_option(client, enum_option_gid: required("enum_option_gid"), options: {}, **data) path = "/enum_options/{enum_option_gid}" path["{enum_option_gid}"] = enum_option_gid parse(client.put(path, body: data, options: options)).first end end end end end asana-0.10.3/lib/asana/resources/gen/batch_api_base.rb0000644000175100017510000000277514002345121021554 0ustar pravipravi### WARNING: This file is auto-generated by our OpenAPI spec. Do not ### edit it manually. require_relative '../../resource_includes/response_helper' module Asana module Resources class BatchAPIBase < Resource def self.inherited(base) Registry.register(base) end class << self # Submit parallel requests # # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def create_batch_request(client, options: {}, **data) path = "/batch" Collection.new(parse(client.post(path, body: data, options: options)), type: Resource, client: client) end end end end end asana-0.10.3/lib/asana/resources/gen/workspaces_base.rb0000644000175100017510000001651214002345121022015 0ustar pravipravi### WARNING: This file is auto-generated by our OpenAPI spec. Do not ### edit it manually. require_relative '../../resource_includes/response_helper' module Asana module Resources class WorkspacesBase < Resource def self.inherited(base) Registry.register(base) end class << self # Add a user to a workspace or organization # # workspace_gid - [str] (required) Globally unique identifier for the workspace or organization. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def add_user_for_workspace(client, workspace_gid: required("workspace_gid"), options: {}, **data) path = "/workspaces/{workspace_gid}/addUser" path["{workspace_gid}"] = workspace_gid User.new(parse(client.post(path, body: data, options: options)).first, client: client) end # Get a workspace # # workspace_gid - [str] (required) Globally unique identifier for the workspace or organization. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_workspace(client, workspace_gid: required("workspace_gid"), options: {}) path = "/workspaces/{workspace_gid}" path["{workspace_gid}"] = workspace_gid Workspace.new(parse(client.get(path, options: options)).first, client: client) end # Get multiple workspaces # # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_workspaces(client, options: {}) path = "/workspaces" Collection.new(parse(client.get(path, options: options)), type: Workspace, client: client) end # Remove a user from a workspace or organization # # workspace_gid - [str] (required) Globally unique identifier for the workspace or organization. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def remove_user_for_workspace(client, workspace_gid: required("workspace_gid"), options: {}, **data) path = "/workspaces/{workspace_gid}/removeUser" path["{workspace_gid}"] = workspace_gid parse(client.post(path, body: data, options: options)).first end # Update a workspace # # workspace_gid - [str] (required) Globally unique identifier for the workspace or organization. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to PUT def update_workspace(client, workspace_gid: required("workspace_gid"), options: {}, **data) path = "/workspaces/{workspace_gid}" path["{workspace_gid}"] = workspace_gid Workspace.new(parse(client.put(path, body: data, options: options)).first, client: client) end end end end end asana-0.10.3/lib/asana/resources/gen/portfolios_base.rb0000644000175100017510000004026514002345121022036 0ustar pravipravi### WARNING: This file is auto-generated by our OpenAPI spec. Do not ### edit it manually. require_relative '../../resource_includes/response_helper' module Asana module Resources class PortfoliosBase < Resource def self.inherited(base) Registry.register(base) end class << self # Add a custom field to a portfolio # # portfolio_gid - [str] (required) Globally unique identifier for the portfolio. # options - [Hash] the request I/O options # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def add_custom_field_setting_for_portfolio(client, portfolio_gid: required("portfolio_gid"), options: {}, **data) path = "/portfolios/{portfolio_gid}/addCustomFieldSetting" path["{portfolio_gid}"] = portfolio_gid parse(client.post(path, body: data, options: options)).first end # Add a portfolio item # # portfolio_gid - [str] (required) Globally unique identifier for the portfolio. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def add_item_for_portfolio(client, portfolio_gid: required("portfolio_gid"), options: {}, **data) path = "/portfolios/{portfolio_gid}/addItem" path["{portfolio_gid}"] = portfolio_gid parse(client.post(path, body: data, options: options)).first end # Add users to a portfolio # # portfolio_gid - [str] (required) Globally unique identifier for the portfolio. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def add_members_for_portfolio(client, portfolio_gid: required("portfolio_gid"), options: {}, **data) path = "/portfolios/{portfolio_gid}/addMembers" path["{portfolio_gid}"] = portfolio_gid parse(client.post(path, body: data, options: options)).first end # Create a portfolio # # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def create_portfolio(client, options: {}, **data) path = "/portfolios" Portfolio.new(parse(client.post(path, body: data, options: options)).first, client: client) end # Delete a portfolio # # portfolio_gid - [str] (required) Globally unique identifier for the portfolio. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def delete_portfolio(client, portfolio_gid: required("portfolio_gid"), options: {}) path = "/portfolios/{portfolio_gid}" path["{portfolio_gid}"] = portfolio_gid parse(client.delete(path, options: options)).first end # Get portfolio items # # portfolio_gid - [str] (required) Globally unique identifier for the portfolio. # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_items_for_portfolio(client, portfolio_gid: required("portfolio_gid"), options: {}) path = "/portfolios/{portfolio_gid}/items" path["{portfolio_gid}"] = portfolio_gid Collection.new(parse(client.get(path, options: options)), type: Project, client: client) end # Get a portfolio # # portfolio_gid - [str] (required) Globally unique identifier for the portfolio. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_portfolio(client, portfolio_gid: required("portfolio_gid"), options: {}) path = "/portfolios/{portfolio_gid}" path["{portfolio_gid}"] = portfolio_gid Portfolio.new(parse(client.get(path, options: options)).first, client: client) end # Get multiple portfolios # # workspace - [str] (required) The workspace or organization to filter portfolios on. # owner - [str] (required) The user who owns the portfolio. Currently, API users can only get a list of portfolios that they themselves own. # options - [Hash] the request I/O options # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100. # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. def get_portfolios(client, workspace: nil, owner: nil, options: {}) path = "/portfolios" params = { workspace: workspace, owner: owner }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get(path, params: params, options: options)), type: Portfolio, client: client) end # Remove a custom field from a portfolio # # portfolio_gid - [str] (required) Globally unique identifier for the portfolio. # options - [Hash] the request I/O options # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def remove_custom_field_setting_for_portfolio(client, portfolio_gid: required("portfolio_gid"), options: {}, **data) path = "/portfolios/{portfolio_gid}/removeCustomFieldSetting" path["{portfolio_gid}"] = portfolio_gid parse(client.post(path, body: data, options: options)).first end # Remove a portfolio item # # portfolio_gid - [str] (required) Globally unique identifier for the portfolio. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def remove_item_for_portfolio(client, portfolio_gid: required("portfolio_gid"), options: {}, **data) path = "/portfolios/{portfolio_gid}/removeItem" path["{portfolio_gid}"] = portfolio_gid parse(client.post(path, body: data, options: options)).first end # Remove users from a portfolio # # portfolio_gid - [str] (required) Globally unique identifier for the portfolio. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to POST def remove_members_for_portfolio(client, portfolio_gid: required("portfolio_gid"), options: {}, **data) path = "/portfolios/{portfolio_gid}/removeMembers" path["{portfolio_gid}"] = portfolio_gid parse(client.post(path, body: data, options: options)).first end # Update a portfolio # # portfolio_gid - [str] (required) Globally unique identifier for the portfolio. # options - [Hash] the request I/O options # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options. # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging. # data - [Hash] the attributes to PUT def update_portfolio(client, portfolio_gid: required("portfolio_gid"), options: {}, **data) path = "/portfolios/{portfolio_gid}" path["{portfolio_gid}"] = portfolio_gid Portfolio.new(parse(client.put(path, body: data, options: options)).first, client: client) end end end end end asana-0.10.3/lib/asana/resources/portfolio.rb0000644000175100017510000002234214002345121020104 0ustar pravipravirequire_relative 'gen/portfolios_base' module Asana module Resources # A _portfolio_ gives a high-level overview of the status of multiple # initiatives in Asana. Portfolios provide a dashboard overview of the state # of multiple items, including a progress report and the most recent # [project status](/developers/api-reference/project_statuses) update. # # Portfolios have some restrictions on size. Each portfolio has a maximum of 250 # items and, like projects, a maximum of 20 custom fields. class Portfolio < PortfoliosBase attr_reader :gid attr_reader :resource_type attr_reader :name attr_reader :owner attr_reader :created_at attr_reader :created_by attr_reader :custom_field_settings attr_reader :color attr_reader :workspace attr_reader :members class << self # Returns the plural name of the resource. def plural_name 'portfolios' end # Creates a new portfolio in the given workspace with the supplied name. # # Note that portfolios created in the Asana UI may have some state # (like the "Priority" custom field) which is automatically added to the # portfolio when it is created. Portfolios created via our API will **not** # be created with the same initial state to allow integrations to create # their own starting state on a portfolio. # # workspace - [Gid] The workspace or organization in which to create the portfolio. # name - [String] The name of the newly-created portfolio # color - [String] An optional color for the portfolio # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def create(client, workspace: required("workspace"), name: required("name"), color: nil, options: {}, **data) with_params = data.merge(workspace: workspace, name: name, color: color).reject { |_,v| v.nil? || Array(v).empty? } self.new(parse(client.post("/portfolios", body: with_params, options: options)).first, client: client) end # Returns the complete record for a single portfolio. # # id - [Gid] The portfolio to get. # options - [Hash] the request I/O options. def find_by_id(client, id, options: {}) self.new(parse(client.get("/portfolios/#{id}", options: options)).first, client: client) end # Returns a list of the portfolios in compact representation that are owned # by the current API user. # # workspace - [Gid] The workspace or organization to filter portfolios on. # owner - [String] The user who owns the portfolio. Currently, API users can only get a # list of portfolios that they themselves own. # # per_page - [Integer] the number of records to fetch per page. # options - [Hash] the request I/O options. def find_all(client, workspace: required("workspace"), owner: required("owner"), per_page: 20, options: {}) params = { workspace: workspace, owner: owner, limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/portfolios", params: params, options: options)), type: self, client: client) end end # An existing portfolio can be updated by making a PUT request on the # URL for that portfolio. Only the fields provided in the `data` block will be # updated; any unspecified fields will remain unchanged. # # Returns the complete updated portfolio record. # # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def update(options: {}, **data) refresh_with(parse(client.put("/portfolios/#{gid}", body: data, options: options)).first) end # An existing portfolio can be deleted by making a DELETE request # on the URL for that portfolio. # # Returns an empty data record. def delete() client.delete("/portfolios/#{gid}") && true end # Get a list of the items in compact form in a portfolio. # # options - [Hash] the request I/O options. def get_items(options: {}) Collection.new(parse(client.get("/portfolios/#{gid}/items", options: options)), type: self, client: client) end # Add an item to a portfolio. # # Returns an empty data block. # # item - [Gid] The item to add to the portfolio. # insert_before - [Gid] An id of an item in this portfolio. The new item will be added before the one specified here. # `insert_before` and `insert_after` parameters cannot both be specified. # # insert_after - [Gid] An id of an item in this portfolio. The new item will be added after the one specified here. # `insert_before` and `insert_after` parameters cannot both be specified. # # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def add_item(item: required("item"), insert_before: nil, insert_after: nil, options: {}, **data) with_params = data.merge(item: item, insert_before: insert_before, insert_after: insert_after).reject { |_,v| v.nil? || Array(v).empty? } client.post("/portfolios/#{gid}/addItem", body: with_params, options: options) && true end # Remove an item to a portfolio. # # Returns an empty data block. # # item - [Gid] The item to remove from the portfolio. # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def remove_item(item: required("item"), options: {}, **data) with_params = data.merge(item: item).reject { |_,v| v.nil? || Array(v).empty? } client.post("/portfolios/#{gid}/removeItem", body: with_params, options: options) && true end # Adds the specified list of users as members of the portfolio. Returns the updated portfolio record. # # members - [Array] An array of user ids. # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def add_members(members: required("members"), options: {}, **data) with_params = data.merge(members: members).reject { |_,v| v.nil? || Array(v).empty? } refresh_with(parse(client.post("/portfolios/#{gid}/addMembers", body: with_params, options: options)).first) end # Removes the specified list of members from the portfolio. Returns the updated portfolio record. # # members - [Array] An array of user ids. # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def remove_members(members: required("members"), options: {}, **data) with_params = data.merge(members: members).reject { |_,v| v.nil? || Array(v).empty? } refresh_with(parse(client.post("/portfolios/#{gid}/removeMembers", body: with_params, options: options)).first) end # Get the custom field settings on a portfolio. # # options - [Hash] the request I/O options. def custom_field_settings(options: {}) Collection.new(parse(client.get("/portfolios/#{gid}/custom_field_settings", options: options)), type: self, client: client) end # Create a new custom field setting on the portfolio. Returns the full # record for the new custom field setting. # # custom_field - [Gid] The id of the custom field to add to the portfolio. # is_important - [Boolean] Whether this field should be considered important to this portfolio (for instance, to display in the list view of items in the portfolio). # # insert_before - [Gid] An id of a custom field setting on this portfolio. The new custom field setting will be added before this one. # `insert_before` and `insert_after` parameters cannot both be specified. # # insert_after - [Gid] An id of a custom field setting on this portfolio. The new custom field setting will be added after this one. # `insert_before` and `insert_after` parameters cannot both be specified. # # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def add_custom_field_setting(custom_field: required("custom_field"), is_important: nil, insert_before: nil, insert_after: nil, options: {}, **data) with_params = data.merge(custom_field: custom_field, is_important: is_important, insert_before: insert_before, insert_after: insert_after).reject { |_,v| v.nil? || Array(v).empty? } Resource.new(parse(client.post("/portfolios/#{gid}/addCustomFieldSetting", body: with_params, options: options)).first, client: client) end # Remove a custom field setting on the portfolio. Returns an empty data # block. # # custom_field - [Gid] The id of the custom field to remove from this portfolio. # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def remove_custom_field_setting(custom_field: required("custom_field"), options: {}, **data) with_params = data.merge(custom_field: custom_field).reject { |_,v| v.nil? || Array(v).empty? } client.post("/portfolios/#{gid}/removeCustomFieldSetting", body: with_params, options: options) && true end end end end asana-0.10.3/lib/asana/resources/events.rb0000644000175100017510000000066214002345121017374 0ustar pravipravirequire_relative 'gen/events_base' module Asana module Resources class EventResponse < EventsBase attr_reader :user attr_reader :resource attr_reader :type attr_reader :action attr_reader :parent attr_reader :created_at class << self # Returns the plural name of the resource. def plural_name 'event_responses' end end end end end asana-0.10.3/lib/asana/resources/user_task_list.rb0000644000175100017510000000752414002345121021127 0ustar pravipravirequire_relative 'gen/user_task_lists_base' module Asana module Resources # A _user task list_ represents the tasks assigned to a particular user. It provides API access to a user's "My Tasks" view in Asana. # # A user's "My Tasks" represent all of the tasks assigned to that user. It is # visually divided into regions based on the task's # [`assignee_status`](/developers/api-reference/tasks#field-assignee_status) # for Asana users to triage their tasks based on when they can address them. # When building an integration it's worth noting that tasks with due dates will # automatically move through `assignee_status` states as their due dates # approach; read up on [task # auto-promotion](/guide/help/fundamentals/my-tasks#gl-auto-promote) for more # infomation. class UserTaskList < UserTaskListsBase attr_reader :gid attr_reader :resource_type attr_reader :name attr_reader :owner attr_reader :workspace class << self # Returns the plural name of the resource. def plural_name 'user_task_lists' end # Returns the full record for the user task list for the given user # # user - [String] An identifier for the user. Can be one of an email address, # the globally unique identifier for the user, or the keyword `me` # to indicate the current user making the request. # # workspace - [Gid] Globally unique identifier for the workspace or organization. # # options - [Hash] the request I/O options. def find_by_user(client, user: required("user"), workspace: required("workspace"), options: {}) params = { workspace: workspace }.reject { |_,v| v.nil? || Array(v).empty? } Resource.new(parse(client.get("/users/#{user}/user_task_list", params: params, options: options)).first, client: client) end # Returns the full record for a user task list. # # id - [Gid] Globally unique identifier for the user task list. # # options - [Hash] the request I/O options. def find_by_id(client, id, options: {}) self.new(parse(client.get("/user_task_lists/#{id}", options: options)).first, client: client) end end # Returns the compact list of tasks in a user's My Tasks list. The returned # tasks will be in order within each assignee status group of `Inbox`, # `Today`, and `Upcoming`. # # **Note:** tasks in `Later` have a different ordering in the Asana web app # than the other assignee status groups; this endpoint will still return # them in list order in `Later` (differently than they show up in Asana, # but the same order as in Asana's mobile apps). # # **Note:** Access control is enforced for this endpoint as with all Asana # API endpoints, meaning a user's private tasks will be filtered out if the # API-authenticated user does not have access to them. # # **Note:** Both complete and incomplete tasks are returned by default # unless they are filtered out (for example, setting `completed_since=now` # will return only incomplete tasks, which is the default view for "My # Tasks" in Asana.) # # completed_since - [String] Only return tasks that are either incomplete or that have been # completed since this time. # # per_page - [Integer] the number of records to fetch per page. # options - [Hash] the request I/O options. def tasks(completed_since: nil, per_page: 20, options: {}) params = { completed_since: completed_since, limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/user_task_lists/#{gid}/tasks", params: params, options: options)), type: Task, client: client) end end end end asana-0.10.3/lib/asana/resources/attachment.rb0000644000175100017510000000316614002345121020222 0ustar pravipravirequire_relative 'gen/attachments_base' module Asana module Resources # An _attachment_ object represents any file attached to a task in Asana, # whether it's an uploaded file or one associated via a third-party service # such as Dropbox or Google Drive. class Attachment < AttachmentsBase attr_reader :gid attr_reader :resource_type attr_reader :created_at attr_reader :download_url attr_reader :host attr_reader :name attr_reader :parent attr_reader :view_url class << self # Returns the plural name of the resource. def plural_name 'attachments' end # Returns the full record for a single attachment. # # id - [Gid] Globally unique identifier for the attachment. # # options - [Hash] the request I/O options. def find_by_id(client, id, options: {}) self.new(parse(client.get("/attachments/#{id}", options: options)).first, client: client) end # Returns the compact records for all attachments on the task. # # task - [Gid] Globally unique identifier for the task. # # per_page - [Integer] the number of records to fetch per page. # options - [Hash] the request I/O options. def find_by_task(client, task: required("task"), per_page: 20, options: {}) params = { limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/tasks/#{task}/attachments", params: params, options: options)), type: self, client: client) end end end end end asana-0.10.3/lib/asana/resources/section.rb0000644000175100017510000001312314002345121017530 0ustar pravipravirequire_relative 'gen/sections_base' module Asana module Resources # A _section_ is a subdivision of a project that groups tasks together. It can # either be a header above a list of tasks in a list view or a column in a # board view of a project. class Section < SectionsBase attr_reader :gid attr_reader :resource_type attr_reader :name attr_reader :project attr_reader :created_at class << self # Returns the plural name of the resource. def plural_name 'sections' end # Creates a new section in a project. # # Returns the full record of the newly created section. # # project - [Gid] The project to create the section in # name - [String] The text to be displayed as the section name. This cannot be an empty string. # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def create_in_project(client, project: required("project"), name: required("name"), options: {}, **data) with_params = data.merge(name: name).reject { |_,v| v.nil? || Array(v).empty? } self.new(parse(client.post("/projects/#{project}/sections", body: with_params, options: options)).first, client: client) end # Returns the compact records for all sections in the specified project. # # project - [Gid] The project to get sections from. # per_page - [Integer] the number of records to fetch per page. # options - [Hash] the request I/O options. def find_by_project(client, project: required("project"), per_page: 20, options: {}) params = { limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/projects/#{project}/sections", params: params, options: options)), type: self, client: client) end # Returns the complete record for a single section. # # id - [Gid] The section to get. # options - [Hash] the request I/O options. def find_by_id(client, id, options: {}) self.new(parse(client.get("/sections/#{gid}", options: options)).first, client: client) end end # A specific, existing section can be updated by making a PUT request on # the URL for that project. Only the fields provided in the `data` block # will be updated; any unspecified fields will remain unchanged. (note that # at this time, the only field that can be updated is the `name` field.) # # When using this method, it is best to specify only those fields you wish # to change, or else you may overwrite changes made by another user since # you last retrieved the task. # # Returns the complete updated section record. # # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def update(options: {}, **data) refresh_with(parse(client.put("/sections/#{gid}", body: data, options: options)).first) end # A specific, existing section can be deleted by making a DELETE request # on the URL for that section. # # Note that sections must be empty to be deleted. # # The last remaining section in a board view cannot be deleted. # # Returns an empty data block. def delete() client.delete("/sections/#{gid}") && true end # Add a task to a specific, existing section. This will remove the task from other sections of the project. # # The task will be inserted at the top of a section unless an `insert_before` or `insert_after` parameter is declared. # # This does not work for separators (tasks with the `resource_subtype` of section). # # insert_before - [Gid] Insert the given task immediately before the task specified by this parameter. Cannot be provided together with `insert_after`. # insert_after - [Gid] Insert the given task immediately after the task specified by this parameter. Cannot be provided together with `insert_before`. # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def add_task(insert_before: nil, insert_after: nil, options: {}, **data) with_params = data.merge(insert_before: insert_before, insert_after: insert_after).reject { |_,v| v.nil? || Array(v).empty? } Task.new(parse(client.post("/sections/#{gid}/addTask", body: with_params, options: options)).first, client: client) end # Move sections relative to each other in a board view. One of # `before_section` or `after_section` is required. # # Sections cannot be moved between projects. # # At this point in time, moving sections is not supported in list views, only board views. # # Returns an empty data block. # # project - [Gid] The project in which to reorder the given section # before_section - [Gid] Insert the given section immediately before the section specified by this parameter. # after_section - [Gid] Insert the given section immediately after the section specified by this parameter. # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def insert_in_project(project: required("project"), before_section: nil, after_section: nil, options: {}, **data) with_params = data.merge(before_section: before_section, after_section: after_section).reject { |_,v| v.nil? || Array(v).empty? } client.post("/projects/#{project}/sections/insert", body: with_params, options: options) && true end end end end asana-0.10.3/lib/asana/resources/user.rb0000644000175100017510000000711514002345121017046 0ustar pravipravirequire_relative 'gen/users_base' module Asana module Resources # A _user_ object represents an account in Asana that can be given access to # various workspaces, projects, and tasks. # # Like other objects in the system, users are referred to by numerical IDs. # However, the special string identifier `me` can be used anywhere # a user ID is accepted, to refer to the current authenticated user. class User < UsersBase attr_reader :gid attr_reader :resource_type attr_reader :name attr_reader :email attr_reader :photo attr_reader :workspaces class << self # Returns the plural name of the resource. def plural_name 'users' end # Returns the full user record for the currently authenticated user. # # options - [Hash] the request I/O options. def me(client, options: {}) Resource.new(parse(client.get("/users/me", options: options)).first, client: client) end # Returns the full user record for the single user with the provided ID. # # id - [String] An identifier for the user. Can be one of an email address, # the globally unique identifier for the user, or the keyword `me` # to indicate the current user making the request. # # options - [Hash] the request I/O options. def find_by_id(client, id, options: {}) self.new(parse(client.get("/users/#{id}", options: options)).first, client: client) end # Returns the user records for all users in the specified workspace or # organization. # # workspace - [Id] The workspace in which to get users. # per_page - [Integer] the number of records to fetch per page. # options - [Hash] the request I/O options. def find_by_workspace(client, workspace: required("workspace"), per_page: 20, options: {}) params = { limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/workspaces/#{workspace}/users", params: params, options: options)), type: self, client: client) end # Returns the user records for all users in all workspaces and organizations # accessible to the authenticated user. Accepts an optional workspace ID # parameter. # # workspace - [Id] The workspace or organization to filter users on. # per_page - [Integer] the number of records to fetch per page. # options - [Hash] the request I/O options. def find_all(client, workspace: nil, per_page: 20, options: {}) params = { workspace: workspace, limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/users", params: params, options: options)), type: self, client: client) end end # Returns all of a user's favorites in the given workspace, of the given type. # Results are given in order (The same order as Asana's sidebar). # # workspace - [Id] The workspace in which to get favorites. # resource_type - [Enum] The resource type of favorites to be returned. # options - [Hash] the request I/O options. def get_user_favorites(workspace: required("workspace"), resource_type: required("resource_type"), options: {}) params = { workspace: workspace, resource_type: resource_type }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/users/#{gid}/favorites", params: params, options: options)), type: Resource, client: client) end end end end asana-0.10.3/lib/asana/resources/tag.rb0000644000175100017510000001326214002345121016643 0ustar pravipravirequire_relative 'gen/tags_base' module Asana module Resources # A _tag_ is a label that can be attached to any task in Asana. It exists in a # single workspace or organization. # # Tags have some metadata associated with them, but it is possible that we will # simplify them in the future so it is not encouraged to rely too heavily on it. # Unlike projects, tags do not provide any ordering on the tasks they # are associated with. class Tag < TagsBase attr_reader :gid attr_reader :resource_type attr_reader :created_at attr_reader :followers attr_reader :name attr_reader :color attr_reader :workspace class << self # Returns the plural name of the resource. def plural_name 'tags' end # Creates a new tag in a workspace or organization. # # Every tag is required to be created in a specific workspace or # organization, and this cannot be changed once set. Note that you can use # the `workspace` parameter regardless of whether or not it is an # organization. # # Returns the full record of the newly created tag. # # workspace - [Gid] The workspace or organization to create the tag in. # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def create(client, workspace: required("workspace"), options: {}, **data) with_params = data.merge(workspace: workspace).reject { |_,v| v.nil? || Array(v).empty? } self.new(parse(client.post("/tags", body: with_params, options: options)).first, client: client) end # Creates a new tag in a workspace or organization. # # Every tag is required to be created in a specific workspace or # organization, and this cannot be changed once set. Note that you can use # the `workspace` parameter regardless of whether or not it is an # organization. # # Returns the full record of the newly created tag. # # workspace - [Gid] The workspace or organization to create the tag in. # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def create_in_workspace(client, workspace: required("workspace"), options: {}, **data) self.new(parse(client.post("/workspaces/#{workspace}/tags", body: data, options: options)).first, client: client) end # Returns the complete tag record for a single tag. # # id - [Gid] The tag to get. # options - [Hash] the request I/O options. def find_by_id(client, id, options: {}) self.new(parse(client.get("/tags/#{id}", options: options)).first, client: client) end # Returns the compact tag records for some filtered set of tags. # Use one or more of the parameters provided to filter the tags returned. # # workspace - [Gid] The workspace or organization to filter tags on. # team - [Gid] The team to filter tags on. # archived - [Boolean] Only return tags whose `archived` field takes on the value of # this parameter. # # per_page - [Integer] the number of records to fetch per page. # options - [Hash] the request I/O options. def find_all(client, workspace: nil, team: nil, archived: nil, per_page: 20, options: {}) params = { workspace: workspace, team: team, archived: archived, limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/tags", params: params, options: options)), type: self, client: client) end # Returns the compact tag records for all tags in the workspace. # # workspace - [Gid] The workspace or organization to find tags in. # per_page - [Integer] the number of records to fetch per page. # options - [Hash] the request I/O options. def find_by_workspace(client, workspace: required("workspace"), per_page: 20, options: {}) params = { limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/workspaces/#{workspace}/tags", params: params, options: options)), type: self, client: client) end end # Updates the properties of a tag. Only the fields provided in the `data` # block will be updated; any unspecified fields will remain unchanged. # # When using this method, it is best to specify only those fields you wish # to change, or else you may overwrite changes made by another user since # you last retrieved the task. # # Returns the complete updated tag record. # # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def update(options: {}, **data) refresh_with(parse(client.put("/tags/#{gid}", body: data, options: options)).first) end # A specific, existing tag can be deleted by making a DELETE request # on the URL for that tag. # # Returns an empty data record. def delete() client.delete("/tags/#{gid}") && true end # Returns the compact task records for all tasks with the given tag. # Tasks can have more than one tag at a time. # # per_page - [Integer] the number of records to fetch per page. # options - [Hash] the request I/O options. def get_tasks_with_tag(per_page: 20, options: {}) params = { limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/tags/#{gid}/tasks", params: params, options: options)), type: Task, client: client) end end end end asana-0.10.3/lib/asana/resources/project.rb0000644000175100017510000003452714002345121017545 0ustar pravipravirequire_relative 'gen/projects_base' module Asana module Resources # A _project_ represents a prioritized list of tasks in Asana or a board with # columns of tasks represented as cards. It exists in a single workspace or # organization and is accessible to a subset of users in that workspace or # organization, depending on its permissions. # # Projects in organizations are shared with a single team. You cannot currently # change the team of a project via the API. Non-organization workspaces do not # have teams and so you should not specify the team of project in a regular # workspace. class Project < ProjectsBase include EventSubscription attr_reader :gid attr_reader :resource_type attr_reader :name attr_reader :owner attr_reader :current_status attr_reader :due_date attr_reader :due_on attr_reader :start_on attr_reader :created_at attr_reader :modified_at attr_reader :archived attr_reader :public attr_reader :members attr_reader :followers attr_reader :custom_fields attr_reader :custom_field_settings attr_reader :color attr_reader :notes attr_reader :html_notes attr_reader :workspace attr_reader :team attr_reader :layout class << self # Returns the plural name of the resource. def plural_name 'projects' end # Creates a new project in a workspace or team. # # Every project is required to be created in a specific workspace or # organization, and this cannot be changed once set. Note that you can use # the `workspace` parameter regardless of whether or not it is an # organization. # # If the workspace for your project _is_ an organization, you must also # supply a `team` to share the project with. # # Returns the full record of the newly created project. # # workspace - [Gid] The workspace or organization to create the project in. # team - [Gid] If creating in an organization, the specific team to create the # project in. # # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def create(client, workspace: required("workspace"), team: nil, options: {}, **data) with_params = data.merge(workspace: workspace, team: team).reject { |_,v| v.nil? || Array(v).empty? } self.new(parse(client.post("/projects", body: with_params, options: options)).first, client: client) end # If the workspace for your project _is_ an organization, you must also # supply a `team` to share the project with. # # Returns the full record of the newly created project. # # workspace - [Gid] The workspace or organization to create the project in. # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def create_in_workspace(client, workspace: required("workspace"), options: {}, **data) self.new(parse(client.post("/workspaces/#{workspace}/projects", body: data, options: options)).first, client: client) end # Creates a project shared with the given team. # # Returns the full record of the newly created project. # # team - [Gid] The team to create the project in. # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def create_in_team(client, team: required("team"), options: {}, **data) self.new(parse(client.post("/teams/#{team}/projects", body: data, options: options)).first, client: client) end # Returns the complete project record for a single project. # # id - [Gid] The project to get. # options - [Hash] the request I/O options. def find_by_id(client, id, options: {}) self.new(parse(client.get("/projects/#{id}", options: options)).first, client: client) end # Returns the compact project records for some filtered set of projects. # Use one or more of the parameters provided to filter the projects returned. # # workspace - [Gid] The workspace or organization to filter projects on. # team - [Gid] The team to filter projects on. # is_template - [Boolean] **Note: This parameter can only be included if a team is also defined, or the workspace is not an organization** # Filters results to include only template projects. # # archived - [Boolean] Only return projects whose `archived` field takes on the value of # this parameter. # # per_page - [Integer] the number of records to fetch per page. # options - [Hash] the request I/O options. def find_all(client, workspace: nil, team: nil, is_template: nil, archived: nil, per_page: 20, options: {}) params = { workspace: workspace, team: team, is_template: is_template, archived: archived, limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/projects", params: params, options: options)), type: self, client: client) end # Returns the compact project records for all projects in the workspace. # # workspace - [Gid] The workspace or organization to find projects in. # is_template - [Boolean] **Note: This parameter can only be included if a team is also defined, or the workspace is not an organization** # Filters results to include only template projects. # # archived - [Boolean] Only return projects whose `archived` field takes on the value of # this parameter. # # per_page - [Integer] the number of records to fetch per page. # options - [Hash] the request I/O options. def find_by_workspace(client, workspace: required("workspace"), is_template: nil, archived: nil, per_page: 20, options: {}) params = { is_template: is_template, archived: archived, limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/workspaces/#{workspace}/projects", params: params, options: options)), type: self, client: client) end # Returns the compact project records for all projects in the team. # # team - [Gid] The team to find projects in. # is_template - [Boolean] Filters results to include only template projects. # # archived - [Boolean] Only return projects whose `archived` field takes on the value of # this parameter. # # per_page - [Integer] the number of records to fetch per page. # options - [Hash] the request I/O options. def find_by_team(client, team: required("team"), is_template: nil, archived: nil, per_page: 20, options: {}) params = { is_template: is_template, archived: archived, limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/teams/#{team}/projects", params: params, options: options)), type: self, client: client) end end # A specific, existing project can be updated by making a PUT request on the # URL for that project. Only the fields provided in the `data` block will be # updated; any unspecified fields will remain unchanged. # # When using this method, it is best to specify only those fields you wish # to change, or else you may overwrite changes made by another user since # you last retrieved the task. # # Returns the complete updated project record. # # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def update(options: {}, **data) refresh_with(parse(client.put("/projects/#{gid}", body: data, options: options)).first) end # A specific, existing project can be deleted by making a DELETE request # on the URL for that project. # # Returns an empty data record. def delete() client.delete("/projects/#{gid}") && true end # Creates and returns a job that will asynchronously handle the duplication. # # name - [String] The name of the new project. # team - [Gid] Sets the team of the new project. If team is not defined, the new project # will be in the same team as the the original project. # # include - [Array] The elements that will be duplicated to the new project. # Tasks are always included. # # schedule_dates - [String] A dictionary of options to auto-shift dates. # `task_dates` must be included to use this option. # Requires either `start_on` or `due_on`, but not both. # `start_on` will set the first start date of the new # project to the given date, while `due_on` will set the last due date # to the given date. Both will offset the remaining dates by the same amount # of the original project. # # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def duplicate_project(name: required("name"), team: nil, include: nil, schedule_dates: nil, options: {}, **data) with_params = data.merge(name: name, team: team, include: include, schedule_dates: schedule_dates).reject { |_,v| v.nil? || Array(v).empty? } Resource.new(parse(client.post("/projects/#{gid}/duplicate", body: with_params, options: options)).first, client: client) end # Returns the compact task records for all tasks within the given project, # ordered by their priority within the project. Tasks can exist in more than one project at a time. # # per_page - [Integer] the number of records to fetch per page. # options - [Hash] the request I/O options. def tasks(per_page: 20, options: {}) params = { limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/projects/#{gid}/tasks", params: params, options: options)), type: Task, client: client) end # Adds the specified list of users as followers to the project. Followers are a subset of members, therefore if # the users are not already members of the project they will also become members as a result of this operation. # Returns the updated project record. # # followers - [Array] An array of followers to add to the project. # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def add_followers(followers: required("followers"), options: {}, **data) with_params = data.merge(followers: followers).reject { |_,v| v.nil? || Array(v).empty? } refresh_with(parse(client.post("/projects/#{gid}/addFollowers", body: with_params, options: options)).first) end # Removes the specified list of users from following the project, this will not affect project membership status. # Returns the updated project record. # # followers - [Array] An array of followers to remove from the project. # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def remove_followers(followers: required("followers"), options: {}, **data) with_params = data.merge(followers: followers).reject { |_,v| v.nil? || Array(v).empty? } refresh_with(parse(client.post("/projects/#{gid}/removeFollowers", body: with_params, options: options)).first) end # Adds the specified list of users as members of the project. Returns the updated project record. # # members - [Array] An array of user ids. # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def add_members(members: required("members"), options: {}, **data) with_params = data.merge(members: members).reject { |_,v| v.nil? || Array(v).empty? } refresh_with(parse(client.post("/projects/#{gid}/addMembers", body: with_params, options: options)).first) end # Removes the specified list of members from the project. Returns the updated project record. # # members - [Array] An array of user ids. # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def remove_members(members: required("members"), options: {}, **data) with_params = data.merge(members: members).reject { |_,v| v.nil? || Array(v).empty? } refresh_with(parse(client.post("/projects/#{gid}/removeMembers", body: with_params, options: options)).first) end # Create a new custom field setting on the project. # # custom_field - [Gid] The id of the custom field to associate with this project. # is_important - [Boolean] Whether this field should be considered important to this project. # # insert_before - [Gid] An id of a Custom Field Settings on this project, before which the new Custom Field Settings will be added. # `insert_before` and `insert_after` parameters cannot both be specified. # # insert_after - [Gid] An id of a Custom Field Settings on this project, after which the new Custom Field Settings will be added. # `insert_before` and `insert_after` parameters cannot both be specified. # # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def add_custom_field_setting(custom_field: required("custom_field"), is_important: nil, insert_before: nil, insert_after: nil, options: {}, **data) with_params = data.merge(custom_field: custom_field, is_important: is_important, insert_before: insert_before, insert_after: insert_after).reject { |_,v| v.nil? || Array(v).empty? } Resource.new(parse(client.post("/projects/#{gid}/addCustomFieldSetting", body: with_params, options: options)).first, client: client) end # Remove a custom field setting on the project. # # custom_field - [Gid] The id of the custom field to remove from this project. # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def remove_custom_field_setting(custom_field: nil, options: {}, **data) with_params = data.merge(custom_field: custom_field).reject { |_,v| v.nil? || Array(v).empty? } Resource.new(parse(client.post("/projects/#{gid}/removeCustomFieldSetting", body: with_params, options: options)).first, client: client) end end end end asana-0.10.3/lib/asana/resources/task.rb0000644000175100017510000006315614002345121017041 0ustar pravipravirequire_relative 'gen/tasks_base' module Asana module Resources # The _task_ is the basic object around which many operations in Asana are # centered. In the Asana application, multiple tasks populate the middle pane # according to some view parameters, and the set of selected tasks determines # the more detailed information presented in the details pane. class Task < TasksBase include AttachmentUploading include EventSubscription attr_reader :gid attr_reader :resource_type attr_reader :resource_subtype attr_reader :assignee attr_reader :assignee_status attr_reader :created_at attr_reader :completed attr_reader :completed_at attr_reader :custom_fields attr_reader :dependencies attr_reader :dependents attr_reader :due_on attr_reader :due_at attr_reader :external attr_reader :followers attr_reader :is_rendered_as_separator attr_reader :liked attr_reader :likes attr_reader :memberships attr_reader :modified_at attr_reader :name attr_reader :notes attr_reader :html_notes attr_reader :num_likes attr_reader :num_subtasks attr_reader :parent attr_reader :projects attr_reader :start_on attr_reader :workspace attr_reader :tags class << self # Returns the plural name of the resource. def plural_name 'tasks' end # Creating a new task is as easy as POSTing to the `/tasks` endpoint # with a data block containing the fields you'd like to set on the task. # Any unspecified fields will take on default values. # # Every task is required to be created in a specific workspace, and this # workspace cannot be changed once set. The workspace need not be set # explicitly if you specify `projects` or a `parent` task instead. # # `projects` can be a comma separated list of projects, or just a single # project the task should belong to. # # workspace - [Gid] The workspace to create a task in. # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def create(client, workspace: nil, options: {}, **data) with_params = data.merge(workspace: workspace).reject { |_,v| v.nil? || Array(v).empty? } self.new(parse(client.post("/tasks", body: with_params, options: options)).first, client: client) end # Creating a new task is as easy as POSTing to the `/tasks` endpoint # with a data block containing the fields you'd like to set on the task. # Any unspecified fields will take on default values. # # Every task is required to be created in a specific workspace, and this # workspace cannot be changed once set. The workspace need not be set # explicitly if you specify a `project` or a `parent` task instead. # # workspace - [Gid] The workspace to create a task in. # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def create_in_workspace(client, workspace: required("workspace"), options: {}, **data) self.new(parse(client.post("/workspaces/#{workspace}/tasks", body: data, options: options)).first, client: client) end # Returns the complete task record for a single task. # # id - [Gid] The task to get. # options - [Hash] the request I/O options. def find_by_id(client, id, options: {}) self.new(parse(client.get("/tasks/#{id}", options: options)).first, client: client) end # Returns the compact task records for all tasks within the given project, # ordered by their priority within the project. # # project - [Gid] The project in which to search for tasks. # per_page - [Integer] the number of records to fetch per page. # options - [Hash] the request I/O options. def find_by_project(client, project: nil, projectId: nil, per_page: 20, options: {}) params = { limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/projects/#{project != nil ? project : projectId}/tasks", params: params, options: options)), type: self, client: client) end # Returns the compact task records for all tasks with the given tag. # # tag - [Gid] The tag in which to search for tasks. # per_page - [Integer] the number of records to fetch per page. # options - [Hash] the request I/O options. def find_by_tag(client, tag: required("tag"), per_page: 20, options: {}) params = { limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/tags/#{tag}/tasks", params: params, options: options)), type: self, client: client) end # Board view only: Returns the compact section records for all tasks within the given section. # # section - [Gid] The section in which to search for tasks. # per_page - [Integer] the number of records to fetch per page. # options - [Hash] the request I/O options. def find_by_section(client, section: required("section"), per_page: 20, options: {}) params = { limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/sections/#{section}/tasks", params: params, options: options)), type: self, client: client) end # Returns the compact list of tasks in a user's My Tasks list. The returned # tasks will be in order within each assignee status group of `Inbox`, # `Today`, and `Upcoming`. # # **Note:** tasks in `Later` have a different ordering in the Asana web app # than the other assignee status groups; this endpoint will still return # them in list order in `Later` (differently than they show up in Asana, # but the same order as in Asana's mobile apps). # # **Note:** Access control is enforced for this endpoint as with all Asana # API endpoints, meaning a user's private tasks will be filtered out if the # API-authenticated user does not have access to them. # # **Note:** Both complete and incomplete tasks are returned by default # unless they are filtered out (for example, setting `completed_since=now` # will return only incomplete tasks, which is the default view for "My # Tasks" in Asana.) # # user_task_list - [Gid] The user task list in which to search for tasks. # completed_since - [String] Only return tasks that are either incomplete or that have been # completed since this time. # # per_page - [Integer] the number of records to fetch per page. # options - [Hash] the request I/O options. def find_by_user_task_list(client, user_task_list: required("user_task_list"), completed_since: nil, per_page: 20, options: {}) params = { completed_since: completed_since, limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/user_task_lists/#{user_task_list}/tasks", params: params, options: options)), type: self, client: client) end # Returns the compact task records for some filtered set of tasks. Use one # or more of the parameters provided to filter the tasks returned. You must # specify a `project`, `section`, `tag`, or `user_task_list` if you do not # specify `assignee` and `workspace`. # # assignee - [String] The assignee to filter tasks on. # workspace - [Gid] The workspace or organization to filter tasks on. # project - [Gid] The project to filter tasks on. # section - [Gid] The section to filter tasks on. # tag - [Gid] The tag to filter tasks on. # user_task_list - [Gid] The user task list to filter tasks on. # completed_since - [String] Only return tasks that are either incomplete or that have been # completed since this time. # # modified_since - [String] Only return tasks that have been modified since the given time. # # per_page - [Integer] the number of records to fetch per page. # options - [Hash] the request I/O options. # Notes: # # If you specify `assignee`, you must also specify the `workspace` to filter on. # # If you specify `workspace`, you must also specify the `assignee` to filter on. # # Currently, this is only supported in board views. # # A task is considered "modified" if any of its properties change, # or associations between it and other objects are modified (e.g. # a task being added to a project). A task is not considered modified # just because another object it is associated with (e.g. a subtask) # is modified. Actions that count as modifying the task include # assigning, renaming, completing, and adding stories. def find_all(client, assignee: nil, workspace: nil, project: nil, section: nil, tag: nil, user_task_list: nil, completed_since: nil, modified_since: nil, per_page: 20, options: {}) params = { assignee: assignee, workspace: workspace, project: project, section: section, tag: tag, user_task_list: user_task_list, completed_since: completed_since, modified_since: modified_since, limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/tasks", params: params, options: options)), type: self, client: client) end # The search endpoint allows you to build complex queries to find and fetch exactly the data you need from Asana. For a more comprehensive description of all the query parameters and limitations of this endpoint, see our [long-form documentation](/developers/documentation/getting-started/search-api) for this feature. # # workspace - [Gid] The workspace or organization in which to search for tasks. # resource_subtype - [Enum] Filters results by the task's resource_subtype. # # per_page - [Integer] the number of records to fetch per page. # options - [Hash] the request I/O options. def search_in_workspace(client, workspace: required("workspace"), resource_subtype: nil, per_page: 20, options: {}) params = { resource_subtype: resource_subtype, limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } if options[:params] params.merge!(options[:params]) end Collection.new(parse(client.get("/workspaces/#{workspace}/tasks/search", params: params, options: options)), type: Resource, client: client) end alias_method :search, :search_in_workspace end # A specific, existing task can be updated by making a PUT request on the # URL for that task. Only the fields provided in the `data` block will be # updated; any unspecified fields will remain unchanged. # # When using this method, it is best to specify only those fields you wish # to change, or else you may overwrite changes made by another user since # you last retrieved the task. # # Returns the complete updated task record. # # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def update(options: {}, **data) refresh_with(parse(client.put("/tasks/#{gid}", body: data, options: options)).first) end # A specific, existing task can be deleted by making a DELETE request on the # URL for that task. Deleted tasks go into the "trash" of the user making # the delete request. Tasks can be recovered from the trash within a period # of 30 days; afterward they are completely removed from the system. # # Returns an empty data record. def delete() client.delete("/tasks/#{gid}") && true end # Creates and returns a job that will asynchronously handle the duplication. # # name - [String] The name of the new task. # include - [Array] The fields that will be duplicated to the new task. # # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def duplicate_task(name: required("name"), include: nil, options: {}, **data) with_params = data.merge(name: name, include: include).reject { |_,v| v.nil? || Array(v).empty? } Resource.new(parse(client.post("/tasks/#{gid}/duplicate", body: with_params, options: options)).first, client: client) end # Returns the compact representations of all of the dependencies of a task. # # options - [Hash] the request I/O options. def dependencies(options: {}) Collection.new(parse(client.get("/tasks/#{gid}/dependencies", options: options)), type: self.class, client: client) end # Returns the compact representations of all of the dependents of a task. # # options - [Hash] the request I/O options. def dependents(options: {}) Collection.new(parse(client.get("/tasks/#{gid}/dependents", options: options)), type: self.class, client: client) end # Marks a set of tasks as dependencies of this task, if they are not # already dependencies. *A task can have at most 15 dependencies.* # # dependencies - [Array] An array of task IDs that this task should depend on. # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def add_dependencies(dependencies: required("dependencies"), options: {}, **data) with_params = data.merge(dependencies: dependencies).reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.post("/tasks/#{gid}/addDependencies", body: with_params, options: options)), type: self.class, client: client) end # Marks a set of tasks as dependents of this task, if they are not already # dependents. *A task can have at most 30 dependents.* # # dependents - [Array] An array of task IDs that should depend on this task. # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def add_dependents(dependents: required("dependents"), options: {}, **data) with_params = data.merge(dependents: dependents).reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.post("/tasks/#{gid}/addDependents", body: with_params, options: options)), type: self.class, client: client) end # Unlinks a set of dependencies from this task. # # dependencies - [Array] An array of task IDs to remove as dependencies. # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def remove_dependencies(dependencies: required("dependencies"), options: {}, **data) with_params = data.merge(dependencies: dependencies).reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.post("/tasks/#{gid}/removeDependencies", body: with_params, options: options)), type: self.class, client: client) end # Unlinks a set of dependents from this task. # # dependents - [Array] An array of task IDs to remove as dependents. # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def remove_dependents(dependents: required("dependents"), options: {}, **data) with_params = data.merge(dependents: dependents).reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.post("/tasks/#{gid}/removeDependents", body: with_params, options: options)), type: self.class, client: client) end # Adds each of the specified followers to the task, if they are not already # following. Returns the complete, updated record for the affected task. # # followers - [Array] An array of followers to add to the task. # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def add_followers(followers: required("followers"), options: {}, **data) with_params = data.merge(followers: followers).reject { |_,v| v.nil? || Array(v).empty? } refresh_with(parse(client.post("/tasks/#{gid}/addFollowers", body: with_params, options: options)).first) end # Removes each of the specified followers from the task if they are # following. Returns the complete, updated record for the affected task. # # followers - [Array] An array of followers to remove from the task. # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def remove_followers(followers: required("followers"), options: {}, **data) with_params = data.merge(followers: followers).reject { |_,v| v.nil? || Array(v).empty? } refresh_with(parse(client.post("/tasks/#{gid}/removeFollowers", body: with_params, options: options)).first) end # Returns a compact representation of all of the projects the task is in. # # per_page - [Integer] the number of records to fetch per page. # options - [Hash] the request I/O options. def projects(per_page: 20, options: {}) params = { limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/tasks/#{gid}/projects", params: params, options: options)), type: Project, client: client) end # Adds the task to the specified project, in the optional location # specified. If no location arguments are given, the task will be added to # the end of the project. # # `addProject` can also be used to reorder a task within a project or section that # already contains it. # # At most one of `insert_before`, `insert_after`, or `section` should be # specified. Inserting into a section in an non-order-dependent way can be # done by specifying `section`, otherwise, to insert within a section in a # particular place, specify `insert_before` or `insert_after` and a task # within the section to anchor the position of this task. # # Returns an empty data block. # # project - [Gid] The project to add the task to. # insert_after - [Gid] A task in the project to insert the task after, or `null` to # insert at the beginning of the list. # # insert_before - [Gid] A task in the project to insert the task before, or `null` to # insert at the end of the list. # # section - [Gid] A section in the project to insert the task into. The task will be # inserted at the bottom of the section. # # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def add_project(project: required("project"), insert_after: nil, insert_before: nil, section: nil, options: {}, **data) with_params = data.merge(project: project, insert_after: insert_after, insert_before: insert_before, section: section).reject { |_,v| v.nil? || Array(v).empty? } client.post("/tasks/#{gid}/addProject", body: with_params, options: options) && true end # Removes the task from the specified project. The task will still exist # in the system, but it will not be in the project anymore. # # Returns an empty data block. # # project - [Gid] The project to remove the task from. # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def remove_project(project: required("project"), options: {}, **data) with_params = data.merge(project: project).reject { |_,v| v.nil? || Array(v).empty? } client.post("/tasks/#{gid}/removeProject", body: with_params, options: options) && true end # Returns a compact representation of all of the tags the task has. # # per_page - [Integer] the number of records to fetch per page. # options - [Hash] the request I/O options. def tags(per_page: 20, options: {}) params = { limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/tasks/#{gid}/tags", params: params, options: options)), type: Tag, client: client) end # Adds a tag to a task. Returns an empty data block. # # tag - [Gid] The tag to add to the task. # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def add_tag(tag: required("tag"), options: {}, **data) with_params = data.merge(tag: tag).reject { |_,v| v.nil? || Array(v).empty? } client.post("/tasks/#{gid}/addTag", body: with_params, options: options) && true end # Removes a tag from the task. Returns an empty data block. # # tag - [Gid] The tag to remove from the task. # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def remove_tag(tag: required("tag"), options: {}, **data) with_params = data.merge(tag: tag).reject { |_,v| v.nil? || Array(v).empty? } client.post("/tasks/#{gid}/removeTag", body: with_params, options: options) && true end # Returns a compact representation of all of the subtasks of a task. # # per_page - [Integer] the number of records to fetch per page. # options - [Hash] the request I/O options. def subtasks(per_page: 20, options: {}) params = { limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/tasks/#{gid}/subtasks", params: params, options: options)), type: self.class, client: client) end # Creates a new subtask and adds it to the parent task. Returns the full record # for the newly created subtask. # # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def add_subtask(options: {}, **data) self.class.new(parse(client.post("/tasks/#{gid}/subtasks", body: data, options: options)).first, client: client) end # Changes the parent of a task. Each task may only be a subtask of a single # parent, or no parent task at all. Returns an empty data block. When using `insert_before` and `insert_after`, # at most one of those two options can be specified, and they must already be subtasks # of the parent. # # parent - [Gid] The new parent of the task, or `null` for no parent. # insert_after - [Gid] A subtask of the parent to insert the task after, or `null` to # insert at the beginning of the list. # # insert_before - [Gid] A subtask of the parent to insert the task before, or `null` to # insert at the end of the list. # # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def set_parent(parent: required("parent"), insert_after: nil, insert_before: nil, options: {}, **data) with_params = data.merge(parent: parent, insert_after: insert_after, insert_before: insert_before).reject { |_,v| v.nil? || Array(v).empty? } client.post("/tasks/#{gid}/setParent", body: with_params, options: options) && true end # Returns a compact representation of all of the stories on the task. # # per_page - [Integer] the number of records to fetch per page. # options - [Hash] the request I/O options. def stories(per_page: 20, options: {}) params = { limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/tasks/#{gid}/stories", params: params, options: options)), type: Story, client: client) end # Adds a comment to a task. The comment will be authored by the # currently authenticated user, and timestamped when the server receives # the request. # # Returns the full record for the new story added to the task. # # text - [String] The plain text of the comment to add. # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def add_comment(text: required("text"), options: {}, **data) with_params = data.merge(text: text).reject { |_,v| v.nil? || Array(v).empty? } Story.new(parse(client.post("/tasks/#{gid}/stories", body: with_params, options: options)).first, client: client) end # Insert or reorder tasks in a user's My Tasks list. If the task was not # assigned to the owner of the user task list it will be reassigned when # this endpoint is called. If neither `insert_before` nor `insert_after` # are provided the task will be inserted at the top of the assignee's # inbox. # # Returns an empty data block. # # user_task_list - [Gid] Globally unique identifier for the user task list. # # insert_before - [Gid] Insert the task before the task specified by this field. The inserted # task will inherit the `assignee_status` of this task. `insert_before` # and `insert_after` parameters cannot both be specified. # # insert_after - [Gid] Insert the task after the task specified by this field. The inserted # task will inherit the `assignee_status` of this task. `insert_before` # and `insert_after` parameters cannot both be specified. # # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def insert_in_user_task_list(user_task_list: required("user_task_list"), insert_before: nil, insert_after: nil, options: {}, **data) with_params = data.merge(insert_before: insert_before, insert_after: insert_after).reject { |_,v| v.nil? || Array(v).empty? } client.post("/user_task_lists/#{user_task_list}/tasks/insert", body: with_params, options: options) && true end end end end asana-0.10.3/lib/asana/resources/batch_api.rb0000644000175100017510000000041014002345121017771 0ustar pravipravirequire_relative 'gen/batch_api_base' module Asana module Resources class BatchAPI < BatchAPIBase class << self # Returns the plural name of the resource. def plural_name 'batch_apis' end end end end end asana-0.10.3/lib/asana/resources/custom_fields.rb0000644000175100017510000002306514002345121020732 0ustar pravipravirequire_relative 'gen/custom_fields_base' module Asana module Resources # Custom Fields store the metadata that is used in order to add user-specified # information to tasks in Asana. Be sure to reference the [Custom # Fields](/developers/documentation/getting-started/custom-fields) developer # documentation for more information about how custom fields relate to various # resources in Asana. # # Users in Asana can [lock custom # fields](/guide/help/premium/custom-fields#gl-lock-fields), which will make # them read-only when accessed by other users. Attempting to edit a locked # custom field will return HTTP error code `403 Forbidden`. class CustomField < CustomFieldsBase attr_reader :gid attr_reader :resource_type attr_reader :resource_subtype attr_reader :name attr_reader :description attr_reader :type attr_reader :enum_options attr_reader :precision class << self # Returns the plural name of the resource. def plural_name 'custom_fields' end # Creates a new custom field in a workspace. Every custom field is required to be created in a specific workspace, and this workspace cannot be changed once set. # # A custom field's `name` must be unique within a workspace and not conflict with names of existing task properties such as 'Due Date' or 'Assignee'. A custom field's `type` must be one of 'text', 'enum', or 'number'. # # Returns the full record of the newly created custom field. # # workspace - [Gid] The workspace to create a custom field in. # resource_subtype - [String] The type of the custom field. Must be one of the given values. # type - [String] **Deprecated: New integrations should prefer the `resource_subtype` parameter.** # name - [String] The name of the custom field. # description - [String] The description of the custom field. # precision - [Integer] The number of decimal places for the numerical values. Required if the custom field is of type 'number'. # enum_options - [String] The discrete values the custom field can assume. Required if the custom field is of type 'enum'. # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def create(client, workspace: required("workspace"), resource_subtype: nil, type: nil, name: required("name"), description: nil, precision: nil, enum_options: nil, options: {}, **data) with_params = data.merge(workspace: workspace, resource_subtype: resource_subtype || type, name: name, description: description, precision: precision, enum_options: enum_options).reject { |_,v| v.nil? || Array(v).empty? } Resource.new(parse(client.post("/custom_fields", body: with_params, options: options)).first, client: client) end # Returns the complete definition of a custom field's metadata. # # id - [Gid] Globally unique identifier for the custom field. # # options - [Hash] the request I/O options. def find_by_id(client, id, options: {}) self.new(parse(client.get("/custom_fields/#{id}", options: options)).first, client: client) end # Returns a list of the compact representation of all of the custom fields in a workspace. # # workspace - [Gid] The workspace or organization to find custom field definitions in. # per_page - [Integer] the number of records to fetch per page. # options - [Hash] the request I/O options. def find_by_workspace(client, workspace: required("workspace"), per_page: 20, options: {}) params = { limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/workspaces/#{workspace}/custom_fields", params: params, options: options)), type: Resource, client: client) end # Creates an enum option and adds it to this custom field's list of enum options. A custom field can have at most 50 enum options (including disabled options). By default new enum options are inserted at the end of a custom field's list. # # Locked custom fields can only have enum options added by the user who locked the field. # # Returns the full record of the newly created enum option. # # custom_field - [Gid] Globally unique identifier for the custom field. # # name - [String] The name of the enum option. # color - [String] The color of the enum option. Defaults to 'none'. # insert_before - [Gid] An existing enum option within this custom field before which the new enum option should be inserted. Cannot be provided together with after_enum_option. # insert_after - [Gid] An existing enum option within this custom field after which the new enum option should be inserted. Cannot be provided together with before_enum_option. # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def create_enum_option(client, custom_field: required("custom_field"), name: required("name"), color: nil, insert_before: nil, insert_after: nil, options: {}, **data) with_params = data.merge(name: name, color: color, insert_before: insert_before, insert_after: insert_after).reject { |_,v| v.nil? || Array(v).empty? } Resource.new(parse(client.post("/custom_fields/#{custom_field}/enum_options", body: with_params, options: options)).first, client: client) end alias_method :add_enum_option, :create_enum_option # Moves a particular enum option to be either before or after another specified enum option in the custom field. # # Locked custom fields can only be reordered by the user who locked the field. # # custom_field - [Gid] Globally unique identifier for the custom field. # # enum_option - [Gid] The ID of the enum option to relocate. # name - [String] The name of the enum option. # color - [String] The color of the enum option. Defaults to 'none'. # before_enum_option - [Gid] An existing enum option within this custom field before which the new enum option should be inserted. Cannot be provided together with after_enum_option. # after_enum_option - [Gid] An existing enum option within this custom field after which the new enum option should be inserted. Cannot be provided together with before_enum_option. # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def insert_enum_option(client, custom_field: required("custom_field"), enum_option: required("enum_option"), name: required("name"), color: nil, before_enum_option: nil, after_enum_option: nil, options: {}, **data) with_params = data.merge(enum_option: enum_option, name: name, color: color, before_enum_option: before_enum_option, after_enum_option: after_enum_option).reject { |_,v| v.nil? || Array(v).empty? } Resource.new(parse(client.post("/custom_fields/#{custom_field}/enum_options/insert", body: with_params, options: options)).first, client: client) end alias_method :reorder_enum_option, :insert_enum_option end # A specific, existing custom field can be updated by making a PUT request on the URL for that custom field. Only the fields provided in the `data` block will be updated; any unspecified fields will remain unchanged # # When using this method, it is best to specify only those fields you wish to change, or else you may overwrite changes made by another user since you last retrieved the custom field. # # An enum custom field's `enum_options` cannot be updated with this endpoint. Instead see "Work With Enum Options" for information on how to update `enum_options`. # # Locked custom fields can only be updated by the user who locked the field. # # Returns the complete updated custom field record. # # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def update(options: {}, **data) refresh_with(parse(client.put("/custom_fields/#{gid}", body: data, options: options)).first) end # A specific, existing custom field can be deleted by making a DELETE request on the URL for that custom field. # # Locked custom fields can only be deleted by the user who locked the field. # # Returns an empty data record. def delete() client.delete("/custom_fields/#{gid}") && true end # Updates an existing enum option. Enum custom fields require at least one enabled enum option. # # Locked custom fields can only be updated by the user who locked the field. # # Returns the full record of the updated enum option. # # enum_option - [Gid] Globally unique identifier for the enum option. # # name - [String] The name of the enum option. # color - [String] The color of the enum option. Defaults to 'none'. # enabled - [Boolean] Whether or not the enum option is a selectable value for the custom field. # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def update_enum_option(enum_option: required("enum_option"), name: required("name"), color: nil, enabled: nil, options: {}, **data) with_params = data.merge(name: name, color: color, enabled: enabled).reject { |_,v| v.nil? || Array(v).empty? } refresh_with(parse(client.put("/enum_options/#{enum_option}", body: with_params, options: options)).first) end end end end asana-0.10.3/lib/asana/resources/workspace.rb0000644000175100017510000001360714002345121020071 0ustar pravipravirequire_relative 'gen/workspaces_base' module Asana module Resources # A _workspace_ is the highest-level organizational unit in Asana. All projects # and tasks have an associated workspace. # # An _organization_ is a special kind of workspace that represents a company. # In an organization, you can group your projects into teams. You can read # more about how organizations work on the Asana Guide. # To tell if your workspace is an organization or not, check its # `is_organization` property. # # Over time, we intend to migrate most workspaces into organizations and to # release more organization-specific functionality. We may eventually deprecate # using workspace-based APIs for organizations. Currently, and until after # some reasonable grace period following any further announcements, you can # still reference organizations in any `workspace` parameter. class Workspace < WorkspacesBase attr_reader :gid attr_reader :resource_type attr_reader :name attr_reader :is_organization class << self # Returns the plural name of the resource. def plural_name 'workspaces' end # Returns the full workspace record for a single workspace. # # id - [Id] Globally unique identifier for the workspace or organization. # # options - [Hash] the request I/O options. def find_by_id(client, id, options: {}) self.new(parse(client.get("/workspaces/#{id}", options: options)).first, client: client) end # Returns the compact records for all workspaces visible to the authorized user. # # per_page - [Integer] the number of records to fetch per page. # options - [Hash] the request I/O options. def find_all(client, per_page: 20, options: {}) params = { limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/workspaces", params: params, options: options)), type: self, client: client) end end # A specific, existing workspace can be updated by making a PUT request on # the URL for that workspace. Only the fields provided in the data block # will be updated; any unspecified fields will remain unchanged. # # Currently the only field that can be modified for a workspace is its `name`. # # Returns the complete, updated workspace record. # # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def update(options: {}, **data) refresh_with(parse(client.put("/workspaces/#{gid}", body: data, options: options)).first) end # Retrieves objects in the workspace based on an auto-completion/typeahead # search algorithm. This feature is meant to provide results quickly, so do # not rely on this API to provide extremely accurate search results. The # result set is limited to a single page of results with a maximum size, # so you won't be able to fetch large numbers of results. # # resource_type - [Enum] The type of values the typeahead should return. You can choose from # one of the following: custom_field, project, tag, task, and user. # Note that unlike in the names of endpoints, the types listed here are # in singular form (e.g. `task`). Using multiple types is not yet supported. # # type - [Enum] **Deprecated: new integrations should prefer the resource_type field.** # # query - [String] The string that will be used to search for relevant objects. If an # empty string is passed in, the API will currently return an empty # result set. # # count - [Number] The number of results to return. The default is `20` if this # parameter is omitted, with a minimum of `1` and a maximum of `100`. # If there are fewer results found than requested, all will be returned. # # per_page - [Integer] the number of records to fetch per page. # options - [Hash] the request I/O options. def typeahead(resource_type: nil, type: nil, query: nil, count: nil, per_page: 20, options: {}) params = { resource_type: resource_type || type, query: query, count: count, limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/workspaces/#{gid}/typeahead", params: params, options: options)), type: Resource, client: client) end # The user can be referenced by their globally unique user ID or their email address. # Returns the full user record for the invited user. # # user - [String] An identifier for the user. Can be one of an email address, # the globally unique identifier for the user, or the keyword `me` # to indicate the current user making the request. # # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def add_user(user: required("user"), options: {}, **data) with_params = data.merge(user: user).reject { |_,v| v.nil? || Array(v).empty? } User.new(parse(client.post("/workspaces/#{gid}/addUser", body: with_params, options: options)).first, client: client) end # The user making this call must be an admin in the workspace. # Returns an empty data record. # # user - [String] An identifier for the user. Can be one of an email address, # the globally unique identifier for the user, or the keyword `me` # to indicate the current user making the request. # # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def remove_user(user: required("user"), options: {}, **data) with_params = data.merge(user: user).reject { |_,v| v.nil? || Array(v).empty? } client.post("/workspaces/#{gid}/removeUser", body: with_params, options: options) && true end end end end asana-0.10.3/lib/asana/resources/portfolio_membership.rb0000644000175100017510000000471314002345121022321 0ustar pravipravirequire_relative 'gen/portfolio_memberships_base' module Asana module Resources # This object determines if a user is a member of a portfolio. class PortfolioMembership < PortfolioMembershipsBase attr_reader :gid attr_reader :resource_type attr_reader :user attr_reader :portfolio class << self # Returns the plural name of the resource. def plural_name 'portfolio_memberships' end # Returns the compact portfolio membership records for the portfolio. You must # specify `portfolio`, `portfolio` and `user`, or `workspace` and `user`. # # portfolio - [Gid] The portfolio for which to fetch memberships. # workspace - [Gid] The workspace for which to fetch memberships. # user - [String] The user to filter the memberships to. # per_page - [Integer] the number of records to fetch per page. # options - [Hash] the request I/O options. def find_all(client, portfolio: nil, workspace: nil, user: nil, per_page: 20, options: {}) params = { portfolio: portfolio, workspace: workspace, user: user, limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/portfolio_memberships", params: params, options: options)), type: Resource, client: client) end # Returns the compact portfolio membership records for the portfolio. # # portfolio - [Gid] The portfolio for which to fetch memberships. # user - [String] If present, the user to filter the memberships to. # per_page - [Integer] the number of records to fetch per page. # options - [Hash] the request I/O options. def find_by_portfolio(client, portfolio: required("portfolio"), user: nil, per_page: 20, options: {}) params = { user: user, limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/portfolios/#{portfolio}/portfolio_memberships", params: params, options: options)), type: Resource, client: client) end # Returns the portfolio membership record. # # id - [Gid] Globally unique identifier for the portfolio membership. # # options - [Hash] the request I/O options. def find_by_id(client, id, options: {}) self.new(parse(client.get("/portfolio_memberships/#{id}", options: options)).first, client: client) end end end end end asana-0.10.3/lib/asana/resources/project_membership.rb0000644000175100017510000000362714002345121021755 0ustar pravipravirequire_relative 'gen/project_memberships_base' module Asana module Resources # With the introduction of "comment-only" projects in Asana, a user's membership # in a project comes with associated permissions. These permissions (whether a # user has full access to the project or comment-only access) are accessible # through the project memberships endpoints described here. class ProjectMembership < ProjectMembershipsBase attr_reader :gid attr_reader :resource_type attr_reader :user attr_reader :project attr_reader :write_access class << self # Returns the plural name of the resource. def plural_name 'project_memberships' end # Returns the compact project membership records for the project. # # project - [Gid] The project for which to fetch memberships. # user - [String] If present, the user to filter the memberships to. # per_page - [Integer] the number of records to fetch per page. # options - [Hash] the request I/O options. def find_by_project(client, project: required("project"), user: nil, per_page: 20, options: {}) params = { user: user, limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/projects/#{project}/project_memberships", params: params, options: options)), type: Resource, client: client) end alias_method :get_many, :find_by_project # Returns the project membership record. # # id - [Gid] Globally unique identifier for the project membership. # # options - [Hash] the request I/O options. def find_by_id(client, id, options: {}) self.new(parse(client.get("/project_memberships/#{id}", options: options)).first, client: client) end alias_method :get_single, :find_by_id end end end end asana-0.10.3/lib/asana/resources/team.rb0000644000175100017510000001113014002345121017006 0ustar pravipravirequire_relative 'gen/teams_base' module Asana module Resources # A _team_ is used to group related projects and people together within an # organization. Each project in an organization is associated with a team. class Team < TeamsBase attr_reader :gid attr_reader :resource_type attr_reader :name attr_reader :description attr_reader :html_description attr_reader :organization class << self # Returns the plural name of the resource. def plural_name 'teams' end # Returns the full record for a single team. # # id - [Id] Globally unique identifier for the team. # # options - [Hash] the request I/O options. def find_by_id(client, id, options: {}) self.new(parse(client.get("/teams/#{id}", options: options)).first, client: client) end # Returns the compact records for all teams in the organization visible to # the authorized user. # # organization - [Id] Globally unique identifier for the workspace or organization. # # per_page - [Integer] the number of records to fetch per page. # options - [Hash] the request I/O options. def find_by_organization(client, organization: required("organization"), per_page: 20, options: {}) params = { limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/organizations/#{organization}/teams", params: params, options: options)), type: self, client: client) end # Returns the compact records for all teams to which user is assigned. # # user - [String] An identifier for the user. Can be one of an email address, # the globally unique identifier for the user, or the keyword `me` # to indicate the current user making the request. # # organization - [Id] The workspace or organization to filter teams on. # per_page - [Integer] the number of records to fetch per page. # options - [Hash] the request I/O options. def find_by_user(client, user: required("user"), organization: nil, per_page: 20, options: {}) params = { organization: organization, limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/users/#{user}/teams", params: params, options: options)), type: self, client: client) end end # Returns the compact records for all users that are members of the team. # # per_page - [Integer] the number of records to fetch per page. # options - [Hash] the request I/O options. def users(per_page: 20, options: {}) params = { limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/teams/#{gid}/users", params: params, options: options)), type: User, client: client) end # The user making this call must be a member of the team in order to add others. # The user to add must exist in the same organization as the team in order to be added. # The user to add can be referenced by their globally unique user ID or their email address. # Returns the full user record for the added user. # # user - [String] An identifier for the user. Can be one of an email address, # the globally unique identifier for the user, or the keyword `me` # to indicate the current user making the request. # # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def add_user(user: required("user"), options: {}, **data) with_params = data.merge(user: user).reject { |_,v| v.nil? || Array(v).empty? } User.new(parse(client.post("/teams/#{gid}/addUser", body: with_params, options: options)).first, client: client) end # The user to remove can be referenced by their globally unique user ID or their email address. # Removes the user from the specified team. Returns an empty data record. # # user - [String] An identifier for the user. Can be one of an email address, # the globally unique identifier for the user, or the keyword `me` # to indicate the current user making the request. # # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def remove_user(user: required("user"), options: {}, **data) with_params = data.merge(user: user).reject { |_,v| v.nil? || Array(v).empty? } client.post("/teams/#{gid}/removeUser", body: with_params, options: options) && true end end end end asana-0.10.3/lib/asana/resources/typeahead.rb0000644000175100017510000000053614002345121020034 0ustar pravipravirequire_relative 'gen/typeahead_base' module Asana module Resources class Typeahead < TypeaheadBase attr_reader :gid attr_reader :resource_type attr_reader :name class << self # Returns the plural name of the resource. def plural_name 'typeaheads' end end end end end asana-0.10.3/lib/asana/resources/project_status.rb0000644000175100017510000000610614002345121021140 0ustar pravipravirequire_relative 'gen/project_statuses_base' module Asana module Resources # A _project status_ is an update on the progress of a particular project, and is sent out to all project # followers when created. These updates include both text describing the update and a color code intended to # represent the overall state of the project: "green" for projects that are on track, "yellow" for projects # at risk, and "red" for projects that are behind. # # Project statuses can be created and deleted, but not modified. class ProjectStatus < ProjectStatusesBase attr_reader :gid attr_reader :resource_type attr_reader :title attr_reader :text attr_reader :html_text attr_reader :color attr_reader :created_by attr_reader :created_at class << self # Returns the plural name of the resource. def plural_name 'project_statuses' end # Creates a new status update on the project. # # Returns the full record of the newly created project status update. # # project - [Gid] The project on which to create a status update. # text - [String] The text of the project status update. # # color - [String] The color to associate with the status update. Must be one of `"red"`, `"yellow"`, or `"green"`. # # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def create_in_project(client, project: required("project"), text: required("text"), color: required("color"), options: {}, **data) with_params = data.merge(text: text, color: color).reject { |_,v| v.nil? || Array(v).empty? } Resource.new(parse(client.post("/projects/#{project}/project_statuses", body: with_params, options: options)).first, client: client) end alias_method :create, :create_in_project # Returns the compact project status update records for all updates on the project. # # project - [Gid] The project to find status updates for. # per_page - [Integer] the number of records to fetch per page. # options - [Hash] the request I/O options. def find_by_project(client, project: required("project"), per_page: 20, options: {}) params = { limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/projects/#{project}/project_statuses", params: params, options: options)), type: Resource, client: client) end # Returns the complete record for a single status update. # # id - [Gid] The project status update to get. # options - [Hash] the request I/O options. def find_by_id(client, id, options: {}) self.new(parse(client.get("/project_statuses/#{id}", options: options)).first, client: client) end end # Deletes a specific, existing project status update. # # Returns an empty data record. def delete() client.delete("/project_statuses/#{gid}") && true end end end end asana-0.10.3/lib/asana/resources/custom_field_settings.rb0000644000175100017510000000432614002345121022466 0ustar pravipravirequire_relative 'gen/custom_field_settings_base' module Asana module Resources # Custom fields are applied to a particular project or portfolio with the # Custom Field Settings resource. This resource both represents the # many-to-many join of the Custom Field and Project or Portfolio as well as # stores information that is relevant to that particular pairing; for instance, # the `is_important` property determines some possible application-specific # handling of that custom field and parent. class CustomFieldSetting < CustomFieldSettingsBase attr_reader :gid attr_reader :resource_type attr_reader :created_at attr_reader :is_important attr_reader :parent attr_reader :project attr_reader :custom_field class << self # Returns the plural name of the resource. def plural_name 'custom_field_settings' end # Returns a list of all of the custom fields settings on a project. # # project - [Gid] The ID of the project for which to list custom field settings # per_page - [Integer] the number of records to fetch per page. # options - [Hash] the request I/O options. def find_by_project(client, project: required("project"), per_page: 20, options: {}) params = { limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/projects/#{project}/custom_field_settings", params: params, options: options)), type: Resource, client: client) end # Returns a list of all of the custom fields settings on a portfolio. # # portfolio - [Gid] The ID of the portfolio for which to list custom field settings # per_page - [Integer] the number of records to fetch per page. # options - [Hash] the request I/O options. def find_by_portfolio(client, portfolio: required("portfolio"), per_page: 20, options: {}) params = { limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/portfolios/#{portfolio}/custom_field_settings", params: params, options: options)), type: Resource, client: client) end end end end end asana-0.10.3/lib/asana/resources/webhook.rb0000644000175100017510000001260314002345121017524 0ustar pravipravirequire_relative 'gen/webhooks_base' module Asana module Resources # Webhooks allow an application to be notified of changes. This is in addition # to the ability to fetch those changes directly as # [Events](/developers/api-reference/events) - in fact, Webhooks are just a way # to receive Events via HTTP POST at the time they occur instead of polling for # them. For services accessible via HTTP this is often vastly more convenient, # and if events are not too frequent can be significantly more efficient. # # In both cases, however, changes are represented as Event objects - refer to # the [Events documentation](/developers/api-reference/events) for more # information on what data these events contain. # # **NOTE:** While Webhooks send arrays of Event objects to their target, the # Event objects themselves contain *only IDs*, rather than the actual resource # they are referencing. So while a normal event you receive via GET /events # would look like this: # # {\ # "resource": {\ # "id": 1337,\ # "resource_type": "task",\ # "name": "My Task"\ # },\ # "parent": null,\ # "created_at": "2013-08-21T18:20:37.972Z",\ # "user": {\ # "id": 1123,\ # "resource_type": "user",\ # "name": "Tom Bizarro"\ # },\ # "action": "changed",\ # "type": "task"\ # } # # In a Webhook payload you would instead receive this: # # {\ # "resource": 1337,\ # "parent": null,\ # "created_at": "2013-08-21T18:20:37.972Z",\ # "user": 1123,\ # "action": "changed",\ # "type": "task"\ # } # # Webhooks themselves contain only the information necessary to deliver the # events to the desired target as they are generated. class Webhook < WebhooksBase attr_reader :gid attr_reader :resource_type attr_reader :resource attr_reader :target attr_reader :active attr_reader :created_at attr_reader :last_success_at attr_reader :last_failure_at attr_reader :last_failure_content class << self # Returns the plural name of the resource. def plural_name 'webhooks' end # Establishing a webhook is a two-part process. First, a simple HTTP POST # similar to any other resource creation. Since you could have multiple # webhooks we recommend specifying a unique local id for each target. # # Next comes the confirmation handshake. When a webhook is created, we will # send a test POST to the `target` with an `X-Hook-Secret` header as # described in the # [Resthooks Security documentation](http://resthooks.org/docs/security/). # The target must respond with a `200 OK` and a matching `X-Hook-Secret` # header to confirm that this webhook subscription is indeed expected. # # If you do not acknowledge the webhook's confirmation handshake it will # fail to setup, and you will receive an error in response to your attempt # to create it. This means you need to be able to receive and complete the # webhook *while* the POST request is in-flight. # # resource - [Id] A resource ID to subscribe to. The resource can be a task or project. # # target - [String] The URL to receive the HTTP POST. # # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def create(client, resource: required("resource"), target: required("target"), options: {}, **data) with_params = data.merge(resource: resource, target: target).reject { |_,v| v.nil? || Array(v).empty? } self.new(parse(client.post("/webhooks", body: with_params, options: options)).first, client: client) end # Returns the compact representation of all webhooks your app has # registered for the authenticated user in the given workspace. # # workspace - [Id] The workspace to query for webhooks in. # # resource - [Id] Only return webhooks for the given resource. # # per_page - [Integer] the number of records to fetch per page. # options - [Hash] the request I/O options. def get_all(client, workspace: required("workspace"), resource: nil, per_page: 20, options: {}) params = { workspace: workspace, resource: resource, limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/webhooks", params: params, options: options)), type: self, client: client) end # Returns the full record for the given webhook. # # id - [Id] The webhook to get. # # options - [Hash] the request I/O options. def get_by_id(client, id, options: {}) self.new(parse(client.get("/webhooks/#{id}", options: options)).first, client: client) end end # This method permanently removes a webhook. Note that it may be possible # to receive a request that was already in flight after deleting the # webhook, but no further requests will be issued. def delete_by_id() self.class.new(parse(client.delete("/webhooks/#{gid}")).first, client: client) end end end end asana-0.10.3/lib/asana/resources/job.rb0000644000175100017510000000167314002345121016645 0ustar pravipravirequire_relative 'gen/jobs_base' module Asana module Resources # A _job_ represents a process that handles asynchronous work. # # Jobs are created when an endpoint requests an action that will be handled asynchronously. # Such as project or task duplication. class Job < JobsBase attr_reader :gid attr_reader :resource_type attr_reader :resource_subtype attr_reader :status attr_reader :new_project attr_reader :new_task class << self # Returns the plural name of the resource. def plural_name 'jobs' end # Returns the complete job record for a single job. # # id - [Gid] The job to get. # options - [Hash] the request I/O options. def find_by_id(client, id, options: {}) self.new(parse(client.get("/jobs/#{id}", options: options)).first, client: client) end end end end end asana-0.10.3/lib/asana/resources/workspace_membership.rb0000644000175100017510000000104314002345121022273 0ustar pravipravirequire_relative 'gen/workspace_memberships_base' module Asana module Resources class WorkspaceMembership < WorkspaceMembershipsBase attr_reader :gid attr_reader :resource_type attr_reader :user attr_reader :workspace attr_reader :user_task_list attr_reader :is_admin attr_reader :is_active attr_reader :is_guest class << self # Returns the plural name of the resource. def plural_name 'workspace_memberships' end end end end end asana-0.10.3/lib/asana/resources/story.rb0000644000175100017510000000753614002345121017257 0ustar pravipravirequire_relative 'gen/stories_base' module Asana module Resources # A _story_ represents an activity associated with an object in the Asana # system. Stories are generated by the system whenever users take actions such # as creating or assigning tasks, or moving tasks between projects. _Comments_ # are also a form of user-generated story. class Story < StoriesBase attr_reader :gid attr_reader :resource_type attr_reader :resource_subtype attr_reader :created_at attr_reader :created_by attr_reader :liked alias_method :hearted, :liked attr_reader :likes alias_method :hearts, :likes attr_reader :num_likes attr_reader :text attr_reader :html_text attr_reader :target attr_reader :is_pinned attr_reader :is_edited attr_reader :source attr_reader :type class << self # Returns the plural name of the resource. def plural_name 'stories' end # Returns the compact records for all stories on the task. # # task - [Gid] Globally unique identifier for the task. # # per_page - [Integer] the number of records to fetch per page. # options - [Hash] the request I/O options. def find_by_task(client, task: required("task"), per_page: 20, options: {}) params = { limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? } Collection.new(parse(client.get("/tasks/#{task}/stories", params: params, options: options)), type: self, client: client) end # Returns the full record for a single story. # # id - [Gid] Globally unique identifier for the story. # # options - [Hash] the request I/O options. def find_by_id(client, id, options: {}) self.new(parse(client.get("/stories/#{id}", options: options)).first, client: client) end # Adds a comment to a task. The comment will be authored by the # currently authenticated user, and timestamped when the server receives # the request. # # Returns the full record for the new story added to the task. # # task - [Id] Globally unique identifier for the task. # # text - [String] The plain text of the comment to add. # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def create_on_task(client, task: required("task"), text: required("text"), options: {}, **data) with_params = data.merge(text: text).reject { |_,v| v.nil? || Array(v).empty? } self.new(parse(client.post("/tasks/#{task}/stories", body: with_params, options: options)).first, client: client) end end # Updates the story and returns the full record for the updated story. # Only comment stories can have their text updated, and only comment stories and # attachment stories can be pinned. Only one of `text` and `html_text` can be specified. # # text - [String] The plain text with which to update the comment. # # html_text - [String] The rich text with which to update the comment. # is_pinned - [Boolean] Whether the story should be pinned on the resource. # options - [Hash] the request I/O options. # data - [Hash] the attributes to post. def update(text: nil, html_text: nil, is_pinned: nil, options: {}, **data) with_params = data.merge(text: text, html_text: html_text, is_pinned: is_pinned).reject { |_,v| v.nil? || Array(v).empty? } refresh_with(parse(client.put("/stories/#{gid}", body: with_params, options: options)).first) end # Deletes a story. A user can only delete stories they have created. Returns an empty data record. def delete() client.delete("/stories/#{gid}") && true end end end end asana-0.10.3/lib/asana/errors.rb0000644000175100017510000000636514002345121015400 0ustar pravipravimodule Asana # Public: Defines the different errors that the Asana API may throw, which the # client code may want to catch. module Errors # Public: A generic, catch-all API error. It contains the whole response # object for debugging purposes. # # Note: This exception should never be raised when there exists a more # specific subclass. APIError = Class.new(StandardError) do attr_accessor :response def to_s 'An unknown API error ocurred.' end end # Public: A 401 error. Raised when the credentials used are invalid and the # user could not be authenticated. NotAuthorized = Class.new(APIError) do def to_s 'Valid credentials were not provided with the request, so the API could '\ 'not associate a user with the request.' end end # Public: A 402 error. Raised when the user is trying to access a feature # that requires a premium account (Payment Required). PremiumOnly = Class.new(APIError) do def to_s 'The endpoint that is being requested is only available to premium '\ 'users.' end end # Public: A 403 error. Raised when the user doesn't have permission to # access the requested resource or to perform the requested action on it. Forbidden = Class.new(APIError) do def to_s 'The authorization and request syntax was valid but the server is refusing '\ 'to complete the request. This can happen if you try to read or write '\ 'to objects or properties that the user does not have access to.' end end # Public: A 404 error. Raised when the requested resource doesn't exist. NotFound = Class.new(APIError) do def to_s 'Either the request method and path supplied do not specify a known '\ 'action in the API, or the object specified by the request does not '\ 'exist.' end end # Public: A 500 error. Raised when there is a problem in the Asana API # server. It contains a unique phrase that can be used to identify the # problem when contacting developer support. ServerError = Class.new(APIError) do attr_accessor :phrase def initialize(phrase) @phrase = phrase end def to_s "There has been an error on Asana's end. Use this unique phrase to "\ 'identify the problem when contacting support: ' + %("#{@phrase}") end end # Public: A 400 error. Raised when the request was malformed or missing some # parameters. It contains a list of errors indicating the specific problems. InvalidRequest = Class.new(APIError) do attr_accessor :errors def initialize(errors) @errors = errors end def to_s errors.join(', ') end end # Public: A 429 error. Raised when the Asana API enforces rate-limiting on # the client to avoid overload. It contains the number of seconds to wait # before retrying the operation. RateLimitEnforced = Class.new(APIError) do attr_accessor :retry_after_seconds def initialize(retry_after_seconds) @retry_after_seconds = retry_after_seconds end def to_s "Retry your request after #{@retry_after_seconds} seconds." end end end end asana-0.10.3/lib/asana/version.rb0000644000175100017510000000011714002345121015536 0ustar pravipravi#:nodoc: module Asana # Public: Version of the gem. VERSION = '0.10.3' end asana-0.10.3/lib/asana.rb0000644000175100017510000000045414002345121014055 0ustar pravipravirequire 'asana/ruby2_0_0_compatibility' require 'asana/authentication' require 'asana/resources' require 'asana/client' require 'asana/errors' require 'asana/http_client' require 'asana/version' # Public: Top-level namespace of the Asana API Ruby client. module Asana include Asana::Resources end asana-0.10.3/Appraisals0000644000175100017510000000010014002345121013705 0ustar pravipravi appraise "faraday-1.0.0" do gem "faraday", "1.0.0" end asana-0.10.3/samples/0000755000175100017510000000000014002345121013340 5ustar pravipraviasana-0.10.3/samples/users_sample.yaml0000644000175100017510000000307514002345121016733 0ustar pravipraviusers: get_favorites_for_user: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.users.get_favorites_for_user(user_gid: 'user_gid', resource_type: ''resource_type_example'', workspace: ''workspace_example'', param: "value", param: "value", options: {pretty: true}) get_user: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.users.get_user(user_gid: 'user_gid', param: "value", param: "value", options: {pretty: true}) get_users: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.users.get_users(param: "value", param: "value", options: {pretty: true}) get_users_for_team: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.users.get_users_for_team(team_gid: 'team_gid', param: "value", param: "value", options: {pretty: true}) get_users_for_workspace: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.users.get_users_for_workspace(workspace_gid: 'workspace_gid', param: "value", param: "value", options: {pretty: true}) asana-0.10.3/samples/organization_exports_sample.yaml0000644000175100017510000000127014002345121022055 0ustar pravipraviorganizationexports: create_organization_export: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.organization_exports.create_organization_export(field: "value", field: "value", options: {pretty: true}) get_organization_export: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.organization_exports.get_organization_export(organization_export_gid: 'organization_export_gid', param: "value", param: "value", options: {pretty: true}) asana-0.10.3/samples/project_statuses_sample.yaml0000644000175100017510000000252614002345121021173 0ustar pravipraviprojectstatuses: create_project_status_for_project: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.project_statuses.create_project_status_for_project(project_gid: 'project_gid', field: "value", field: "value", options: {pretty: true}) delete_project_status: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.project_statuses.delete_project_status(project_status_gid: 'project_status_gid', options: {pretty: true}) get_project_status: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.project_statuses.get_project_status(project_status_gid: 'project_status_gid', param: "value", param: "value", options: {pretty: true}) get_project_statuses_for_project: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.project_statuses.get_project_statuses_for_project(project_gid: 'project_gid', param: "value", param: "value", options: {pretty: true}) asana-0.10.3/samples/events_sample.yaml0000644000175100017510000000047714002345121017101 0ustar pravipravievents: get_events: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.events.get_events(resource: ''resource_example'', param: "value", param: "value", options: {pretty: true}) asana-0.10.3/samples/workspaces_sample.yaml0000644000175100017510000000305514002345121017751 0ustar pravipraviworkspaces: add_user_for_workspace: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.workspaces.add_user_for_workspace(workspace_gid: 'workspace_gid', field: "value", field: "value", options: {pretty: true}) get_workspace: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.workspaces.get_workspace(workspace_gid: 'workspace_gid', param: "value", param: "value", options: {pretty: true}) get_workspaces: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.workspaces.get_workspaces(param: "value", param: "value", options: {pretty: true}) remove_user_for_workspace: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.workspaces.remove_user_for_workspace(workspace_gid: 'workspace_gid', field: "value", field: "value", options: {pretty: true}) update_workspace: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.workspaces.update_workspace(workspace_gid: 'workspace_gid', field: "value", field: "value", options: {pretty: true}) asana-0.10.3/samples/typeahead_sample.yaml0000644000175100017510000000061114002345121017527 0ustar pravipravitypeahead: typeahead_for_workspace: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.typeahead.typeahead_for_workspace(workspace_gid: 'workspace_gid', resource_type: ''resource_type_example'', param: "value", param: "value", options: {pretty: true}) asana-0.10.3/samples/team_memberships_sample.yaml0000644000175100017510000000254014002345121021112 0ustar pravipraviteammemberships: get_team_membership: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.team_memberships.get_team_membership(team_membership_gid: 'team_membership_gid', param: "value", param: "value", options: {pretty: true}) get_team_memberships: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.team_memberships.get_team_memberships(param: "value", param: "value", options: {pretty: true}) get_team_memberships_for_team: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.team_memberships.get_team_memberships_for_team(team_gid: 'team_gid', param: "value", param: "value", options: {pretty: true}) get_team_memberships_for_user: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.team_memberships.get_team_memberships_for_user(user_gid: 'user_gid', workspace: ''workspace_example'', param: "value", param: "value", options: {pretty: true}) asana-0.10.3/samples/project_memberships_sample.yaml0000644000175100017510000000133714002345121021635 0ustar pravipraviprojectmemberships: get_project_membership: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.project_memberships.get_project_membership(project_membership_gid: 'project_membership_gid', param: "value", param: "value", options: {pretty: true}) get_project_memberships_for_project: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.project_memberships.get_project_memberships_for_project(project_gid: 'project_gid', param: "value", param: "value", options: {pretty: true}) asana-0.10.3/samples/sections_sample.yaml0000644000175100017510000000422314002345121017415 0ustar pravipravisections: add_task_for_section: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.sections.add_task_for_section(section_gid: 'section_gid', field: "value", field: "value", options: {pretty: true}) create_section_for_project: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.sections.create_section_for_project(project_gid: 'project_gid', field: "value", field: "value", options: {pretty: true}) delete_section: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.sections.delete_section(section_gid: 'section_gid', options: {pretty: true}) get_section: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.sections.get_section(section_gid: 'section_gid', param: "value", param: "value", options: {pretty: true}) get_sections_for_project: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.sections.get_sections_for_project(project_gid: 'project_gid', param: "value", param: "value", options: {pretty: true}) insert_section_for_project: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.sections.insert_section_for_project(project_gid: 'project_gid', field: "value", field: "value", options: {pretty: true}) update_section: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.sections.update_section(section_gid: 'section_gid', field: "value", field: "value", options: {pretty: true}) asana-0.10.3/samples/teams_sample.yaml0000644000175100017510000000306714002345121016704 0ustar pravipraviteams: add_user_for_team: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.teams.add_user_for_team(team_gid: 'team_gid', field: "value", field: "value", options: {pretty: true}) get_team: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.teams.get_team(team_gid: 'team_gid', param: "value", param: "value", options: {pretty: true}) get_teams_for_organization: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.teams.get_teams_for_organization(workspace_gid: 'workspace_gid', param: "value", param: "value", options: {pretty: true}) get_teams_for_user: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.teams.get_teams_for_user(user_gid: 'user_gid', organization: ''organization_example'', param: "value", param: "value", options: {pretty: true}) remove_user_for_team: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.teams.remove_user_for_team(team_gid: 'team_gid', field: "value", field: "value", options: {pretty: true}) asana-0.10.3/samples/jobs_sample.yaml0000644000175100017510000000043714002345121016526 0ustar pravipravijobs: get_job: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.jobs.get_job(job_gid: 'job_gid', param: "value", param: "value", options: {pretty: true}) asana-0.10.3/samples/custom_field_settings_sample.yaml0000644000175100017510000000137014002345121022163 0ustar pravipravicustomfieldsettings: get_custom_field_settings_for_portfolio: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.custom_field_settings.get_custom_field_settings_for_portfolio(portfolio_gid: 'portfolio_gid', param: "value", param: "value", options: {pretty: true}) get_custom_field_settings_for_project: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.custom_field_settings.get_custom_field_settings_for_project(project_gid: 'project_gid', param: "value", param: "value", options: {pretty: true}) asana-0.10.3/samples/portfolio_memberships_sample.yaml0000644000175100017510000000206214002345121022200 0ustar pravipraviportfoliomemberships: get_portfolio_membership: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.portfolio_memberships.get_portfolio_membership(portfolio_membership_gid: 'portfolio_membership_gid', param: "value", param: "value", options: {pretty: true}) get_portfolio_memberships: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.portfolio_memberships.get_portfolio_memberships(param: "value", param: "value", options: {pretty: true}) get_portfolio_memberships_for_portfolio: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.portfolio_memberships.get_portfolio_memberships_for_portfolio(portfolio_gid: 'portfolio_gid', param: "value", param: "value", options: {pretty: true}) asana-0.10.3/samples/stories_sample.yaml0000644000175100017510000000271714002345121017264 0ustar pravipravistories: create_story_for_task: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.stories.create_story_for_task(task_gid: 'task_gid', field: "value", field: "value", options: {pretty: true}) delete_story: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.stories.delete_story(story_gid: 'story_gid', options: {pretty: true}) get_stories_for_task: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.stories.get_stories_for_task(task_gid: 'task_gid', param: "value", param: "value", options: {pretty: true}) get_story: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.stories.get_story(story_gid: 'story_gid', param: "value", param: "value", options: {pretty: true}) update_story: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.stories.update_story(story_gid: 'story_gid', field: "value", field: "value", options: {pretty: true}) asana-0.10.3/samples/batch_api_sample.yaml0000644000175100017510000000045614002345121017504 0ustar pravipravibatchapi: create_batch_request: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.batch_api.create_batch_request(field: "value", field: "value", options: {pretty: true}) asana-0.10.3/samples/workspace_memberships_sample.yaml0000644000175100017510000000213214002345121022157 0ustar pravipraviworkspacememberships: get_workspace_membership: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.workspace_memberships.get_workspace_membership(workspace_membership_gid: 'workspace_membership_gid', param: "value", param: "value", options: {pretty: true}) get_workspace_memberships_for_user: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.workspace_memberships.get_workspace_memberships_for_user(user_gid: 'user_gid', param: "value", param: "value", options: {pretty: true}) get_workspace_memberships_for_workspace: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.workspace_memberships.get_workspace_memberships_for_workspace(workspace_gid: 'workspace_gid', param: "value", param: "value", options: {pretty: true}) asana-0.10.3/samples/custom_fields_sample.yaml0000644000175100017510000000515114002345121020427 0ustar pravipravicustomfields: create_custom_field: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.custom_fields.create_custom_field(field: "value", field: "value", options: {pretty: true}) create_enum_option_for_custom_field: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.custom_fields.create_enum_option_for_custom_field(custom_field_gid: 'custom_field_gid', field: "value", field: "value", options: {pretty: true}) delete_custom_field: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.custom_fields.delete_custom_field(custom_field_gid: 'custom_field_gid', options: {pretty: true}) get_custom_field: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.custom_fields.get_custom_field(custom_field_gid: 'custom_field_gid', param: "value", param: "value", options: {pretty: true}) get_custom_fields_for_workspace: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.custom_fields.get_custom_fields_for_workspace(workspace_gid: 'workspace_gid', param: "value", param: "value", options: {pretty: true}) insert_enum_option_for_custom_field: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.custom_fields.insert_enum_option_for_custom_field(custom_field_gid: 'custom_field_gid', field: "value", field: "value", options: {pretty: true}) update_custom_field: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.custom_fields.update_custom_field(custom_field_gid: 'custom_field_gid', field: "value", field: "value", options: {pretty: true}) update_enum_option: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.custom_fields.update_enum_option(enum_option_gid: 'enum_option_gid', field: "value", field: "value", options: {pretty: true}) asana-0.10.3/samples/tags_sample.yaml0000644000175100017510000000440114002345121016522 0ustar pravipravitags: create_tag: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.tags.create_tag(field: "value", field: "value", options: {pretty: true}) create_tag_for_workspace: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.tags.create_tag_for_workspace(workspace_gid: 'workspace_gid', field: "value", field: "value", options: {pretty: true}) delete_tag: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.tags.delete_tag(tag_gid: 'tag_gid', options: {pretty: true}) get_tag: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.tags.get_tag(tag_gid: 'tag_gid', param: "value", param: "value", options: {pretty: true}) get_tags: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.tags.get_tags(param: "value", param: "value", options: {pretty: true}) get_tags_for_task: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.tags.get_tags_for_task(task_gid: 'task_gid', param: "value", param: "value", options: {pretty: true}) get_tags_for_workspace: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.tags.get_tags_for_workspace(workspace_gid: 'workspace_gid', param: "value", param: "value", options: {pretty: true}) update_tag: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.tags.update_tag(tag_gid: 'tag_gid', field: "value", field: "value", options: {pretty: true}) asana-0.10.3/samples/user_task_lists_sample.yaml0000644000175100017510000000133014002345121021000 0ustar pravipraviusertasklists: get_user_task_list: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.user_task_lists.get_user_task_list(user_task_list_gid: 'user_task_list_gid', param: "value", param: "value", options: {pretty: true}) get_user_task_list_for_user: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.user_task_lists.get_user_task_list_for_user(user_gid: 'user_gid', workspace: ''workspace_example'', param: "value", param: "value", options: {pretty: true}) asana-0.10.3/samples/attachments_sample.yaml0000644000175100017510000000236414002345121020105 0ustar pravipraviattachments: create_attachment_for_task: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.attachments.create_attachment_for_task(task_gid: 'task_gid', field: "value", field: "value", options: {pretty: true}) delete_attachment: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.attachments.delete_attachment(attachment_gid: 'attachment_gid', options: {pretty: true}) get_attachment: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.attachments.get_attachment(attachment_gid: 'attachment_gid', param: "value", param: "value", options: {pretty: true}) get_attachments_for_task: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.attachments.get_attachments_for_task(task_gid: 'task_gid', param: "value", param: "value", options: {pretty: true}) asana-0.10.3/samples/tasks_sample.yaml0000644000175100017510000001747214002345121016725 0ustar pravipravitasks: add_dependencies_for_task: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.tasks.add_dependencies_for_task(task_gid: 'task_gid', field: "value", field: "value", options: {pretty: true}) add_dependents_for_task: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.tasks.add_dependents_for_task(task_gid: 'task_gid', field: "value", field: "value", options: {pretty: true}) add_followers_for_task: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.tasks.add_followers_for_task(task_gid: 'task_gid', field: "value", field: "value", options: {pretty: true}) add_project_for_task: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.tasks.add_project_for_task(task_gid: 'task_gid', field: "value", field: "value", options: {pretty: true}) add_tag_for_task: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.tasks.add_tag_for_task(task_gid: 'task_gid', field: "value", field: "value", options: {pretty: true}) create_subtask_for_task: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.tasks.create_subtask_for_task(task_gid: 'task_gid', field: "value", field: "value", options: {pretty: true}) create_task: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.tasks.create_task(field: "value", field: "value", options: {pretty: true}) delete_task: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.tasks.delete_task(task_gid: 'task_gid', options: {pretty: true}) duplicate_task: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.tasks.duplicate_task(task_gid: 'task_gid', field: "value", field: "value", options: {pretty: true}) get_dependencies_for_task: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.tasks.get_dependencies_for_task(task_gid: 'task_gid', param: "value", param: "value", options: {pretty: true}) get_dependents_for_task: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.tasks.get_dependents_for_task(task_gid: 'task_gid', param: "value", param: "value", options: {pretty: true}) get_subtasks_for_task: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.tasks.get_subtasks_for_task(task_gid: 'task_gid', param: "value", param: "value", options: {pretty: true}) get_task: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.tasks.get_task(task_gid: 'task_gid', param: "value", param: "value", options: {pretty: true}) get_tasks: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.tasks.get_tasks(param: "value", param: "value", options: {pretty: true}) get_tasks_for_project: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.tasks.get_tasks_for_project(project_gid: 'project_gid', param: "value", param: "value", options: {pretty: true}) get_tasks_for_section: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.tasks.get_tasks_for_section(section_gid: 'section_gid', param: "value", param: "value", options: {pretty: true}) get_tasks_for_tag: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.tasks.get_tasks_for_tag(tag_gid: 'tag_gid', param: "value", param: "value", options: {pretty: true}) get_tasks_for_user_task_list: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.tasks.get_tasks_for_user_task_list(user_task_list_gid: 'user_task_list_gid', param: "value", param: "value", options: {pretty: true}) remove_dependencies_for_task: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.tasks.remove_dependencies_for_task(task_gid: 'task_gid', field: "value", field: "value", options: {pretty: true}) remove_dependents_for_task: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.tasks.remove_dependents_for_task(task_gid: 'task_gid', field: "value", field: "value", options: {pretty: true}) remove_follower_for_task: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.tasks.remove_follower_for_task(task_gid: 'task_gid', field: "value", field: "value", options: {pretty: true}) remove_project_for_task: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.tasks.remove_project_for_task(task_gid: 'task_gid', field: "value", field: "value", options: {pretty: true}) remove_tag_for_task: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.tasks.remove_tag_for_task(task_gid: 'task_gid', field: "value", field: "value", options: {pretty: true}) search_tasks_for_workspace: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.tasks.search_tasks_for_workspace(workspace_gid: 'workspace_gid', param: "value", param: "value", options: {pretty: true}) set_parent_for_task: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.tasks.set_parent_for_task(task_gid: 'task_gid', field: "value", field: "value", options: {pretty: true}) update_task: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.tasks.update_task(task_gid: 'task_gid', field: "value", field: "value", options: {pretty: true}) asana-0.10.3/samples/webhooks_sample.yaml0000644000175100017510000000223514002345121017410 0ustar pravipraviwebhooks: create_webhook: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.webhooks.create_webhook(field: "value", field: "value", options: {pretty: true}) delete_webhook: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.webhooks.delete_webhook(webhook_gid: 'webhook_gid', options: {pretty: true}) get_webhook: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.webhooks.get_webhook(webhook_gid: 'webhook_gid', param: "value", param: "value", options: {pretty: true}) get_webhooks: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.webhooks.get_webhooks(workspace: ''workspace_example'', param: "value", param: "value", options: {pretty: true}) asana-0.10.3/samples/portfolios_sample.yaml0000644000175100017510000000756714002345121020004 0ustar pravipraviportfolios: add_custom_field_setting_for_portfolio: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.portfolios.add_custom_field_setting_for_portfolio(portfolio_gid: 'portfolio_gid', field: "value", field: "value", options: {pretty: true}) add_item_for_portfolio: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.portfolios.add_item_for_portfolio(portfolio_gid: 'portfolio_gid', field: "value", field: "value", options: {pretty: true}) add_members_for_portfolio: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.portfolios.add_members_for_portfolio(portfolio_gid: 'portfolio_gid', field: "value", field: "value", options: {pretty: true}) create_portfolio: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.portfolios.create_portfolio(field: "value", field: "value", options: {pretty: true}) delete_portfolio: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.portfolios.delete_portfolio(portfolio_gid: 'portfolio_gid', options: {pretty: true}) get_items_for_portfolio: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.portfolios.get_items_for_portfolio(portfolio_gid: 'portfolio_gid', param: "value", param: "value", options: {pretty: true}) get_portfolio: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.portfolios.get_portfolio(portfolio_gid: 'portfolio_gid', param: "value", param: "value", options: {pretty: true}) get_portfolios: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.portfolios.get_portfolios(workspace: ''workspace_example'', owner: ''owner_example'', param: "value", param: "value", options: {pretty: true}) remove_custom_field_setting_for_portfolio: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.portfolios.remove_custom_field_setting_for_portfolio(portfolio_gid: 'portfolio_gid', field: "value", field: "value", options: {pretty: true}) remove_item_for_portfolio: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.portfolios.remove_item_for_portfolio(portfolio_gid: 'portfolio_gid', field: "value", field: "value", options: {pretty: true}) remove_members_for_portfolio: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.portfolios.remove_members_for_portfolio(portfolio_gid: 'portfolio_gid', field: "value", field: "value", options: {pretty: true}) update_portfolio: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.portfolios.update_portfolio(portfolio_gid: 'portfolio_gid', field: "value", field: "value", options: {pretty: true}) asana-0.10.3/samples/projects_sample.yaml0000644000175100017510000001313714002345121017423 0ustar pravipraviprojects: add_custom_field_setting_for_project: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.projects.add_custom_field_setting_for_project(project_gid: 'project_gid', field: "value", field: "value", options: {pretty: true}) add_followers_for_project: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.projects.add_followers_for_project(project_gid: 'project_gid', field: "value", field: "value", options: {pretty: true}) add_members_for_project: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.projects.add_members_for_project(project_gid: 'project_gid', field: "value", field: "value", options: {pretty: true}) create_project: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.projects.create_project(field: "value", field: "value", options: {pretty: true}) create_project_for_team: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.projects.create_project_for_team(team_gid: 'team_gid', field: "value", field: "value", options: {pretty: true}) create_project_for_workspace: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.projects.create_project_for_workspace(workspace_gid: 'workspace_gid', field: "value", field: "value", options: {pretty: true}) delete_project: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.projects.delete_project(project_gid: 'project_gid', options: {pretty: true}) duplicate_project: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.projects.duplicate_project(project_gid: 'project_gid', field: "value", field: "value", options: {pretty: true}) get_project: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.projects.get_project(project_gid: 'project_gid', param: "value", param: "value", options: {pretty: true}) get_projects: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.projects.get_projects(param: "value", param: "value", options: {pretty: true}) get_projects_for_task: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.projects.get_projects_for_task(task_gid: 'task_gid', param: "value", param: "value", options: {pretty: true}) get_projects_for_team: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.projects.get_projects_for_team(team_gid: 'team_gid', param: "value", param: "value", options: {pretty: true}) get_projects_for_workspace: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.projects.get_projects_for_workspace(workspace_gid: 'workspace_gid', param: "value", param: "value", options: {pretty: true}) get_task_counts_for_project: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.projects.get_task_counts_for_project(project_gid: 'project_gid', param: "value", param: "value", options: {pretty: true}) remove_custom_field_setting_for_project: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.projects.remove_custom_field_setting_for_project(project_gid: 'project_gid', field: "value", field: "value", options: {pretty: true}) remove_followers_for_project: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.projects.remove_followers_for_project(project_gid: 'project_gid', field: "value", field: "value", options: {pretty: true}) remove_members_for_project: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.projects.remove_members_for_project(project_gid: 'project_gid', field: "value", field: "value", options: {pretty: true}) update_project: >- require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN' end result = client.projects.update_project(project_gid: 'project_gid', field: "value", field: "value", options: {pretty: true}) asana-0.10.3/README.md0000644000175100017510000002612714002345121013163 0ustar pravipravi# Asana [![Gem Version](https://badge.fury.io/rb/asana.svg)](http://badge.fury.io/rb/asana) [![Build Status](https://travis-ci.org/Asana/ruby-asana.svg?branch=master)](https://travis-ci.org/Asana/ruby-asana) [![Code Climate](https://codeclimate.com/github/Asana/ruby-asana/badges/gpa.svg)](https://codeclimate.com/github/Asana/ruby-asana) A Ruby client for the 1.0 version of the Asana API. Supported rubies: * MRI 2.0.0 up to 2.2.x stable ## Gem Installation Add this line to your application's Gemfile: ```ruby gem 'asana' ``` And then execute: $ bundle Or install it yourself as: $ gem install asana ## Usage To do anything, you'll need always an instance of `Asana::Client` configured with your preferred authentication method (see the Authentication section below for more complex scenarios) and other options. The most minimal example would be as follows: ```ruby require 'asana' client = Asana::Client.new do |c| c.authentication :access_token, 'personal_access_token' end client.workspaces.find_all.first ``` A full-blown customized client using OAuth2 wih a previously obtained refresh token, Typhoeus as a Faraday adapter, a custom user agent and custom Faraday middleware: ```ruby require 'asana' client = Asana::Client.new do |c| c.authentication :oauth2, refresh_token: 'abc', client_id: 'bcd', client_secret: 'cde', redirect_uri: 'http://example.org/auth' c.faraday_adapter :typhoeus c.configure_faraday { |conn| conn.use SomeFaradayMiddleware } end workspace = client.workspaces.find_by_id(12) workspace.users # => # ...> client.tags.create_in_workspace(workspace: workspace.id, name: 'foo') # => # ``` All resources are exposed as methods on the `Asana::Client` instance. Check out the [documentation for each of them][docs]. ### Authentication This gem supports authenticating against the Asana API with either an API token or through OAuth2. #### Personal Access Token ```ruby Asana::Client.new do |c| c.authentication :access_token, 'personal_access_token' end ``` #### OAuth2 Authenticating through OAuth2 is preferred. There are many ways you can do this. ##### With a plain bearer token (doesn't support auto-refresh) If you have a plain bearer token obtained somewhere else and you don't mind not having your token auto-refresh, you can authenticate with it as follows: ```ruby Asana::Client.new do |c| c.authentication :oauth2, bearer_token: 'my_bearer_token' end ``` ##### With a refresh token and client credentials If you obtained a refresh token, you can use it together with your client credentials to authenticate: ```ruby Asana::Client.new do |c| c.authentication :oauth2, refresh_token: 'abc', client_id: 'bcd', client_secret: 'cde', redirect_uri: 'http://example.org/auth' end ``` ##### With an ::OAuth2::AccessToken object (from `omniauth-asana` for example) If you use `omniauth-asana` or a browser-based OAuth2 authentication strategy in general, possibly because your application is a web application, you can reuse those credentials to authenticate with this API client. Here's how to do it from the callback method: ```ruby # assuming we're using Sinatra and omniauth-asana get '/auth/:name/callback' do creds = request.env["omniauth.auth"]["credentials"].tap { |h| h.delete('expires') } strategy = request.env["omniauth.strategy"] # We need to refresh the omniauth OAuth2 token access_token = OAuth2::AccessToken.from_hash(strategy.client, creds).refresh! $client = Asana::Client.new do |c| c.authentication :oauth2, access_token end redirect '/' end ``` See `examples/omniauth_integration.rb` for a working example of this. ##### Using an OAuth2 offline authentication flow (for CLI applications) If your application can't receive HTTP requests and thus you can't use `omniauth-asana`, for example if it's a CLI application, you can authenticate as follows: ```ruby access_token = Asana::Authentication::OAuth2.offline_flow(client_id: ..., client_secret: ...) client = Asana::Client.new do |c| c.authentication :oauth2, access_token end client.tasks.find_by_id(12) ``` This will print an authorization URL on STDOUT, and block until you paste in the authorization code, which you can get by visiting that URL and granting the necessary permissions. ### Pagination Whenever you ask for a collection of resources, you can provide a number of results per page to fetch, between 1 and 100. If you don't provide any, it defaults to 20. ```ruby my_tasks = client.tasks.find_by_tag(tag: tag_id, per_page: 5) # => # ...> ``` An `Asana::Collection` is a paginated collection -- it holds the first `per_page` results, and a reference to the next page if any. When you iterate an `Asana::Collection`, it'll transparently keep fetching all the pages, and caching them along the way: ```ruby my_tasks.size # => 23, not 5 my_tasks.take(14) # => [#, #, ... until 14] ``` #### Manual pagination If you only want to deal with one page at a time and manually paginate, you can get the elements of the current page with `#elements` and ask for the next page with `#next_page`, which will return an `Asana::Collection` with the next page of elements: ```ruby my_tasks.elements # => [#, #, ... until 5] my_tasks.next_page # => # ``` #### Lazy pagination Because an `Asana::Collection` represents the entire collection, it is often handy to just take what you need from it, rather than let it fetch all its contents from the network. You can accomplish this by turning it into a lazy collection with `#lazy`: ```ruby # let my_tasks be an Asana::Collection of 10 pages of 100 elements each my_tasks.lazy.drop(120).take(15).to_a # Fetches only 2 pages, enough to get elements 120 to 135 # => [#, #, ...] ``` ### Error handling In any request against the Asana API, there a number of errors that could arise. Those are well documented in the [Asana API Documentation][apidocs], and are represented as exceptions under the namespace `Asana::Errors`. All errors are subclasses of `Asana::Errors::APIError`, so make sure to rescue instances of this class if you want to handle them yourself. ### I/O options All requests (except `DELETE`) accept extra I/O options [as documented in the API docs][io]. Just pass an extra `options` hash to any request: ```ruby client.tasks.find_by_id(12, options: { expand: ['workspace'] }) ``` ### Attachment uploading To attach a file to a task or a project, you just need its absolute path on your filesystem and its MIME type, and the file will be uploaded for you: ```ruby task = client.tasks.find_by_id(12) attachment = task.attach(filename: '/absolute/path/to/my/file.png', mime: 'image/png') attachment.name # => 'file.png' ``` ### Event streams To subscribe to an event stream of a task or a project, just call `#events` on it: ```ruby task = client.tasks.find_by_id(12) task.events # => # # You can do the same with only the task id: events = client.events.for(task.id) ``` An `Asana::Events` object is an infinite collection of `Asana::Event` instances. Be warned that if you call `#each` on it, it will block forever! Note that, by default, an event stream will wait at least 1 second between polls, but that's configurable with the `wait` parameter: ```ruby # wait at least 3 and a half seconds between each poll to the API task.events(wait: 3.5) # => # ``` There are some interesting things you can do with an event stream, as it is a normal Ruby Enumerable. Read below to get some ideas. #### Subscribe to the event stream with a callback, polling every 2 seconds ```ruby # Run this in another thread so that we don't block forever events = client.tasks.find_by_id(12).events(wait: 2) Thread.new do events.each do |event| notify_someone "New event arrived! #{event}" end end ``` #### Make the stream lazy and filter it by a specific pattern To do that we need to call `#lazy` on the `Events` instance, just like with any other `Enumerable`. ```ruby events = client.tasks.find_by_id(12).events only_change_events = events.lazy.select { |event| event.action == 'changed' } Thread.new do only_change_events.each do |event| notify_someone "New change event arrived! #{event}" end end ``` ### Asana Change Warnings You will receive warning logs if performing requests that may be affected by a deprecation. The warning contains a link that explains the deprecation. If you receive one of these warnings, you should: * Read about the deprecation. * Resolve sections of your code that would be affected by the deprecation. * Add the deprecation flag to your "asana-enable" header. You can add global headers, by setting default_headers c.default_headers "asana-enable" => "string_ids" Or you can add a header field to the options of each request. If you would rather suppress these warnings, you can set c.log_asana_change_warnings false ## Development You'll need Ruby 2.1+ and Node v0.10.26+ / NPM 1.4.3+ installed. After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment. Run the build with `rake`. This is equivalent to: $ rake spec && rake rubocop && rake yard To install this gem onto your local machine, run `bundle exec rake install`. ## Releasing a new version To release a new version, run either of these commands: rake bump:patch rake bump:minor rake bump:major This will: update `lib/asana/version.rb`, commit and tag the commit. Then you just need to `push --tags` to let Travis build and release the new version to Rubygems: git push --tags ### Code generation The specific Asana resource classes (`Tag`, `Workspace`, `Task`, etc) are generated code, hence they shouldn't be modified by hand. The code that generates it lives in `lib/templates/resource.ejs`, and is tested by generating `spec/templates/unicorn.rb` and running `spec/templates/unicorn_spec.rb` as part of the build. If you wish to make changes on the code generation script: 1. Add/modify a spec on `spec/templates/unicorn_spec.rb` 2. Add your new feature or change to `lib/templates/resource.ejs` 3. Run `rake` or, more granularly, `rake codegen && rspec spec/templates/unicorn_spec.rb` Once you're sure your code works, submit a pull request and ask the maintainer to make a release, as they'll need to run a release script. ## Contributing 1. Fork it ( https://github.com/[my-github-username]/asana/fork ) 2. Create your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am 'Add some feature'`) 4. Push to the branch (`git push origin my-new-feature`) 5. Create a new Pull Request [apidocs]: https://developers.asana.com/docs [io]: https://developers.asana.com/docs/#input-output-options [docs]: http://www.rubydoc.info/github/Asana/ruby-asana/master [meta]: https://github.com/asana/asana-api-meta asana-0.10.3/Rakefile0000644000175100017510000000443314002345121013345 0ustar pravipravirequire 'bundler/setup' require 'bundler/gem_tasks' require 'appraisal' require 'rspec/core/rake_task' require 'rubocop/rake_task' require 'yard' RSpec::Core::RakeTask.new(:spec) RuboCop::RakeTask.new YARD::Rake::YardocTask.new do |t| t.stats_options = ['--list-undoc'] end desc 'Generates a test resource from a YAML using the resource template.' task :codegen do # TODO: I believe this is obsolete and can be removed `node spec/support/codegen.js` end namespace :bump do def read_version File.readlines('./lib/asana/version.rb') .detect { |l| l =~ /VERSION/ } .scan(/VERSION = '([^']+)/).flatten.first.split('.') .map { |n| Integer(n) } end # rubocop:disable Metrics/MethodLength def write_version(major, minor, patch) str = <<-EOS #:nodoc: module Asana # Public: Version of the gem. VERSION = '#{major}.#{minor}.#{patch}' end EOS File.open('./lib/asana/version.rb', 'w') do |f| f.write str end new_version = "#{major}.#{minor}.#{patch}" system('git add lib/asana/version.rb') system(%(git commit -m "Bumped to #{new_version}" && ) + %(git tag -a v#{new_version} -m "Version #{new_version}")) puts "\nRun git push --tags to release." end desc 'Bumps a patch version' task :patch do major, minor, patch = read_version write_version major, minor, patch + 1 end desc 'Bumps a minor version' task :minor do major, minor, = read_version write_version major, minor + 1, 0 end desc 'Bumps a major version' task :major do major, = read_version write_version major + 1, 0, 0 end end desc 'Default: run the unit tests.' task default: [:all, :rubocop, :yard] desc 'Test the plugin under all supported Rails versions.' task :all do |_t| if ENV['TRAVIS'] # require 'json' # puts JSON.pretty_generate(ENV.to_hash) if ENV['BUNDLE_GEMFILE'] =~ /gemfiles/ appraisal_name = ENV['BUNDLE_GEMFILE'].scan(/faraday\_(.*)\.gemfile/).flatten.first command_prefix = "appraisal faraday-#{appraisal_name}" exec("#{command_prefix} bundle install && #{command_prefix} bundle exec rspec") else exec(' bundle exec appraisal install && bundle exec rake appraisal spec') end else exec('bundle exec appraisal install && bundle exec rake appraisal spec') end end asana-0.10.3/.swagger-codegen-ignore0000644000175100017510000000004114002345121016212 0ustar pravipravi# Swagger Codegen Ignore test/* asana-0.10.3/Gemfile0000644000175100017510000000133114002345121013165 0ustar pravipravisource 'https://rubygems.org' # Specify your gem's dependencies in asana.gemspec gemspec group :tools do # Currently we need to pin the version of Rubocop, due to an incompatibility # with rubocop-rspec. However, this also solves the problem that Rubocop # routinely adds new checks which can cause our build to "break" even when no # changes have been made. In this situation it's better to intentionally # upgrade Rubocop and fix issues at that time. gem 'rubocop', '~> 0.52.1' gem 'rubocop-rspec', '~> 1.22.2' gem 'guard' gem 'guard-rspec' gem 'guard-rubocop' gem 'guard-yard' gem 'yard' gem 'yard-tomdoc' gem 'byebug' gem 'simplecov', require: false gem "rack-protection", "1.5.5" end asana-0.10.3/LICENSE.txt0000644000175100017510000000206614002345121013523 0ustar pravipraviThe MIT License (MIT) Copyright (c) 2015 Asana, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. asana-0.10.3/package.json0000644000175100017510000000015214002345121014160 0ustar pravipravi{ "devDependencies": { "inflect": "^0.3.0", "js-yaml": "^3.2.5", "lodash": "^4.17.13" } } asana-0.10.3/.yardopts0000644000175100017510000000012414002345121013537 0ustar pravipravi--title "Asana API Ruby Client" --readme README.md --plugin tomdoc lib - LICENSE.txtasana-0.10.3/asana.gemspec0000644000175100017510000000225014002345121014323 0ustar pravipravi# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'asana/version' Gem::Specification.new do |spec| spec.name = "asana" spec.version = Asana::VERSION spec.authors = ["Txus"] spec.email = ["me@txus.io"] spec.summary = %q{Official Ruby client for the Asana API} spec.description = %q{Official Ruby client for the Asana API} spec.homepage = "https://github.com/asana/ruby-asana" spec.license = "MIT" spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } spec.bindir = "exe" spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] spec.required_ruby_version = '> 2.0' spec.add_dependency "oauth2", "~> 1.4" spec.add_dependency "faraday", "~> 1.0" spec.add_dependency "faraday_middleware", "~> 1.0" spec.add_dependency "faraday_middleware-multi_json", "~> 0.0" spec.add_development_dependency "rake", "~> 10.0" spec.add_development_dependency "rspec", "~> 3.2" spec.add_development_dependency 'appraisal', '~> 2.1', '>= 2.1' end asana-0.10.3/.codeclimate.yml0000644000175100017510000000010114002345121014736 0ustar pravipravilanguages: Ruby: true exclude_paths: - "lib/asana/resources/*"