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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fba81fcfd6e52f9ed9b9351753b1fc053ef365023841c54d82b64fe63615211b
|
4
|
+
data.tar.gz: d69406d6cd8b45e8e824b6ab011f4ca4568ee08d41bb6c13da1e8f5c70c85d9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5f09823b1fd94a67c66b80a98d2b22085c365c5ef45fe8103d132c44269434c199ad16ceeb616c9c6479bb7d7f6a25f878acafc59069432e98d7b61e2a56dec
|
7
|
+
data.tar.gz: df14ac41b6115767e8844bd60524c2b73f3b219a9fa7937b9b5ae73ce6c00fdc10bce26a88b289f788a01de0dd4cb8edccf95c2c1886fb9a1e53c5cc5e2aa296
|
data/.gitignore
CHANGED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.4.0
|
data/README.md
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/asana.svg)](http://badge.fury.io/rb/asana)
|
4
4
|
[![Build Status](https://travis-ci.org/Asana/ruby-asana.svg?branch=master)](https://travis-ci.org/Asana/ruby-asana)
|
5
5
|
[![Code Climate](https://codeclimate.com/github/Asana/ruby-asana/badges/gpa.svg)](https://codeclimate.com/github/Asana/ruby-asana)
|
6
|
-
[![Dependency Status](https://gemnasium.com/Asana/ruby-asana.svg)](https://gemnasium.com/Asana/ruby-asana)
|
7
6
|
|
8
7
|
|
9
8
|
A Ruby client for the 1.0 version of the Asana API.
|
@@ -341,6 +340,25 @@ Thread.new do
|
|
341
340
|
end
|
342
341
|
```
|
343
342
|
|
343
|
+
### Asana Change Warnings
|
344
|
+
|
345
|
+
You will receive warning logs if performing requests that may be affected by a deprecation. The warning contains a link that explains the deprecation.
|
346
|
+
|
347
|
+
If you receive one of these warnings, you should:
|
348
|
+
* Read about the deprecation.
|
349
|
+
* Resolve sections of your code that would be affected by the deprecation.
|
350
|
+
* Add the deprecation flag to your "asana-enable" header.
|
351
|
+
|
352
|
+
You can add global headers, by setting default_headers
|
353
|
+
|
354
|
+
c.default_headers "asana-enable" => "string_ids"
|
355
|
+
|
356
|
+
Or you can add a header field to the options of each request.
|
357
|
+
|
358
|
+
If you would rather suppress these warnings, you can set
|
359
|
+
|
360
|
+
c.log_asana_change_warnings false
|
361
|
+
|
344
362
|
## Development
|
345
363
|
|
346
364
|
You'll need Ruby 2.1+ and Node v0.10.26+ / NPM 1.4.3+ installed.
|
data/asana.gemspec
CHANGED
@@ -26,7 +26,6 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.add_dependency "faraday_middleware", "~> 0.9"
|
27
27
|
spec.add_dependency "faraday_middleware-multi_json", "~> 0.0"
|
28
28
|
|
29
|
-
spec.add_development_dependency "bundler", "~> 1.7"
|
30
29
|
spec.add_development_dependency "rake", "~> 10.0"
|
31
30
|
spec.add_development_dependency "rspec", "~> 3.2"
|
32
31
|
spec.add_development_dependency 'appraisal', '~> 2.1', '>= 2.1'
|
data/lib/asana/client.rb
CHANGED
@@ -75,10 +75,12 @@ module Asana
|
|
75
75
|
def initialize
|
76
76
|
config = Configuration.new.tap { |c| yield c }.to_h
|
77
77
|
@http_client =
|
78
|
-
HttpClient.new(authentication:
|
79
|
-
adapter:
|
80
|
-
user_agent:
|
81
|
-
debug_mode:
|
78
|
+
HttpClient.new(authentication: config.fetch(:authentication),
|
79
|
+
adapter: config[:faraday_adapter],
|
80
|
+
user_agent: config[:user_agent],
|
81
|
+
debug_mode: config[:debug_mode],
|
82
|
+
log_asana_change_warnings: config[:log_asana_change_warnings],
|
83
|
+
default_headers: config[:default_headers],
|
82
84
|
&config[:faraday_configuration])
|
83
85
|
end
|
84
86
|
|
@@ -16,7 +16,9 @@ module Asana
|
|
16
16
|
class Configuration
|
17
17
|
# Public: Initializes an empty configuration object.
|
18
18
|
def initialize
|
19
|
-
@configuration = {
|
19
|
+
@configuration = {
|
20
|
+
:log_asana_change_warnings => true
|
21
|
+
}
|
20
22
|
end
|
21
23
|
|
22
24
|
# Public: Sets an authentication strategy.
|
@@ -63,6 +65,20 @@ module Asana
|
|
63
65
|
@configuration[:debug_mode] = true
|
64
66
|
end
|
65
67
|
|
68
|
+
# Public: Configures the client to log Asana-Change warnings on STDERR.
|
69
|
+
#
|
70
|
+
# Returns nothing.
|
71
|
+
def log_asana_change_warnings(value)
|
72
|
+
@configuration[:log_asana_change_warnings] = !!value
|
73
|
+
end
|
74
|
+
|
75
|
+
# Public: Configures the client to always send the given headers
|
76
|
+
#
|
77
|
+
# Returns nothing.
|
78
|
+
def default_headers(value)
|
79
|
+
@configuration[:default_headers] = value
|
80
|
+
end
|
81
|
+
|
66
82
|
# Public:
|
67
83
|
# Returns the configuration [Hash].
|
68
84
|
def to_h
|
data/lib/asana/http_client.rb
CHANGED
@@ -26,12 +26,16 @@ module Asana
|
|
26
26
|
adapter: nil,
|
27
27
|
user_agent: nil,
|
28
28
|
debug_mode: false,
|
29
|
+
log_asana_change_warnings: true,
|
30
|
+
default_headers: nil,
|
29
31
|
&config)
|
30
|
-
@authentication
|
31
|
-
@adapter
|
32
|
-
@environment_info
|
33
|
-
@debug_mode
|
34
|
-
@
|
32
|
+
@authentication = authentication
|
33
|
+
@adapter = adapter || Faraday.default_adapter
|
34
|
+
@environment_info = EnvironmentInfo.new(user_agent)
|
35
|
+
@debug_mode = debug_mode
|
36
|
+
@log_asana_change_warnings = log_asana_change_warnings
|
37
|
+
@default_headers = default_headers
|
38
|
+
@config = config
|
35
39
|
end
|
36
40
|
|
37
41
|
# Public: Performs a GET request against the API.
|
@@ -49,7 +53,7 @@ module Asana
|
|
49
53
|
hash[:"opt_#{k}"] = v.is_a?(Array) ? v.join(',') : v
|
50
54
|
end
|
51
55
|
end
|
52
|
-
perform_request(:get, resource_uri, params.merge(opts))
|
56
|
+
perform_request(:get, resource_uri, params.merge(opts), options[:headers])
|
53
57
|
end
|
54
58
|
|
55
59
|
# Public: Performs a PUT request against the API.
|
@@ -62,8 +66,14 @@ module Asana
|
|
62
66
|
# Returns an [Asana::HttpClient::Response] if everything went well.
|
63
67
|
# Raises [Asana::Errors::APIError] if anything went wrong.
|
64
68
|
def put(resource_uri, body: {}, options: {})
|
69
|
+
opts = options.reduce({}) do |acc, (k, v)|
|
70
|
+
acc.tap do |hash|
|
71
|
+
hash[:"opt_#{k}"] = v.is_a?(Array) ? v.join(',') : v
|
72
|
+
end
|
73
|
+
end
|
74
|
+
options.merge(opts)
|
65
75
|
params = { data: body }.merge(options.empty? ? {} : { options: options })
|
66
|
-
perform_request(:put, resource_uri, params)
|
76
|
+
perform_request(:put, resource_uri, params, options[:headers])
|
67
77
|
end
|
68
78
|
|
69
79
|
# Public: Performs a POST request against the API.
|
@@ -78,13 +88,19 @@ module Asana
|
|
78
88
|
# Returns an [Asana::HttpClient::Response] if everything went well.
|
79
89
|
# Raises [Asana::Errors::APIError] if anything went wrong.
|
80
90
|
def post(resource_uri, body: {}, upload: nil, options: {})
|
91
|
+
opts = options.reduce({}) do |acc, (k, v)|
|
92
|
+
acc.tap do |hash|
|
93
|
+
hash[:"opt_#{k}"] = v.is_a?(Array) ? v.join(',') : v
|
94
|
+
end
|
95
|
+
end
|
96
|
+
options.merge(opts)
|
81
97
|
params = { data: body }.merge(options.empty? ? {} : { options: options })
|
82
98
|
if upload
|
83
|
-
perform_request(:post, resource_uri, params.merge(file: upload)) do |c|
|
99
|
+
perform_request(:post, resource_uri, params.merge(file: upload), options[:headers]) do |c|
|
84
100
|
c.request :multipart
|
85
101
|
end
|
86
102
|
else
|
87
|
-
perform_request(:post, resource_uri, params)
|
103
|
+
perform_request(:post, resource_uri, params, options[:headers])
|
88
104
|
end
|
89
105
|
end
|
90
106
|
|
@@ -113,11 +129,14 @@ module Asana
|
|
113
129
|
end
|
114
130
|
end
|
115
131
|
|
116
|
-
def perform_request(method, resource_uri, body = {}, &request_config)
|
132
|
+
def perform_request(method, resource_uri, body = {}, headers = {}, &request_config)
|
117
133
|
handling_errors do
|
118
134
|
url = BASE_URI + resource_uri
|
135
|
+
headers = (@default_headers || {}).merge(headers || {})
|
119
136
|
log_request(method, url, body) if @debug_mode
|
120
|
-
Response.new(connection(&request_config).public_send(method, url, body))
|
137
|
+
result = Response.new(connection(&request_config).public_send(method, url, body, headers))
|
138
|
+
log_asana_change_headers(headers, result.headers) if @log_asana_change_warnings
|
139
|
+
result
|
121
140
|
end
|
122
141
|
end
|
123
142
|
|
@@ -151,5 +170,73 @@ module Asana
|
|
151
170
|
url,
|
152
171
|
body.inspect)
|
153
172
|
end
|
173
|
+
|
174
|
+
def log_asana_change_headers(request_headers, response_headers)
|
175
|
+
change_header_key = nil
|
176
|
+
|
177
|
+
response_headers.each_key do |key|
|
178
|
+
if key.downcase == 'asana-change'
|
179
|
+
change_header_key = key
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
if change_header_key != nil
|
184
|
+
accounted_for_flags = Array.new
|
185
|
+
|
186
|
+
if request_headers == nil
|
187
|
+
request_headers = {}
|
188
|
+
end
|
189
|
+
# Grab the request's asana-enable flags
|
190
|
+
request_headers.each_key do |req_header|
|
191
|
+
if req_header.downcase == 'asana-enable'
|
192
|
+
request_headers[req_header].split(',').each do |flag|
|
193
|
+
accounted_for_flags.push(flag)
|
194
|
+
end
|
195
|
+
elsif req_header.downcase == 'asana-disable'
|
196
|
+
request_headers[req_header].split(',').each do |flag|
|
197
|
+
accounted_for_flags.push(flag)
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
changes = response_headers[change_header_key].split(',')
|
203
|
+
|
204
|
+
changes.each do |unsplit_change|
|
205
|
+
change = unsplit_change.split(';')
|
206
|
+
|
207
|
+
name = nil
|
208
|
+
info = nil
|
209
|
+
affected = nil
|
210
|
+
|
211
|
+
change.each do |unsplit_field|
|
212
|
+
field = unsplit_field.split('=')
|
213
|
+
|
214
|
+
field[0].strip!
|
215
|
+
field[1].strip!
|
216
|
+
if field[0] == 'name'
|
217
|
+
name = field[1]
|
218
|
+
elsif field[0] == 'info'
|
219
|
+
info = field[1]
|
220
|
+
elsif field[0] == 'affected'
|
221
|
+
affected = field[1]
|
222
|
+
end
|
223
|
+
|
224
|
+
# Only show the error if the flag was not in the request's asana-enable header
|
225
|
+
if !(accounted_for_flags.include? name) && (affected == 'true')
|
226
|
+
message1 = 'This request is affected by the "%s"' +
|
227
|
+
' deprecation. Please visit this url for more info: %s'
|
228
|
+
message2 = 'Adding "%s" to your "Asana-Enable" or ' +
|
229
|
+
'"Asana-Disable" header will opt in/out to this deprecation ' +
|
230
|
+
'and suppress this warning.'
|
231
|
+
|
232
|
+
STDERR.puts format(message1, name, info)
|
233
|
+
STDERR.puts format(message2, name)
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|
238
|
+
end
|
154
239
|
end
|
155
240
|
end
|
241
|
+
|
242
|
+
|
@@ -11,6 +11,9 @@ module Asana
|
|
11
11
|
# Public:
|
12
12
|
# Returns the [Hash] representing the parsed JSON body.
|
13
13
|
attr_reader :body
|
14
|
+
# Public:
|
15
|
+
# Returns the [Hash] of attribute headers.
|
16
|
+
attr_reader :headers
|
14
17
|
|
15
18
|
# Public: Wraps a Faraday response.
|
16
19
|
#
|
@@ -19,6 +22,7 @@ module Asana
|
|
19
22
|
@faraday_env = faraday_response.env
|
20
23
|
@status = faraday_env.status
|
21
24
|
@body = faraday_env.body
|
25
|
+
@headers = faraday_response.headers
|
22
26
|
end
|
23
27
|
|
24
28
|
# Public:
|
@@ -20,7 +20,7 @@ module Asana
|
|
20
20
|
raise ArgumentError, "file #{filename} doesn't exist"
|
21
21
|
end
|
22
22
|
upload = Faraday::UploadIO.new(path, mime)
|
23
|
-
response = client.post("/#{self.class.plural_name}/#{
|
23
|
+
response = client.post("/#{self.class.plural_name}/#{gid}/attachments",
|
24
24
|
body: data,
|
25
25
|
upload: upload,
|
26
26
|
options: options)
|
@@ -7,7 +7,7 @@ module Asana
|
|
7
7
|
module EventSubscription
|
8
8
|
# Public: Returns an infinite collection of events on the resource.
|
9
9
|
def events(wait: 1, options: {})
|
10
|
-
Events.new(resource:
|
10
|
+
Events.new(resource: gid, client: client, wait: wait, options: options)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
@@ -25,7 +25,7 @@ module Asana
|
|
25
25
|
def refresh
|
26
26
|
raise "#{self.class.name} does not respond to #find_by_id" unless \
|
27
27
|
self.class.respond_to?(:find_by_id)
|
28
|
-
self.class.find_by_id(client,
|
28
|
+
self.class.find_by_id(client, gid)
|
29
29
|
end
|
30
30
|
|
31
31
|
# Internal: Proxies method calls to the data, wrapping it accordingly and
|
@@ -11,6 +11,10 @@ module Asana
|
|
11
11
|
|
12
12
|
attr_reader :id
|
13
13
|
|
14
|
+
attr_reader :gid
|
15
|
+
|
16
|
+
attr_reader :resource_type
|
17
|
+
|
14
18
|
attr_reader :created_at
|
15
19
|
|
16
20
|
attr_reader :download_url
|
@@ -31,7 +35,7 @@ module Asana
|
|
31
35
|
|
32
36
|
# Returns the full record for a single attachment.
|
33
37
|
#
|
34
|
-
# id - [
|
38
|
+
# id - [Gid] Globally unique identifier for the attachment.
|
35
39
|
#
|
36
40
|
# options - [Hash] the request I/O options.
|
37
41
|
def find_by_id(client, id, options: {})
|
@@ -41,7 +45,7 @@ module Asana
|
|
41
45
|
|
42
46
|
# Returns the compact records for all attachments on the task.
|
43
47
|
#
|
44
|
-
# task - [
|
48
|
+
# task - [Gid] Globally unique identifier for the task.
|
45
49
|
#
|
46
50
|
# per_page - [Integer] the number of records to fetch per page.
|
47
51
|
# options - [Hash] the request I/O options.
|
@@ -3,20 +3,27 @@
|
|
3
3
|
|
4
4
|
module Asana
|
5
5
|
module Resources
|
6
|
-
# Custom fields are
|
7
|
-
# Field Settings resource. This resource both represents the
|
8
|
-
# of the Custom Field and Project as well as
|
9
|
-
# particular pairing; for instance,
|
10
|
-
# some possible application-specific
|
6
|
+
# Custom fields are applied to a particular project or portfolio with the
|
7
|
+
# Custom Field Settings resource. This resource both represents the
|
8
|
+
# many-to-many join of the Custom Field and Project or Portfolio as well as
|
9
|
+
# stores information that is relevant to that particular pairing; for instance,
|
10
|
+
# the `is_important` property determines some possible application-specific
|
11
|
+
# handling of that custom field and parent.
|
11
12
|
class CustomFieldSetting < Resource
|
12
13
|
|
13
14
|
|
14
15
|
attr_reader :id
|
15
16
|
|
17
|
+
attr_reader :gid
|
18
|
+
|
19
|
+
attr_reader :resource_type
|
20
|
+
|
16
21
|
attr_reader :created_at
|
17
22
|
|
18
23
|
attr_reader :is_important
|
19
24
|
|
25
|
+
attr_reader :parent
|
26
|
+
|
20
27
|
attr_reader :project
|
21
28
|
|
22
29
|
attr_reader :custom_field
|
@@ -27,15 +34,25 @@ module Asana
|
|
27
34
|
'custom_field_settings'
|
28
35
|
end
|
29
36
|
|
30
|
-
# Returns a list of all of the custom fields settings on a project
|
37
|
+
# Returns a list of all of the custom fields settings on a project.
|
31
38
|
#
|
32
|
-
# project - [
|
39
|
+
# project - [Gid] The ID of the project for which to list custom field settings
|
33
40
|
# per_page - [Integer] the number of records to fetch per page.
|
34
41
|
# options - [Hash] the request I/O options.
|
35
42
|
def find_by_project(client, project: required("project"), per_page: 20, options: {})
|
36
43
|
params = { limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? }
|
37
44
|
Collection.new(parse(client.get("/projects/#{project}/custom_field_settings", params: params, options: options)), type: Resource, client: client)
|
38
45
|
end
|
46
|
+
|
47
|
+
# Returns a list of all of the custom fields settings on a portfolio.
|
48
|
+
#
|
49
|
+
# portfolio - [Gid] The ID of the portfolio for which to list custom field settings
|
50
|
+
# per_page - [Integer] the number of records to fetch per page.
|
51
|
+
# options - [Hash] the request I/O options.
|
52
|
+
def find_by_portfolio(client, portfolio: required("portfolio"), per_page: 20, options: {})
|
53
|
+
params = { limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? }
|
54
|
+
Collection.new(parse(client.get("/portfolios/#{portfolio}/custom_field_settings", params: params, options: options)), type: Resource, client: client)
|
55
|
+
end
|
39
56
|
end
|
40
57
|
|
41
58
|
end
|
@@ -8,11 +8,22 @@ module Asana
|
|
8
8
|
# Fields](/developers/documentation/getting-started/custom-fields) developer
|
9
9
|
# documentation for more information about how custom fields relate to various
|
10
10
|
# resources in Asana.
|
11
|
+
#
|
12
|
+
# Users in Asana can [lock custom
|
13
|
+
# fields](/guide/help/premium/custom-fields#gl-lock-fields), which will make
|
14
|
+
# them read-only when accessed by other users. Attempting to edit a locked
|
15
|
+
# custom field will return HTTP error code `403 Forbidden`.
|
11
16
|
class CustomField < Resource
|
12
17
|
|
13
18
|
|
14
19
|
attr_reader :id
|
15
20
|
|
21
|
+
attr_reader :gid
|
22
|
+
|
23
|
+
attr_reader :resource_type
|
24
|
+
|
25
|
+
attr_reader :resource_subtype
|
26
|
+
|
16
27
|
attr_reader :name
|
17
28
|
|
18
29
|
attr_reader :description
|
@@ -35,22 +46,23 @@ module Asana
|
|
35
46
|
#
|
36
47
|
# Returns the full record of the newly created custom field.
|
37
48
|
#
|
38
|
-
# workspace - [
|
39
|
-
#
|
49
|
+
# workspace - [Gid] The workspace to create a custom field in.
|
50
|
+
# resource_subtype - [String] The type of the custom field. Must be one of the given values.
|
51
|
+
# type - [String] **Deprecated: New integrations should prefer the `resource_subtype` parameter.**
|
40
52
|
# name - [String] The name of the custom field.
|
41
53
|
# description - [String] The description of the custom field.
|
42
54
|
# precision - [Integer] The number of decimal places for the numerical values. Required if the custom field is of type 'number'.
|
43
55
|
# enum_options - [String] The discrete values the custom field can assume. Required if the custom field is of type 'enum'.
|
44
56
|
# options - [Hash] the request I/O options.
|
45
57
|
# data - [Hash] the attributes to post.
|
46
|
-
def create(client, workspace: required("workspace"), type:
|
47
|
-
with_params = data.merge(workspace: workspace,
|
58
|
+
def create(client, workspace: required("workspace"), resource_subtype: nil, type: nil, name: required("name"), description: nil, precision: nil, enum_options: nil, options: {}, **data)
|
59
|
+
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? }
|
48
60
|
Resource.new(parse(client.post("/custom_fields", body: with_params, options: options)).first, client: client)
|
49
61
|
end
|
50
62
|
|
51
63
|
# Returns the complete definition of a custom field's metadata.
|
52
64
|
#
|
53
|
-
# id - [
|
65
|
+
# id - [Gid] Globally unique identifier for the custom field.
|
54
66
|
#
|
55
67
|
# options - [Hash] the request I/O options.
|
56
68
|
def find_by_id(client, id, options: {})
|
@@ -60,7 +72,7 @@ module Asana
|
|
60
72
|
|
61
73
|
# Returns a list of the compact representation of all of the custom fields in a workspace.
|
62
74
|
#
|
63
|
-
# workspace - [
|
75
|
+
# workspace - [Gid] The workspace or organization to find custom field definitions in.
|
64
76
|
# per_page - [Integer] the number of records to fetch per page.
|
65
77
|
# options - [Hash] the request I/O options.
|
66
78
|
def find_by_workspace(client, workspace: required("workspace"), per_page: 20, options: {})
|
@@ -70,68 +82,78 @@ module Asana
|
|
70
82
|
|
71
83
|
# 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.
|
72
84
|
#
|
85
|
+
# Locked custom fields can only have enum options added by the user who locked the field.
|
86
|
+
#
|
73
87
|
# Returns the full record of the newly created enum option.
|
74
88
|
#
|
75
|
-
# custom_field - [
|
89
|
+
# custom_field - [Gid] Globally unique identifier for the custom field.
|
76
90
|
#
|
77
91
|
# name - [String] The name of the enum option.
|
78
92
|
# color - [String] The color of the enum option. Defaults to 'none'.
|
79
|
-
# insert_before - [
|
80
|
-
# insert_after - [
|
93
|
+
# 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.
|
94
|
+
# 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.
|
81
95
|
# options - [Hash] the request I/O options.
|
82
96
|
# data - [Hash] the attributes to post.
|
83
|
-
def
|
97
|
+
def create_enum_option(client, custom_field: required("custom_field"), name: required("name"), color: nil, insert_before: nil, insert_after: nil, options: {}, **data)
|
84
98
|
with_params = data.merge(name: name, color: color, insert_before: insert_before, insert_after: insert_after).reject { |_,v| v.nil? || Array(v).empty? }
|
85
99
|
Resource.new(parse(client.post("/custom_fields/#{custom_field}/enum_options", body: with_params, options: options)).first, client: client)
|
86
100
|
end
|
101
|
+
alias_method :add_enum_option, :create_enum_option
|
87
102
|
|
88
103
|
# Moves a particular enum option to be either before or after another specified enum option in the custom field.
|
89
104
|
#
|
90
|
-
#
|
105
|
+
# Locked custom fields can only be reordered by the user who locked the field.
|
106
|
+
#
|
107
|
+
# custom_field - [Gid] Globally unique identifier for the custom field.
|
91
108
|
#
|
92
|
-
# enum_option - [
|
109
|
+
# enum_option - [Gid] The ID of the enum option to relocate.
|
93
110
|
# name - [String] The name of the enum option.
|
94
111
|
# color - [String] The color of the enum option. Defaults to 'none'.
|
95
|
-
# before_enum_option - [
|
96
|
-
# after_enum_option - [
|
112
|
+
# 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.
|
113
|
+
# 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.
|
97
114
|
# options - [Hash] the request I/O options.
|
98
115
|
# data - [Hash] the attributes to post.
|
99
|
-
def
|
116
|
+
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)
|
100
117
|
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? }
|
101
118
|
Resource.new(parse(client.post("/custom_fields/#{custom_field}/enum_options/insert", body: with_params, options: options)).first, client: client)
|
102
119
|
end
|
120
|
+
alias_method :reorder_enum_option, :insert_enum_option
|
103
121
|
end
|
104
122
|
|
105
123
|
# 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
|
106
124
|
#
|
107
125
|
# 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.
|
108
126
|
#
|
109
|
-
# A custom field's `type` cannot be updated.
|
110
|
-
#
|
111
127
|
# 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`.
|
112
128
|
#
|
129
|
+
# Locked custom fields can only be updated by the user who locked the field.
|
130
|
+
#
|
113
131
|
# Returns the complete updated custom field record.
|
114
132
|
#
|
115
133
|
# options - [Hash] the request I/O options.
|
116
134
|
# data - [Hash] the attributes to post.
|
117
135
|
def update(options: {}, **data)
|
118
136
|
|
119
|
-
refresh_with(parse(client.put("/custom_fields/#{
|
137
|
+
refresh_with(parse(client.put("/custom_fields/#{gid}", body: data, options: options)).first)
|
120
138
|
end
|
121
139
|
|
122
140
|
# A specific, existing custom field can be deleted by making a DELETE request on the URL for that custom field.
|
123
141
|
#
|
142
|
+
# Locked custom fields can only be deleted by the user who locked the field.
|
143
|
+
#
|
124
144
|
# Returns an empty data record.
|
125
145
|
def delete()
|
126
146
|
|
127
|
-
client.delete("/custom_fields/#{
|
147
|
+
client.delete("/custom_fields/#{gid}") && true
|
128
148
|
end
|
129
149
|
|
130
150
|
# Updates an existing enum option. Enum custom fields require at least one enabled enum option.
|
131
151
|
#
|
152
|
+
# Locked custom fields can only be updated by the user who locked the field.
|
153
|
+
#
|
132
154
|
# Returns the full record of the updated enum option.
|
133
155
|
#
|
134
|
-
# enum_option - [
|
156
|
+
# enum_option - [Gid] Globally unique identifier for the enum option.
|
135
157
|
#
|
136
158
|
# name - [String] The name of the enum option.
|
137
159
|
# color - [String] The color of the enum option. Defaults to 'none'.
|