asana 0.8.1 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.ruby-version +1 -0
- data/README.md +19 -1
- data/asana.gemspec +0 -1
- data/lib/asana/client.rb +6 -4
- data/lib/asana/client/configuration.rb +17 -1
- data/lib/asana/http_client.rb +98 -11
- data/lib/asana/http_client/response.rb +4 -0
- data/lib/asana/resource_includes/attachment_uploading.rb +1 -1
- data/lib/asana/resource_includes/event_subscription.rb +1 -1
- data/lib/asana/resource_includes/resource.rb +1 -1
- data/lib/asana/resources/attachment.rb +6 -2
- data/lib/asana/resources/custom_field_settings.rb +24 -7
- data/lib/asana/resources/custom_fields.rb +42 -20
- data/lib/asana/resources/job.rb +43 -0
- data/lib/asana/resources/organization_export.rb +4 -2
- data/lib/asana/resources/portfolio.rb +206 -0
- data/lib/asana/resources/portfolio_membership.rb +63 -0
- data/lib/asana/resources/project.rb +74 -32
- data/lib/asana/resources/project_membership.rb +11 -5
- data/lib/asana/resources/project_status.rb +12 -5
- data/lib/asana/resources/section.rb +28 -8
- data/lib/asana/resources/story.rb +11 -15
- data/lib/asana/resources/tag.rb +13 -9
- data/lib/asana/resources/task.rb +135 -60
- data/lib/asana/resources/team.rb +13 -3
- data/lib/asana/resources/user.rb +15 -0
- data/lib/asana/resources/user_task_list.rb +93 -0
- data/lib/asana/resources/webhook.rb +7 -1
- data/lib/asana/resources/workspace.rb +13 -7
- data/lib/asana/version.rb +1 -1
- metadata +12 -22
@@ -0,0 +1,43 @@
|
|
1
|
+
### WARNING: This file is auto-generated by the asana-api-meta repo. Do not
|
2
|
+
### edit it manually.
|
3
|
+
|
4
|
+
module Asana
|
5
|
+
module Resources
|
6
|
+
# A _job_ represents a process that handles asynchronous work.
|
7
|
+
#
|
8
|
+
# Jobs are created when an endpoint requests an action that will be handled asynchronously.
|
9
|
+
# Such as project or task duplication.
|
10
|
+
class Job < Resource
|
11
|
+
|
12
|
+
|
13
|
+
attr_reader :gid
|
14
|
+
|
15
|
+
attr_reader :resource_type
|
16
|
+
|
17
|
+
attr_reader :resource_subtype
|
18
|
+
|
19
|
+
attr_reader :status
|
20
|
+
|
21
|
+
attr_reader :new_project
|
22
|
+
|
23
|
+
attr_reader :new_task
|
24
|
+
|
25
|
+
class << self
|
26
|
+
# Returns the plural name of the resource.
|
27
|
+
def plural_name
|
28
|
+
'jobs'
|
29
|
+
end
|
30
|
+
|
31
|
+
# Returns the complete job record for a single job.
|
32
|
+
#
|
33
|
+
# id - [Gid] The job to get.
|
34
|
+
# options - [Hash] the request I/O options.
|
35
|
+
def find_by_id(client, id, options: {})
|
36
|
+
|
37
|
+
self.new(parse(client.get("/jobs/#{id}", options: options)).first, client: client)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -21,6 +21,8 @@ module Asana
|
|
21
21
|
|
22
22
|
attr_reader :id
|
23
23
|
|
24
|
+
attr_reader :gid
|
25
|
+
|
24
26
|
attr_reader :created_at
|
25
27
|
|
26
28
|
attr_reader :download_url
|
@@ -37,7 +39,7 @@ module Asana
|
|
37
39
|
|
38
40
|
# Returns details of a previously-requested Organization export.
|
39
41
|
#
|
40
|
-
# id - [
|
42
|
+
# id - [Gid] Globally unique identifier for the Organization export.
|
41
43
|
#
|
42
44
|
# options - [Hash] the request I/O options.
|
43
45
|
def find_by_id(client, id, options: {})
|
@@ -48,7 +50,7 @@ module Asana
|
|
48
50
|
# This method creates a request to export an Organization. Asana will complete the export at some
|
49
51
|
# point after you create the request.
|
50
52
|
#
|
51
|
-
# organization - [
|
53
|
+
# organization - [Gid] Globally unique identifier for the workspace or organization.
|
52
54
|
#
|
53
55
|
# options - [Hash] the request I/O options.
|
54
56
|
# data - [Hash] the attributes to post.
|
@@ -0,0 +1,206 @@
|
|
1
|
+
### WARNING: This file is auto-generated by the asana-api-meta repo. Do not
|
2
|
+
### edit it manually.
|
3
|
+
|
4
|
+
module Asana
|
5
|
+
module Resources
|
6
|
+
# A _portfolio_ gives a high-level overview of the status of multiple
|
7
|
+
# initiatives in Asana. Portfolios provide a dashboard overview of the state
|
8
|
+
# of multiple items, including a progress report and the most recent
|
9
|
+
# [project status](/developers/api-reference/project_statuses) update.
|
10
|
+
#
|
11
|
+
# Portfolios have some restrictions on size. Each portfolio has a maximum of 250
|
12
|
+
# items and, like projects, a maximum of 20 custom fields.
|
13
|
+
class Portfolio < Resource
|
14
|
+
|
15
|
+
|
16
|
+
attr_reader :id
|
17
|
+
|
18
|
+
attr_reader :gid
|
19
|
+
|
20
|
+
attr_reader :resource_type
|
21
|
+
|
22
|
+
attr_reader :name
|
23
|
+
|
24
|
+
attr_reader :owner
|
25
|
+
|
26
|
+
attr_reader :created_at
|
27
|
+
|
28
|
+
attr_reader :created_by
|
29
|
+
|
30
|
+
attr_reader :custom_field_settings
|
31
|
+
|
32
|
+
attr_reader :color
|
33
|
+
|
34
|
+
attr_reader :workspace
|
35
|
+
|
36
|
+
attr_reader :members
|
37
|
+
|
38
|
+
class << self
|
39
|
+
# Returns the plural name of the resource.
|
40
|
+
def plural_name
|
41
|
+
'portfolios'
|
42
|
+
end
|
43
|
+
|
44
|
+
# Creates a new portfolio in the given workspace with the supplied name.
|
45
|
+
#
|
46
|
+
# Note that portfolios created in the Asana UI may have some state
|
47
|
+
# (like the "Priority" custom field) which is automatically added to the
|
48
|
+
# portfolio when it is created. Portfolios created via our API will **not**
|
49
|
+
# be created with the same initial state to allow integrations to create
|
50
|
+
# their own starting state on a portfolio.
|
51
|
+
#
|
52
|
+
# workspace - [Gid] The workspace or organization in which to create the portfolio.
|
53
|
+
# name - [String] The name of the newly-created portfolio
|
54
|
+
# color - [String] An optional color for the portfolio
|
55
|
+
# options - [Hash] the request I/O options.
|
56
|
+
# data - [Hash] the attributes to post.
|
57
|
+
def create(client, workspace: required("workspace"), name: required("name"), color: nil, options: {}, **data)
|
58
|
+
with_params = data.merge(workspace: workspace, name: name, color: color).reject { |_,v| v.nil? || Array(v).empty? }
|
59
|
+
self.new(parse(client.post("/portfolios", body: with_params, options: options)).first, client: client)
|
60
|
+
end
|
61
|
+
|
62
|
+
# Returns the complete record for a single portfolio.
|
63
|
+
#
|
64
|
+
# id - [Gid] The portfolio to get.
|
65
|
+
# options - [Hash] the request I/O options.
|
66
|
+
def find_by_id(client, id, options: {})
|
67
|
+
|
68
|
+
self.new(parse(client.get("/portfolios/#{id}", options: options)).first, client: client)
|
69
|
+
end
|
70
|
+
|
71
|
+
# Returns a list of the portfolios in compact representation that are owned
|
72
|
+
# by the current API user.
|
73
|
+
#
|
74
|
+
# workspace - [Gid] The workspace or organization to filter portfolios on.
|
75
|
+
# owner - [String] The user who owns the portfolio. Currently, API users can only get a
|
76
|
+
# list of portfolios that they themselves own.
|
77
|
+
#
|
78
|
+
# per_page - [Integer] the number of records to fetch per page.
|
79
|
+
# options - [Hash] the request I/O options.
|
80
|
+
def find_all(client, workspace: required("workspace"), owner: required("owner"), per_page: 20, options: {})
|
81
|
+
params = { workspace: workspace, owner: owner, limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? }
|
82
|
+
Collection.new(parse(client.get("/portfolios", params: params, options: options)), type: self, client: client)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
# An existing portfolio can be updated by making a PUT request on the
|
87
|
+
# URL for that portfolio. Only the fields provided in the `data` block will be
|
88
|
+
# updated; any unspecified fields will remain unchanged.
|
89
|
+
#
|
90
|
+
# Returns the complete updated portfolio record.
|
91
|
+
#
|
92
|
+
# options - [Hash] the request I/O options.
|
93
|
+
# data - [Hash] the attributes to post.
|
94
|
+
def update(options: {}, **data)
|
95
|
+
|
96
|
+
refresh_with(parse(client.put("/portfolios/#{gid}", body: data, options: options)).first)
|
97
|
+
end
|
98
|
+
|
99
|
+
# An existing portfolio can be deleted by making a DELETE request
|
100
|
+
# on the URL for that portfolio.
|
101
|
+
#
|
102
|
+
# Returns an empty data record.
|
103
|
+
def delete()
|
104
|
+
|
105
|
+
client.delete("/portfolios/#{gid}") && true
|
106
|
+
end
|
107
|
+
|
108
|
+
# Get a list of the items in compact form in a portfolio.
|
109
|
+
#
|
110
|
+
# options - [Hash] the request I/O options.
|
111
|
+
def get_items(options: {})
|
112
|
+
|
113
|
+
Collection.new(parse(client.get("/portfolios/#{gid}/items", options: options)), type: self, client: client)
|
114
|
+
end
|
115
|
+
|
116
|
+
# Add an item to a portfolio.
|
117
|
+
#
|
118
|
+
# Returns an empty data block.
|
119
|
+
#
|
120
|
+
# item - [Gid] The item to add to the portfolio.
|
121
|
+
# insert_before - [Gid] An id of an item in this portfolio. The new item will be added before the one specified here.
|
122
|
+
# `insert_before` and `insert_after` parameters cannot both be specified.
|
123
|
+
#
|
124
|
+
# insert_after - [Gid] An id of an item in this portfolio. The new item will be added after the one specified here.
|
125
|
+
# `insert_before` and `insert_after` parameters cannot both be specified.
|
126
|
+
#
|
127
|
+
# options - [Hash] the request I/O options.
|
128
|
+
# data - [Hash] the attributes to post.
|
129
|
+
def add_item(item: required("item"), insert_before: nil, insert_after: nil, options: {}, **data)
|
130
|
+
with_params = data.merge(item: item, insert_before: insert_before, insert_after: insert_after).reject { |_,v| v.nil? || Array(v).empty? }
|
131
|
+
client.post("/portfolios/#{gid}/addItem", body: with_params, options: options) && true
|
132
|
+
end
|
133
|
+
|
134
|
+
# Remove an item to a portfolio.
|
135
|
+
#
|
136
|
+
# Returns an empty data block.
|
137
|
+
#
|
138
|
+
# item - [Gid] The item to remove from the portfolio.
|
139
|
+
# options - [Hash] the request I/O options.
|
140
|
+
# data - [Hash] the attributes to post.
|
141
|
+
def remove_item(item: required("item"), options: {}, **data)
|
142
|
+
with_params = data.merge(item: item).reject { |_,v| v.nil? || Array(v).empty? }
|
143
|
+
client.post("/portfolios/#{gid}/removeItem", body: with_params, options: options) && true
|
144
|
+
end
|
145
|
+
|
146
|
+
# Adds the specified list of users as members of the portfolio. Returns the updated portfolio record.
|
147
|
+
#
|
148
|
+
# members - [Array] An array of user ids.
|
149
|
+
# options - [Hash] the request I/O options.
|
150
|
+
# data - [Hash] the attributes to post.
|
151
|
+
def add_members(members: required("members"), options: {}, **data)
|
152
|
+
with_params = data.merge(members: members).reject { |_,v| v.nil? || Array(v).empty? }
|
153
|
+
refresh_with(parse(client.post("/portfolios/#{gid}/addMembers", body: with_params, options: options)).first)
|
154
|
+
end
|
155
|
+
|
156
|
+
# Removes the specified list of members from the portfolio. Returns the updated portfolio record.
|
157
|
+
#
|
158
|
+
# members - [Array] An array of user ids.
|
159
|
+
# options - [Hash] the request I/O options.
|
160
|
+
# data - [Hash] the attributes to post.
|
161
|
+
def remove_members(members: required("members"), options: {}, **data)
|
162
|
+
with_params = data.merge(members: members).reject { |_,v| v.nil? || Array(v).empty? }
|
163
|
+
refresh_with(parse(client.post("/portfolios/#{gid}/removeMembers", body: with_params, options: options)).first)
|
164
|
+
end
|
165
|
+
|
166
|
+
# Get the custom field settings on a portfolio.
|
167
|
+
#
|
168
|
+
# options - [Hash] the request I/O options.
|
169
|
+
def custom_field_settings(options: {})
|
170
|
+
|
171
|
+
Collection.new(parse(client.get("/portfolios/#{gid}/custom_field_settings", options: options)), type: self, client: client)
|
172
|
+
end
|
173
|
+
|
174
|
+
# Create a new custom field setting on the portfolio. Returns the full
|
175
|
+
# record for the new custom field setting.
|
176
|
+
#
|
177
|
+
# custom_field - [Gid] The id of the custom field to add to the portfolio.
|
178
|
+
# 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).
|
179
|
+
#
|
180
|
+
# insert_before - [Gid] An id of a custom field setting on this portfolio. The new custom field setting will be added before this one.
|
181
|
+
# `insert_before` and `insert_after` parameters cannot both be specified.
|
182
|
+
#
|
183
|
+
# insert_after - [Gid] An id of a custom field setting on this portfolio. The new custom field setting will be added after this one.
|
184
|
+
# `insert_before` and `insert_after` parameters cannot both be specified.
|
185
|
+
#
|
186
|
+
# options - [Hash] the request I/O options.
|
187
|
+
# data - [Hash] the attributes to post.
|
188
|
+
def add_custom_field_setting(custom_field: required("custom_field"), is_important: nil, insert_before: nil, insert_after: nil, options: {}, **data)
|
189
|
+
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? }
|
190
|
+
Resource.new(parse(client.post("/portfolios/#{gid}/addCustomFieldSetting", body: with_params, options: options)).first, client: client)
|
191
|
+
end
|
192
|
+
|
193
|
+
# Remove a custom field setting on the portfolio. Returns an empty data
|
194
|
+
# block.
|
195
|
+
#
|
196
|
+
# custom_field - [Gid] The id of the custom field to remove from this portfolio.
|
197
|
+
# options - [Hash] the request I/O options.
|
198
|
+
# data - [Hash] the attributes to post.
|
199
|
+
def remove_custom_field_setting(custom_field: required("custom_field"), options: {}, **data)
|
200
|
+
with_params = data.merge(custom_field: custom_field).reject { |_,v| v.nil? || Array(v).empty? }
|
201
|
+
client.post("/portfolios/#{gid}/removeCustomFieldSetting", body: with_params, options: options) && true
|
202
|
+
end
|
203
|
+
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
### WARNING: This file is auto-generated by the asana-api-meta repo. Do not
|
2
|
+
### edit it manually.
|
3
|
+
|
4
|
+
module Asana
|
5
|
+
module Resources
|
6
|
+
# This object determines if a user is a member of a portfolio.
|
7
|
+
class PortfolioMembership < Resource
|
8
|
+
|
9
|
+
|
10
|
+
attr_reader :id
|
11
|
+
|
12
|
+
attr_reader :gid
|
13
|
+
|
14
|
+
attr_reader :resource_type
|
15
|
+
|
16
|
+
attr_reader :user
|
17
|
+
|
18
|
+
attr_reader :portfolio
|
19
|
+
|
20
|
+
class << self
|
21
|
+
# Returns the plural name of the resource.
|
22
|
+
def plural_name
|
23
|
+
'portfolio_memberships'
|
24
|
+
end
|
25
|
+
|
26
|
+
# Returns the compact portfolio membership records for the portfolio. You must
|
27
|
+
# specify `portfolio`, `portfolio` and `user`, or `workspace` and `user`.
|
28
|
+
#
|
29
|
+
# portfolio - [Gid] The portfolio for which to fetch memberships.
|
30
|
+
# workspace - [Gid] The workspace for which to fetch memberships.
|
31
|
+
# user - [String] The user to filter the memberships to.
|
32
|
+
# per_page - [Integer] the number of records to fetch per page.
|
33
|
+
# options - [Hash] the request I/O options.
|
34
|
+
def find_all(client, portfolio: nil, workspace: nil, user: nil, per_page: 20, options: {})
|
35
|
+
params = { portfolio: portfolio, workspace: workspace, user: user, limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? }
|
36
|
+
Collection.new(parse(client.get("/portfolio_memberships", params: params, options: options)), type: Resource, client: client)
|
37
|
+
end
|
38
|
+
|
39
|
+
# Returns the compact portfolio membership records for the portfolio.
|
40
|
+
#
|
41
|
+
# portfolio - [Gid] The portfolio for which to fetch memberships.
|
42
|
+
# user - [String] If present, the user to filter the memberships to.
|
43
|
+
# per_page - [Integer] the number of records to fetch per page.
|
44
|
+
# options - [Hash] the request I/O options.
|
45
|
+
def find_by_portfolio(client, portfolio: required("portfolio"), user: nil, per_page: 20, options: {})
|
46
|
+
params = { user: user, limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? }
|
47
|
+
Collection.new(parse(client.get("/portfolios/#{portfolio}/portfolio_memberships", params: params, options: options)), type: Resource, client: client)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Returns the portfolio membership record.
|
51
|
+
#
|
52
|
+
# id - [Gid] Globally unique identifier for the portfolio membership.
|
53
|
+
#
|
54
|
+
# options - [Hash] the request I/O options.
|
55
|
+
def find_by_id(client, id, options: {})
|
56
|
+
|
57
|
+
self.new(parse(client.get("/portfolio_memberships/#{id}", options: options)).first, client: client)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -17,16 +17,22 @@ module Asana
|
|
17
17
|
include EventSubscription
|
18
18
|
|
19
19
|
|
20
|
-
attr_reader :name
|
21
|
-
|
22
20
|
attr_reader :id
|
23
21
|
|
22
|
+
attr_reader :gid
|
23
|
+
|
24
|
+
attr_reader :resource_type
|
25
|
+
|
26
|
+
attr_reader :name
|
27
|
+
|
24
28
|
attr_reader :owner
|
25
29
|
|
26
30
|
attr_reader :current_status
|
27
31
|
|
28
32
|
attr_reader :due_date
|
29
33
|
|
34
|
+
attr_reader :due_on
|
35
|
+
|
30
36
|
attr_reader :start_on
|
31
37
|
|
32
38
|
attr_reader :created_at
|
@@ -41,12 +47,16 @@ module Asana
|
|
41
47
|
|
42
48
|
attr_reader :followers
|
43
49
|
|
50
|
+
attr_reader :custom_fields
|
51
|
+
|
44
52
|
attr_reader :custom_field_settings
|
45
53
|
|
46
54
|
attr_reader :color
|
47
55
|
|
48
56
|
attr_reader :notes
|
49
57
|
|
58
|
+
attr_reader :html_notes
|
59
|
+
|
50
60
|
attr_reader :workspace
|
51
61
|
|
52
62
|
attr_reader :team
|
@@ -71,8 +81,8 @@ module Asana
|
|
71
81
|
#
|
72
82
|
# Returns the full record of the newly created project.
|
73
83
|
#
|
74
|
-
# workspace - [
|
75
|
-
# team - [
|
84
|
+
# workspace - [Gid] The workspace or organization to create the project in.
|
85
|
+
# team - [Gid] If creating in an organization, the specific team to create the
|
76
86
|
# project in.
|
77
87
|
#
|
78
88
|
# options - [Hash] the request I/O options.
|
@@ -87,7 +97,7 @@ module Asana
|
|
87
97
|
#
|
88
98
|
# Returns the full record of the newly created project.
|
89
99
|
#
|
90
|
-
# workspace - [
|
100
|
+
# workspace - [Gid] The workspace or organization to create the project in.
|
91
101
|
# options - [Hash] the request I/O options.
|
92
102
|
# data - [Hash] the attributes to post.
|
93
103
|
def create_in_workspace(client, workspace: required("workspace"), options: {}, **data)
|
@@ -99,7 +109,7 @@ module Asana
|
|
99
109
|
#
|
100
110
|
# Returns the full record of the newly created project.
|
101
111
|
#
|
102
|
-
# team - [
|
112
|
+
# team - [Gid] The team to create the project in.
|
103
113
|
# options - [Hash] the request I/O options.
|
104
114
|
# data - [Hash] the attributes to post.
|
105
115
|
def create_in_team(client, team: required("team"), options: {}, **data)
|
@@ -109,7 +119,7 @@ module Asana
|
|
109
119
|
|
110
120
|
# Returns the complete project record for a single project.
|
111
121
|
#
|
112
|
-
# id - [
|
122
|
+
# id - [Gid] The project to get.
|
113
123
|
# options - [Hash] the request I/O options.
|
114
124
|
def find_by_id(client, id, options: {})
|
115
125
|
|
@@ -119,41 +129,49 @@ module Asana
|
|
119
129
|
# Returns the compact project records for some filtered set of projects.
|
120
130
|
# Use one or more of the parameters provided to filter the projects returned.
|
121
131
|
#
|
122
|
-
# workspace - [
|
123
|
-
# team - [
|
132
|
+
# workspace - [Gid] The workspace or organization to filter projects on.
|
133
|
+
# team - [Gid] The team to filter projects on.
|
134
|
+
# is_template - [Boolean] **Note: This parameter can only be included if a team is also defined, or the workspace is not an organization**
|
135
|
+
# Filters results to include only template projects.
|
136
|
+
#
|
124
137
|
# archived - [Boolean] Only return projects whose `archived` field takes on the value of
|
125
138
|
# this parameter.
|
126
139
|
#
|
127
140
|
# per_page - [Integer] the number of records to fetch per page.
|
128
141
|
# options - [Hash] the request I/O options.
|
129
|
-
def find_all(client, workspace: nil, team: nil, archived: nil, per_page: 20, options: {})
|
130
|
-
params = { workspace: workspace, team: team, archived: archived, limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? }
|
142
|
+
def find_all(client, workspace: nil, team: nil, is_template: nil, archived: nil, per_page: 20, options: {})
|
143
|
+
params = { workspace: workspace, team: team, is_template: is_template, archived: archived, limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? }
|
131
144
|
Collection.new(parse(client.get("/projects", params: params, options: options)), type: self, client: client)
|
132
145
|
end
|
133
146
|
|
134
147
|
# Returns the compact project records for all projects in the workspace.
|
135
148
|
#
|
136
|
-
# workspace - [
|
149
|
+
# workspace - [Gid] The workspace or organization to find projects in.
|
150
|
+
# is_template - [Boolean] **Note: This parameter can only be included if a team is also defined, or the workspace is not an organization**
|
151
|
+
# Filters results to include only template projects.
|
152
|
+
#
|
137
153
|
# archived - [Boolean] Only return projects whose `archived` field takes on the value of
|
138
154
|
# this parameter.
|
139
155
|
#
|
140
156
|
# per_page - [Integer] the number of records to fetch per page.
|
141
157
|
# options - [Hash] the request I/O options.
|
142
|
-
def find_by_workspace(client, workspace: required("workspace"), archived: nil, per_page: 20, options: {})
|
143
|
-
params = { archived: archived, limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? }
|
158
|
+
def find_by_workspace(client, workspace: required("workspace"), is_template: nil, archived: nil, per_page: 20, options: {})
|
159
|
+
params = { is_template: is_template, archived: archived, limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? }
|
144
160
|
Collection.new(parse(client.get("/workspaces/#{workspace}/projects", params: params, options: options)), type: self, client: client)
|
145
161
|
end
|
146
162
|
|
147
163
|
# Returns the compact project records for all projects in the team.
|
148
164
|
#
|
149
|
-
# team - [
|
165
|
+
# team - [Gid] The team to find projects in.
|
166
|
+
# is_template - [Boolean] Filters results to include only template projects.
|
167
|
+
#
|
150
168
|
# archived - [Boolean] Only return projects whose `archived` field takes on the value of
|
151
169
|
# this parameter.
|
152
170
|
#
|
153
171
|
# per_page - [Integer] the number of records to fetch per page.
|
154
172
|
# options - [Hash] the request I/O options.
|
155
|
-
def find_by_team(client, team: required("team"), archived: nil, per_page: 20, options: {})
|
156
|
-
params = { archived: archived, limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? }
|
173
|
+
def find_by_team(client, team: required("team"), is_template: nil, archived: nil, per_page: 20, options: {})
|
174
|
+
params = { is_template: is_template, archived: archived, limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? }
|
157
175
|
Collection.new(parse(client.get("/teams/#{team}/projects", params: params, options: options)), type: self, client: client)
|
158
176
|
end
|
159
177
|
end
|
@@ -172,7 +190,7 @@ module Asana
|
|
172
190
|
# data - [Hash] the attributes to post.
|
173
191
|
def update(options: {}, **data)
|
174
192
|
|
175
|
-
refresh_with(parse(client.put("/projects/#{
|
193
|
+
refresh_with(parse(client.put("/projects/#{gid}", body: data, options: options)).first)
|
176
194
|
end
|
177
195
|
|
178
196
|
# A specific, existing project can be deleted by making a DELETE request
|
@@ -181,7 +199,31 @@ module Asana
|
|
181
199
|
# Returns an empty data record.
|
182
200
|
def delete()
|
183
201
|
|
184
|
-
client.delete("/projects/#{
|
202
|
+
client.delete("/projects/#{gid}") && true
|
203
|
+
end
|
204
|
+
|
205
|
+
# Creates and returns a job that will asynchronously handle the duplication.
|
206
|
+
#
|
207
|
+
# name - [String] The name of the new project.
|
208
|
+
# team - [Gid] Sets the team of the new project. If team is not defined, the new project
|
209
|
+
# will be in the same team as the the original project.
|
210
|
+
#
|
211
|
+
# include - [Array] The elements that will be duplicated to the new project.
|
212
|
+
# Tasks are always included.
|
213
|
+
#
|
214
|
+
# schedule_dates - [String] A dictionary of options to auto-shift dates.
|
215
|
+
# `task_dates` must be included to use this option.
|
216
|
+
# Requires either `start_on` or `due_on`, but not both.
|
217
|
+
# `start_on` will set the first start date of the new
|
218
|
+
# project to the given date, while `due_on` will set the last due date
|
219
|
+
# to the given date. Both will offset the remaining dates by the same amount
|
220
|
+
# of the original project.
|
221
|
+
#
|
222
|
+
# options - [Hash] the request I/O options.
|
223
|
+
# data - [Hash] the attributes to post.
|
224
|
+
def duplicate_project(name: required("name"), team: nil, include: nil, schedule_dates: nil, options: {}, **data)
|
225
|
+
with_params = data.merge(name: name, team: team, include: include, schedule_dates: schedule_dates).reject { |_,v| v.nil? || Array(v).empty? }
|
226
|
+
Resource.new(parse(client.post("/projects/#{gid}/duplicate", body: with_params, options: options)).first, client: client)
|
185
227
|
end
|
186
228
|
|
187
229
|
# Returns the compact task records for all tasks within the given project,
|
@@ -191,7 +233,7 @@ module Asana
|
|
191
233
|
# options - [Hash] the request I/O options.
|
192
234
|
def tasks(per_page: 20, options: {})
|
193
235
|
params = { limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? }
|
194
|
-
Collection.new(parse(client.get("/projects/#{
|
236
|
+
Collection.new(parse(client.get("/projects/#{gid}/tasks", params: params, options: options)), type: Task, client: client)
|
195
237
|
end
|
196
238
|
|
197
239
|
# Adds the specified list of users as followers to the project. Followers are a subset of members, therefore if
|
@@ -203,7 +245,7 @@ module Asana
|
|
203
245
|
# data - [Hash] the attributes to post.
|
204
246
|
def add_followers(followers: required("followers"), options: {}, **data)
|
205
247
|
with_params = data.merge(followers: followers).reject { |_,v| v.nil? || Array(v).empty? }
|
206
|
-
refresh_with(parse(client.post("/projects/#{
|
248
|
+
refresh_with(parse(client.post("/projects/#{gid}/addFollowers", body: with_params, options: options)).first)
|
207
249
|
end
|
208
250
|
|
209
251
|
# Removes the specified list of users from following the project, this will not affect project membership status.
|
@@ -214,55 +256,55 @@ module Asana
|
|
214
256
|
# data - [Hash] the attributes to post.
|
215
257
|
def remove_followers(followers: required("followers"), options: {}, **data)
|
216
258
|
with_params = data.merge(followers: followers).reject { |_,v| v.nil? || Array(v).empty? }
|
217
|
-
refresh_with(parse(client.post("/projects/#{
|
259
|
+
refresh_with(parse(client.post("/projects/#{gid}/removeFollowers", body: with_params, options: options)).first)
|
218
260
|
end
|
219
261
|
|
220
262
|
# Adds the specified list of users as members of the project. Returns the updated project record.
|
221
263
|
#
|
222
|
-
# members - [Array] An array of
|
264
|
+
# members - [Array] An array of user ids.
|
223
265
|
# options - [Hash] the request I/O options.
|
224
266
|
# data - [Hash] the attributes to post.
|
225
267
|
def add_members(members: required("members"), options: {}, **data)
|
226
268
|
with_params = data.merge(members: members).reject { |_,v| v.nil? || Array(v).empty? }
|
227
|
-
refresh_with(parse(client.post("/projects/#{
|
269
|
+
refresh_with(parse(client.post("/projects/#{gid}/addMembers", body: with_params, options: options)).first)
|
228
270
|
end
|
229
271
|
|
230
272
|
# Removes the specified list of members from the project. Returns the updated project record.
|
231
273
|
#
|
232
|
-
# members - [Array] An array of
|
274
|
+
# members - [Array] An array of user ids.
|
233
275
|
# options - [Hash] the request I/O options.
|
234
276
|
# data - [Hash] the attributes to post.
|
235
277
|
def remove_members(members: required("members"), options: {}, **data)
|
236
278
|
with_params = data.merge(members: members).reject { |_,v| v.nil? || Array(v).empty? }
|
237
|
-
refresh_with(parse(client.post("/projects/#{
|
279
|
+
refresh_with(parse(client.post("/projects/#{gid}/removeMembers", body: with_params, options: options)).first)
|
238
280
|
end
|
239
281
|
|
240
282
|
# Create a new custom field setting on the project.
|
241
283
|
#
|
242
|
-
# custom_field - [
|
284
|
+
# custom_field - [Gid] The id of the custom field to associate with this project.
|
243
285
|
# is_important - [Boolean] Whether this field should be considered important to this project.
|
244
286
|
#
|
245
|
-
# insert_before - [
|
287
|
+
# insert_before - [Gid] An id of a Custom Field Settings on this project, before which the new Custom Field Settings will be added.
|
246
288
|
# `insert_before` and `insert_after` parameters cannot both be specified.
|
247
289
|
#
|
248
|
-
# insert_after - [
|
290
|
+
# insert_after - [Gid] An id of a Custom Field Settings on this project, after which the new Custom Field Settings will be added.
|
249
291
|
# `insert_before` and `insert_after` parameters cannot both be specified.
|
250
292
|
#
|
251
293
|
# options - [Hash] the request I/O options.
|
252
294
|
# data - [Hash] the attributes to post.
|
253
295
|
def add_custom_field_setting(custom_field: required("custom_field"), is_important: nil, insert_before: nil, insert_after: nil, options: {}, **data)
|
254
296
|
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? }
|
255
|
-
Resource.new(parse(client.post("/projects/#{
|
297
|
+
Resource.new(parse(client.post("/projects/#{gid}/addCustomFieldSetting", body: with_params, options: options)).first, client: client)
|
256
298
|
end
|
257
299
|
|
258
300
|
# Remove a custom field setting on the project.
|
259
301
|
#
|
260
|
-
# custom_field - [
|
302
|
+
# custom_field - [Gid] The id of the custom field to remove from this project.
|
261
303
|
# options - [Hash] the request I/O options.
|
262
304
|
# data - [Hash] the attributes to post.
|
263
305
|
def remove_custom_field_setting(custom_field: nil, options: {}, **data)
|
264
306
|
with_params = data.merge(custom_field: custom_field).reject { |_,v| v.nil? || Array(v).empty? }
|
265
|
-
Resource.new(parse(client.post("/projects/#{
|
307
|
+
Resource.new(parse(client.post("/projects/#{gid}/removeCustomFieldSetting", body: with_params, options: options)).first, client: client)
|
266
308
|
end
|
267
309
|
|
268
310
|
end
|