asana 2.0.0 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/build.yml +1 -1
  3. data/.rubocop.yml +38 -3
  4. data/.ruby-version +1 -1
  5. data/Appraisals +8 -3
  6. data/Gemfile +7 -3
  7. data/Gemfile.lock +54 -64
  8. data/Guardfile +12 -10
  9. data/README.md +24 -12
  10. data/Rakefile +14 -17
  11. data/VERSION +1 -1
  12. data/asana.gemspec +20 -18
  13. data/examples/cli_app.rb +2 -2
  14. data/examples/events.rb +3 -3
  15. data/examples/personal_access_token.rb +2 -2
  16. data/lib/asana/authentication/oauth2/access_token_authentication.rb +4 -1
  17. data/lib/asana/authentication/oauth2/bearer_token_authentication.rb +3 -2
  18. data/lib/asana/authentication/oauth2/client.rb +2 -0
  19. data/lib/asana/authentication/oauth2.rb +6 -4
  20. data/lib/asana/authentication/token_authentication.rb +3 -1
  21. data/lib/asana/authentication.rb +2 -0
  22. data/lib/asana/client/configuration.rb +6 -5
  23. data/lib/asana/client.rb +13 -11
  24. data/lib/asana/errors.rb +16 -11
  25. data/lib/asana/http_client/environment_info.rb +9 -8
  26. data/lib/asana/http_client/error_handling.rb +23 -24
  27. data/lib/asana/http_client/response.rb +2 -0
  28. data/lib/asana/http_client.rb +66 -65
  29. data/lib/asana/resource_includes/attachment_uploading.rb +6 -6
  30. data/lib/asana/resource_includes/collection.rb +4 -4
  31. data/lib/asana/resource_includes/event.rb +2 -0
  32. data/lib/asana/resource_includes/event_subscription.rb +2 -0
  33. data/lib/asana/resource_includes/events.rb +4 -1
  34. data/lib/asana/resource_includes/registry.rb +2 -0
  35. data/lib/asana/resource_includes/resource.rb +8 -5
  36. data/lib/asana/resource_includes/response_helper.rb +2 -0
  37. data/lib/asana/resources/audit_log_api.rb +42 -0
  38. data/lib/asana/resources/gen/attachments_base.rb +1 -1
  39. data/lib/asana/resources/gen/audit_log_api_base.rb +1 -1
  40. data/lib/asana/resources/gen/memberships_base.rb +71 -0
  41. data/lib/asana/resources/gen/tasks_base.rb +1 -1
  42. data/lib/asana/resources/goal.rb +54 -0
  43. data/lib/asana/resources/goal_relationship.rb +32 -0
  44. data/lib/asana/resources/membership.rb +20 -0
  45. data/lib/asana/resources/project_brief.rb +30 -0
  46. data/lib/asana/resources/project_template.rb +36 -0
  47. data/lib/asana/resources/status_update.rb +54 -0
  48. data/lib/asana/resources/time_period.rb +30 -0
  49. data/lib/asana/resources/typeahead.rb +1 -1
  50. data/lib/asana/resources.rb +4 -4
  51. data/lib/asana/ruby2_0_0_compatibility.rb +2 -0
  52. data/lib/asana/version.rb +1 -1
  53. data/lib/asana.rb +2 -0
  54. data/samples/memberships_sample.yaml +41 -0
  55. metadata +57 -46
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'registry'
2
4
  require_relative 'response_helper'
3
5
 
@@ -21,6 +23,7 @@ module Asana
21
23
  def refresh
22
24
  raise "#{self.class.name} does not respond to #find_by_id" unless \
23
25
  self.class.respond_to?(:find_by_id)
26
+
24
27
  self.class.find_by_id(client, gid)
25
28
  end
26
29
 
@@ -30,17 +33,17 @@ module Asana
30
33
  # Returns the value for the requested property.
31
34
  #
32
35
  # Raises a NoMethodError if the property doesn't exist.
33
- def method_missing(m, *args)
34
- super unless respond_to_missing?(m, *args)
35
- cache(m, wrapped(to_h[m.to_s]))
36
+ def method_missing(method_name, *args)
37
+ super unless respond_to_missing?(method_name, *args)
38
+ cache(method_name, wrapped(to_h[method_name.to_s]))
36
39
  end
37
40
 
38
41
  # Internal: Guard for the method_missing proxy. Checks if the resource
39
42
  # actually has a specific piece of data at all.
40
43
  #
41
44
  # Returns true if the resource has the property, false otherwise.
42
- def respond_to_missing?(m, *)
43
- to_h.key?(m.to_s)
45
+ def respond_to_missing?(method_name, *)
46
+ to_h.key?(method_name.to_s)
44
47
  end
45
48
 
46
49
  # Public:
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Asana
2
4
  module Resources
3
5
  # Internal: A helper to make response body parsing easier.
@@ -0,0 +1,42 @@
1
+ require_relative 'gen/audit_log_api_base'
2
+
3
+ module Asana
4
+ module Resources
5
+ class AuditLogAPI < AuditLogAPIBase
6
+
7
+
8
+ attr_reader :gid
9
+
10
+ attr_reader :actor
11
+
12
+ attr_reader :context
13
+
14
+ attr_reader :api_authentication_method
15
+
16
+ attr_reader :client_ip_address
17
+
18
+ attr_reader :context_type
19
+
20
+ attr_reader :oauth_app_name
21
+
22
+ attr_reader :user_agent
23
+
24
+ attr_reader :created_at
25
+
26
+ attr_reader :details
27
+
28
+ attr_reader :event_category
29
+
30
+ attr_reader :event_type
31
+
32
+ attr_reader :resource
33
+
34
+ class << self
35
+ # Returns the plural name of the resource.
36
+ def plural_name
37
+ 'audit_log_apis'
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -39,7 +39,7 @@ module Asana
39
39
  # Get attachments from an object
40
40
  #
41
41
 
42
- # parent - [str] (required) Globally unique identifier for object to fetch statuses from. Must be a GID for a task, project, or project_brief.
42
+ # parent - [str] (required) Globally unique identifier for object to fetch statuses from. Must be a GID for a `project`, `project_brief`, or `task`.
43
43
  # options - [Hash] the request I/O options
44
44
  # > 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.'
45
45
  # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100.
@@ -17,7 +17,7 @@ module Asana
17
17
  # workspace_gid - [str] (required) Globally unique identifier for the workspace or organization.
18
18
  # start_at - [datetime] Filter to events created after this time (inclusive).
19
19
  # end_at - [datetime] Filter to events created before this time (exclusive).
20
- # event_type - [str] Filter to events of this type. Refer to the [Supported AuditLogEvents](/docs/supported-auditlogevents) for a full list of values.
20
+ # event_type - [str] Filter to events of this type. Refer to the [supported audit log events](/docs/audit-log-events#supported-audit-log-events) for a full list of values.
21
21
  # actor_type - [str] Filter to events with an actor of this type. This only needs to be included if querying for actor types without an ID. If `actor_gid` is included, this should be excluded.
22
22
  # actor_gid - [str] Filter to events triggered by the actor with this ID.
23
23
  # resource_gid - [str] Filter to events with this resource ID.
@@ -0,0 +1,71 @@
1
+ ### WARNING: This file is auto-generated by our OpenAPI spec. Do not
2
+ ### edit it manually.
3
+
4
+ require_relative '../../resource_includes/response_helper'
5
+
6
+ module Asana
7
+ module Resources
8
+ class MembershipsBase < Resource
9
+
10
+ def self.inherited(base)
11
+ Registry.register(base)
12
+ end
13
+
14
+ class << self
15
+ # Create a membership
16
+ #
17
+
18
+ # options - [Hash] the request I/O options
19
+ # > 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.
20
+ # > 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.
21
+ # data - [Hash] the attributes to POST
22
+ def create_membership(client, options: {}, **data)
23
+ path = "/memberships"
24
+ parse(client.post(path, body: data, options: options)).first
25
+ end
26
+
27
+ # Delete a membership
28
+ #
29
+ # membership_gid - [str] (required) Globally unique identifier for the membership.
30
+ # options - [Hash] the request I/O options
31
+ # > 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.
32
+ # > 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.
33
+ def delete_membership(client, membership_gid: required("membership_gid"), options: {})
34
+ path = "/memberships/{membership_gid}"
35
+ path["{membership_gid}"] = membership_gid
36
+ parse(client.delete(path, options: options)).first
37
+ end
38
+
39
+ # Get multiple memberships
40
+ #
41
+
42
+ # parent - [str] (required) Globally unique identifier for `project`, `portfolio`, `team`, `goal`, and `workspace`.
43
+ # member - [str] Globally unique identifier for `team` and `user`.
44
+ # options - [Hash] the request I/O options
45
+ # > 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.'
46
+ # > limit - [int] Pagination limit for the request.
47
+ # > 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.
48
+ # > 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.
49
+ def get_memberships(client, parent: nil, member: nil, options: {})
50
+ path = "/memberships"
51
+ params = { parent: parent, member: member }.reject { |_,v| v.nil? || Array(v).empty? }
52
+ Collection.new(parse(client.get(path, params: params, options: options)), type: Resource, client: client)
53
+ end
54
+
55
+ # Update a membership
56
+ #
57
+ # membership_gid - [str] (required) Globally unique identifier for the membership.
58
+ # options - [Hash] the request I/O options
59
+ # > 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.
60
+ # > 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.
61
+ # data - [Hash] the attributes to PUT
62
+ def update_membership(client, membership_gid: required("membership_gid"), options: {}, **data)
63
+ path = "/memberships/{membership_gid}"
64
+ path["{membership_gid}"] = membership_gid
65
+ parse(client.put(path, body: data, options: options)).first
66
+ end
67
+
68
+ end
69
+ end
70
+ end
71
+ end
@@ -186,7 +186,7 @@ module Asana
186
186
 
187
187
  # assignee - [str] The assignee to filter tasks on. If searching for unassigned tasks, assignee.any = null can be specified. *Note: If you specify `assignee`, you must also specify the `workspace` to filter on.*
188
188
  # project - [str] The project to filter tasks on.
189
- # section - [str] The section to filter tasks on. *Note: Currently, this is only supported in board views.*
189
+ # section - [str] The section to filter tasks on.
190
190
  # workspace - [str] The workspace to filter tasks on. *Note: If you specify `workspace`, you must also specify the `assignee` to filter on.*
191
191
  # completed_since - [datetime] Only return tasks that are either incomplete or that have been completed since this time.
192
192
  # 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.*
@@ -0,0 +1,54 @@
1
+ require_relative 'gen/goals_base'
2
+
3
+ module Asana
4
+ module Resources
5
+ class Goal < GoalsBase
6
+
7
+
8
+ attr_reader :gid
9
+
10
+ attr_reader :resource_type
11
+
12
+ attr_reader :due_on
13
+
14
+ attr_reader :html_notes
15
+
16
+ attr_reader :is_workspace_level
17
+
18
+ attr_reader :liked
19
+
20
+ attr_reader :name
21
+
22
+ attr_reader :notes
23
+
24
+ attr_reader :start_on
25
+
26
+ attr_reader :status
27
+
28
+ attr_reader :current_status_update
29
+
30
+ attr_reader :followers
31
+
32
+ attr_reader :likes
33
+
34
+ attr_reader :metric
35
+
36
+ attr_reader :num_likes
37
+
38
+ attr_reader :owner
39
+
40
+ attr_reader :team
41
+
42
+ attr_reader :time_period
43
+
44
+ attr_reader :workspace
45
+
46
+ class << self
47
+ # Returns the plural name of the resource.
48
+ def plural_name
49
+ 'goals'
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,32 @@
1
+ require_relative 'gen/goal_relationships_base'
2
+
3
+ module Asana
4
+ module Resources
5
+ class GoalRelationship < GoalRelationshipsBase
6
+
7
+
8
+ attr_reader :gid
9
+
10
+ attr_reader :resource_type
11
+
12
+ attr_reader :contribution_weight
13
+
14
+ attr_reader :resource_subtype
15
+
16
+ attr_reader :supported_goal
17
+
18
+ attr_reader :owner
19
+
20
+ attr_reader :supporting_resource
21
+
22
+ attr_reader :supporting_resource
23
+
24
+ class << self
25
+ # Returns the plural name of the resource.
26
+ def plural_name
27
+ 'goal_relationships'
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,20 @@
1
+ require_relative 'gen/memberships_base'
2
+
3
+ module Asana
4
+ module Resources
5
+ class Membership < MembershipsBase
6
+
7
+
8
+ attr_reader :gid
9
+
10
+ attr_reader :resource_type
11
+
12
+ class << self
13
+ # Returns the plural name of the resource.
14
+ def plural_name
15
+ 'memberships'
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,30 @@
1
+ require_relative 'gen/project_briefs_base'
2
+
3
+ module Asana
4
+ module Resources
5
+ class ProjectBrief < ProjectBriefsBase
6
+
7
+
8
+ attr_reader :gid
9
+
10
+ attr_reader :resource_type
11
+
12
+ attr_reader :html_text
13
+
14
+ attr_reader :title
15
+
16
+ attr_reader :permalink_url
17
+
18
+ attr_reader :project
19
+
20
+ attr_reader :text
21
+
22
+ class << self
23
+ # Returns the plural name of the resource.
24
+ def plural_name
25
+ 'project_briefs'
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,36 @@
1
+ require_relative 'gen/project_templates_base'
2
+
3
+ module Asana
4
+ module Resources
5
+ class ProjectTemplate < ProjectTemplatesBase
6
+
7
+
8
+ attr_reader :gid
9
+
10
+ attr_reader :resource_type
11
+
12
+ attr_reader :color
13
+
14
+ attr_reader :description
15
+
16
+ attr_reader :html_description
17
+
18
+ attr_reader :name
19
+
20
+ attr_reader :owner
21
+
22
+ attr_reader :public
23
+
24
+ attr_reader :requested_dates
25
+
26
+ attr_reader :team
27
+
28
+ class << self
29
+ # Returns the plural name of the resource.
30
+ def plural_name
31
+ 'project_templates'
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,54 @@
1
+ require_relative 'gen/status_updates_base'
2
+
3
+ module Asana
4
+ module Resources
5
+ class StatusUpdate < StatusUpdatesBase
6
+
7
+
8
+ attr_reader :gid
9
+
10
+ attr_reader :resource_type
11
+
12
+ attr_reader :html_text
13
+
14
+ attr_reader :resource_subtype
15
+
16
+ attr_reader :status_type
17
+
18
+ attr_reader :text
19
+
20
+ attr_reader :title
21
+
22
+ attr_reader :author
23
+
24
+ attr_reader :created_at
25
+
26
+ attr_reader :created_by
27
+
28
+ attr_reader :hearted
29
+
30
+ attr_reader :hearts
31
+
32
+ attr_reader :liked
33
+
34
+ attr_reader :likes
35
+
36
+ attr_reader :created_at
37
+
38
+ attr_reader :modified_at
39
+
40
+ attr_reader :num_hearts
41
+
42
+ attr_reader :num_likes
43
+
44
+ attr_reader :parent
45
+
46
+ class << self
47
+ # Returns the plural name of the resource.
48
+ def plural_name
49
+ 'status_updates'
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,30 @@
1
+ require_relative 'gen/time_periods_base'
2
+
3
+ module Asana
4
+ module Resources
5
+ class TimePeriod < TimePeriodsBase
6
+
7
+
8
+ attr_reader :gid
9
+
10
+ attr_reader :resource_type
11
+
12
+ attr_reader :display_name
13
+
14
+ attr_reader :end_on
15
+
16
+ attr_reader :parent
17
+
18
+ attr_reader :period
19
+
20
+ attr_reader :start_on
21
+
22
+ class << self
23
+ # Returns the plural name of the resource.
24
+ def plural_name
25
+ 'time_periods'
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -14,7 +14,7 @@ module Asana
14
14
  class << self
15
15
  # Returns the plural name of the resource.
16
16
  def plural_name
17
- 'typeaheads'
17
+ 'typeahead'
18
18
  end
19
19
  end
20
20
  end
@@ -1,11 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'resource_includes/resource'
2
4
  require_relative 'resource_includes/collection'
3
5
 
4
- Dir[File.join(File.dirname(__FILE__), 'resource_includes', '*.rb')]
5
- .each { |resource| require resource }
6
+ Dir[File.join(File.dirname(__FILE__), 'resource_includes', '*.rb')].sort.each { |resource| require resource }
6
7
 
7
- Dir[File.join(File.dirname(__FILE__), 'resources', '*.rb')]
8
- .each { |resource| require resource }
8
+ Dir[File.join(File.dirname(__FILE__), 'resources', '*.rb')].sort.each { |resource| require resource }
9
9
 
10
10
  module Asana
11
11
  # Public: Contains all the resources that the Asana API can return.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  def required(name)
2
4
  raise(ArgumentError, "#{name} is a required keyword argument")
3
5
  end
data/lib/asana/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  #:nodoc:
2
2
  module Asana
3
3
  # Public: Version of the gem.
4
- VERSION = '2.0.0'
4
+ VERSION = '2.0.2'
5
5
  end
data/lib/asana.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'asana/ruby2_0_0_compatibility'
2
4
  require 'asana/authentication'
3
5
  require 'asana/resources'
@@ -0,0 +1,41 @@
1
+ memberships:
2
+ create_membership: >-
3
+ require 'asana'
4
+
5
+
6
+ client = Asana::Client.new do |c|
7
+ c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN'
8
+ end
9
+
10
+
11
+ result = client.memberships.create_membership(field: "value", field: "value", options: {pretty: true})
12
+ delete_membership: >-
13
+ require 'asana'
14
+
15
+
16
+ client = Asana::Client.new do |c|
17
+ c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN'
18
+ end
19
+
20
+
21
+ result = client.memberships.delete_membership(membership_gid: 'membership_gid', options: {pretty: true})
22
+ get_memberships: >-
23
+ require 'asana'
24
+
25
+
26
+ client = Asana::Client.new do |c|
27
+ c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN'
28
+ end
29
+
30
+
31
+ result = client.memberships.get_memberships(parent: '&#x27;parent_example&#x27;', param: "value", param: "value", options: {pretty: true})
32
+ update_membership: >-
33
+ require 'asana'
34
+
35
+
36
+ client = Asana::Client.new do |c|
37
+ c.authentication :access_token, 'PERSONAL_ACCESS_TOKEN'
38
+ end
39
+
40
+
41
+ result = client.memberships.update_membership(membership_gid: 'membership_gid', field: "value", field: "value", options: {pretty: true})