asana 0.10.3 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/build.yml +24 -0
- data/.github/workflows/pubilsh-to-rubygem.yml +18 -0
- data/.github/workflows/publish-to-github-releases.yml +16 -0
- data/.gitignore +0 -1
- data/.rubocop.yml +38 -3
- data/.ruby-version +1 -1
- data/Appraisals +8 -3
- data/Gemfile +7 -3
- data/Gemfile.lock +166 -0
- data/Guardfile +12 -10
- data/README.md +45 -20
- data/Rakefile +20 -27
- data/VERSION +1 -1
- data/asana.gemspec +20 -18
- data/examples/Gemfile.lock +2 -2
- data/examples/cli_app.rb +2 -2
- data/examples/events.rb +3 -3
- data/examples/personal_access_token.rb +2 -2
- data/lib/asana/authentication/oauth2/access_token_authentication.rb +4 -1
- data/lib/asana/authentication/oauth2/bearer_token_authentication.rb +3 -2
- data/lib/asana/authentication/oauth2/client.rb +2 -0
- data/lib/asana/authentication/oauth2.rb +6 -4
- data/lib/asana/authentication/token_authentication.rb +3 -1
- data/lib/asana/authentication.rb +2 -0
- data/lib/asana/client/configuration.rb +6 -5
- data/lib/asana/client.rb +13 -11
- data/lib/asana/errors.rb +16 -11
- data/lib/asana/http_client/environment_info.rb +9 -8
- data/lib/asana/http_client/error_handling.rb +26 -20
- data/lib/asana/http_client/response.rb +2 -0
- data/lib/asana/http_client.rb +66 -65
- data/lib/asana/resource_includes/attachment_uploading.rb +6 -6
- data/lib/asana/resource_includes/collection.rb +4 -4
- data/lib/asana/resource_includes/event.rb +2 -0
- data/lib/asana/resource_includes/event_subscription.rb +2 -0
- data/lib/asana/resource_includes/events.rb +4 -1
- data/lib/asana/resource_includes/registry.rb +2 -0
- data/lib/asana/resource_includes/resource.rb +8 -5
- data/lib/asana/resource_includes/response_helper.rb +2 -0
- data/lib/asana/resources/audit_log_api.rb +42 -0
- data/lib/asana/resources/gen/attachments_base.rb +7 -6
- data/lib/asana/resources/gen/audit_log_api_base.rb +37 -0
- data/lib/asana/resources/gen/goal_relationships_base.rb +83 -0
- data/lib/asana/resources/gen/goals_base.rb +153 -0
- data/lib/asana/resources/gen/memberships_base.rb +71 -0
- data/lib/asana/resources/gen/portfolios_base.rb +3 -3
- data/lib/asana/resources/gen/project_briefs_base.rb +68 -0
- data/lib/asana/resources/gen/project_templates_base.rb +73 -0
- data/lib/asana/resources/gen/projects_base.rb +17 -4
- data/lib/asana/resources/gen/status_updates_base.rb +72 -0
- data/lib/asana/resources/gen/tasks_base.rb +13 -15
- data/lib/asana/resources/gen/teams_base.rb +41 -13
- data/lib/asana/resources/gen/time_periods_base.rb +47 -0
- data/lib/asana/resources/gen/typeahead_base.rb +2 -2
- data/lib/asana/resources/gen/users_base.rb +3 -4
- data/lib/asana/resources/gen/webhooks_base.rb +13 -0
- data/lib/asana/resources/gen/workspaces_base.rb +1 -1
- data/lib/asana/resources/goal.rb +54 -0
- data/lib/asana/resources/goal_relationship.rb +32 -0
- data/lib/asana/resources/membership.rb +20 -0
- data/lib/asana/resources/portfolio.rb +3 -3
- data/lib/asana/resources/project_brief.rb +30 -0
- data/lib/asana/resources/project_template.rb +36 -0
- data/lib/asana/resources/status_update.rb +54 -0
- data/lib/asana/resources/time_period.rb +30 -0
- data/lib/asana/resources/typeahead.rb +1 -1
- data/lib/asana/resources.rb +4 -4
- data/lib/asana/ruby2_0_0_compatibility.rb +2 -0
- data/lib/asana/version.rb +1 -1
- data/lib/asana.rb +2 -0
- data/package-lock.json +115 -0
- data/samples/attachments_sample.yaml +4 -4
- data/samples/audit_log_api_sample.yaml +11 -0
- data/samples/goal_relationships_sample.yaml +51 -0
- data/samples/goals_sample.yaml +101 -0
- data/samples/memberships_sample.yaml +41 -0
- data/samples/project_briefs_sample.yaml +41 -0
- data/samples/project_templates_sample.yaml +41 -0
- data/samples/projects_sample.yaml +10 -0
- data/samples/status_updates_sample.yaml +41 -0
- data/samples/teams_sample.yaml +24 -4
- data/samples/time_periods_sample.yaml +21 -0
- data/samples/webhooks_sample.yaml +10 -0
- metadata +75 -40
- data/.travis.yml +0 -16
data/lib/asana/http_client.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'faraday'
|
2
|
-
require '
|
3
|
-
require 'faraday_middleware/multi_json'
|
4
|
+
require 'faraday/follow_redirects'
|
4
5
|
|
5
6
|
require_relative 'http_client/error_handling'
|
6
7
|
require_relative 'http_client/environment_info'
|
@@ -11,7 +12,7 @@ module Asana
|
|
11
12
|
# parsing and common options.
|
12
13
|
class HttpClient
|
13
14
|
# Internal: The API base URI.
|
14
|
-
BASE_URI = 'https://app.asana.com/api/1.0'
|
15
|
+
BASE_URI = 'https://app.asana.com/api/1.0'
|
15
16
|
|
16
17
|
# Public: Initializes an HttpClient to make requests to the Asana API.
|
17
18
|
#
|
@@ -130,7 +131,8 @@ module Asana
|
|
130
131
|
yield builder if request_config
|
131
132
|
configure_format(builder)
|
132
133
|
add_middleware(builder)
|
133
|
-
|
134
|
+
configure_redirects(builder)
|
135
|
+
@config&.call(builder)
|
134
136
|
use_adapter(builder, @adapter)
|
135
137
|
end
|
136
138
|
end
|
@@ -147,13 +149,16 @@ module Asana
|
|
147
149
|
end
|
148
150
|
|
149
151
|
def configure_format(builder)
|
150
|
-
builder.request :
|
151
|
-
builder.response :
|
152
|
+
builder.request :json
|
153
|
+
builder.response :json
|
152
154
|
end
|
153
155
|
|
154
156
|
def add_middleware(builder)
|
155
157
|
builder.use Faraday::Response::RaiseError
|
156
|
-
|
158
|
+
end
|
159
|
+
|
160
|
+
def configure_redirects(builder)
|
161
|
+
builder.response :follow_redirects
|
157
162
|
end
|
158
163
|
|
159
164
|
def use_adapter(builder, adapter)
|
@@ -170,79 +175,75 @@ module Asana
|
|
170
175
|
end
|
171
176
|
|
172
177
|
def log_request(method, url, body)
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
+
warn format('[%<klass>s] %<method>s %<url>s (%<body>s)',
|
179
|
+
klass: self.class,
|
180
|
+
method: method.to_s.upcase,
|
181
|
+
url: url,
|
182
|
+
body: body.inspect)
|
178
183
|
end
|
179
184
|
|
185
|
+
# rubocop:disable Metrics/AbcSize
|
186
|
+
# rubocop:disable Metrics/MethodLength
|
180
187
|
def log_asana_change_headers(request_headers, response_headers)
|
181
188
|
change_header_key = nil
|
182
189
|
|
183
190
|
response_headers.each_key do |key|
|
184
|
-
if key.downcase == 'asana-change'
|
185
|
-
change_header_key = key
|
186
|
-
end
|
191
|
+
change_header_key = key if key.downcase == 'asana-change'
|
187
192
|
end
|
188
193
|
|
189
|
-
if change_header_key
|
190
|
-
accounted_for_flags = Array.new
|
194
|
+
return if change_header_key.nil?
|
191
195
|
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
elsif req_header.downcase == 'asana-disable'
|
202
|
-
request_headers[req_header].split(',').each do |flag|
|
203
|
-
accounted_for_flags.push(flag)
|
204
|
-
end
|
196
|
+
accounted_for_flags = []
|
197
|
+
|
198
|
+
request_headers = {} if request_headers.nil?
|
199
|
+
# Grab the request's asana-enable flags
|
200
|
+
request_headers.each_key do |req_header|
|
201
|
+
case req_header.downcase
|
202
|
+
when 'asana-enable', 'asana-disable'
|
203
|
+
request_headers[req_header].split(',').each do |flag|
|
204
|
+
accounted_for_flags.push(flag)
|
205
205
|
end
|
206
206
|
end
|
207
|
+
end
|
208
|
+
|
209
|
+
changes = response_headers[change_header_key].split(',')
|
207
210
|
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
affected = field[1]
|
228
|
-
end
|
229
|
-
|
230
|
-
# Only show the error if the flag was not in the request's asana-enable header
|
231
|
-
if !(accounted_for_flags.include? name) && (affected == 'true')
|
232
|
-
message1 = 'This request is affected by the "%s"' +
|
233
|
-
' deprecation. Please visit this url for more info: %s'
|
234
|
-
message2 = 'Adding "%s" to your "Asana-Enable" or ' +
|
235
|
-
'"Asana-Disable" header will opt in/out to this deprecation ' +
|
236
|
-
'and suppress this warning.'
|
237
|
-
|
238
|
-
STDERR.puts format(message1, name, info)
|
239
|
-
STDERR.puts format(message2, name)
|
240
|
-
end
|
211
|
+
changes.each do |unsplit_change|
|
212
|
+
change = unsplit_change.split(';')
|
213
|
+
|
214
|
+
name = nil
|
215
|
+
info = nil
|
216
|
+
affected = nil
|
217
|
+
|
218
|
+
change.each do |unsplit_field|
|
219
|
+
field = unsplit_field.split('=')
|
220
|
+
|
221
|
+
field[0].strip!
|
222
|
+
field[1].strip!
|
223
|
+
case field[0]
|
224
|
+
when 'name'
|
225
|
+
name = field[1]
|
226
|
+
when 'info'
|
227
|
+
info = field[1]
|
228
|
+
when 'affected'
|
229
|
+
affected = field[1]
|
241
230
|
end
|
231
|
+
|
232
|
+
# Only show the error if the flag was not in the request's asana-enable header
|
233
|
+
next unless !(accounted_for_flags.include? name) && (affected == 'true')
|
234
|
+
|
235
|
+
message1 = 'This request is affected by the "%s" ' \
|
236
|
+
'deprecation. Please visit this url for more info: %s'
|
237
|
+
message2 = 'Adding "%s" to your "Asana-Enable" or ' \
|
238
|
+
'"Asana-Disable" header will opt in/out to this deprecation ' \
|
239
|
+
'and suppress this warning.'
|
240
|
+
|
241
|
+
warn format(message1, name, info)
|
242
|
+
warn format(message2, name)
|
242
243
|
end
|
243
244
|
end
|
244
245
|
end
|
246
|
+
# rubocop:enable Metrics/AbcSize
|
247
|
+
# rubocop:enable Metrics/MethodLength
|
245
248
|
end
|
246
249
|
end
|
247
|
-
|
248
|
-
|
@@ -1,3 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'faraday/multipart'
|
4
|
+
|
1
5
|
module Asana
|
2
6
|
module Resources
|
3
7
|
# Internal: Mixin to add the ability to upload an attachment to a specific
|
@@ -11,8 +15,6 @@ module Asana
|
|
11
15
|
# options - [Hash] the request I/O options
|
12
16
|
# data - [Hash] extra attributes to post
|
13
17
|
#
|
14
|
-
# rubocop:disable Metrics/AbcSize
|
15
|
-
# rubocop:disable Metrics/MethodLength
|
16
18
|
def attach(filename: required('filename'),
|
17
19
|
mime: required('mime'),
|
18
20
|
io: nil, options: {}, **data)
|
@@ -21,9 +23,9 @@ module Asana
|
|
21
23
|
path = File.expand_path(filename)
|
22
24
|
raise ArgumentError, "file #{filename} doesn't exist" unless File.exist?(path)
|
23
25
|
|
24
|
-
Faraday::FilePart.new(path, mime)
|
26
|
+
Faraday::Multipart::FilePart.new(path, mime)
|
25
27
|
else
|
26
|
-
Faraday::FilePart.new(io, mime, filename)
|
28
|
+
Faraday::Multipart::FilePart.new(io, mime, filename)
|
27
29
|
end
|
28
30
|
|
29
31
|
response = client.post("/#{self.class.plural_name}/#{gid}/attachments",
|
@@ -33,8 +35,6 @@ module Asana
|
|
33
35
|
|
34
36
|
Attachment.new(parse(response).first, client: client)
|
35
37
|
end
|
36
|
-
# rubocop:enable Metrics/MethodLength
|
37
|
-
# rubocop:enable Metrics/AbcSize
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'response_helper'
|
2
4
|
|
3
5
|
module Asana
|
@@ -40,7 +42,7 @@ module Asana
|
|
40
42
|
def last
|
41
43
|
@elements.last
|
42
44
|
end
|
43
|
-
|
45
|
+
|
44
46
|
# Public: Returns the size of the collection.
|
45
47
|
def size
|
46
48
|
to_a.size
|
@@ -49,9 +51,7 @@ module Asana
|
|
49
51
|
|
50
52
|
# Public: Returns a String representation of the collection.
|
51
53
|
def to_s
|
52
|
-
"#<Asana::Collection<#{@type}> "
|
53
|
-
"[#{@elements.map(&:inspect).join(', ')}" +
|
54
|
-
(@next_page_data ? ', ...' : '') + ']>'
|
54
|
+
"#<Asana::Collection<#{@type}> [#{@elements.map(&:inspect).join(', ')}#{@next_page_data ? ', ...' : ''}]>"
|
55
55
|
end
|
56
56
|
alias inspect to_s
|
57
57
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'event'
|
2
4
|
|
3
5
|
module Asana
|
@@ -89,13 +91,14 @@ module Asana
|
|
89
91
|
|
90
92
|
# Internal: Returns the formatted params for the poll request.
|
91
93
|
def params
|
92
|
-
{ resource: @resource, sync: @sync }.
|
94
|
+
{ resource: @resource, sync: @sync }.compact
|
93
95
|
end
|
94
96
|
|
95
97
|
# Internal: Executes a block if at least @wait seconds have passed since
|
96
98
|
# @last_poll.
|
97
99
|
def rate_limiting
|
98
100
|
return if @last_poll && Time.now - @last_poll <= @wait
|
101
|
+
|
99
102
|
yield.tap { @last_poll = Time.now }
|
100
103
|
end
|
101
104
|
end
|
@@ -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(
|
34
|
-
super unless respond_to_missing?(
|
35
|
-
cache(
|
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?(
|
43
|
-
to_h.key?(
|
45
|
+
def respond_to_missing?(method_name, *)
|
46
|
+
to_h.key?(method_name.to_s)
|
44
47
|
end
|
45
48
|
|
46
49
|
# Public:
|
@@ -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
|
@@ -36,18 +36,19 @@ module Asana
|
|
36
36
|
Attachment.new(parse(client.get(path, options: options)).first, client: client)
|
37
37
|
end
|
38
38
|
|
39
|
-
# Get attachments
|
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 `project`, `project_brief`, or `task`.
|
42
43
|
# options - [Hash] the request I/O options
|
43
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.'
|
44
45
|
# > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100.
|
45
46
|
# > 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.
|
46
47
|
# > 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.
|
47
|
-
def
|
48
|
-
path = "/
|
49
|
-
|
50
|
-
Collection.new(parse(client.get(path, options: options)), type: Attachment, client: client)
|
48
|
+
def get_attachments_for_object(client, parent: nil, options: {})
|
49
|
+
path = "/attachments"
|
50
|
+
params = { parent: parent }.reject { |_,v| v.nil? || Array(v).empty? }
|
51
|
+
Collection.new(parse(client.get(path, params: params, options: options)), type: Attachment, client: client)
|
51
52
|
end
|
52
53
|
|
53
54
|
end
|
@@ -0,0 +1,37 @@
|
|
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 AuditLogAPIBase < Resource
|
9
|
+
|
10
|
+
def self.inherited(base)
|
11
|
+
Registry.register(base)
|
12
|
+
end
|
13
|
+
|
14
|
+
class << self
|
15
|
+
# Get audit log events
|
16
|
+
#
|
17
|
+
# workspace_gid - [str] (required) Globally unique identifier for the workspace or organization.
|
18
|
+
# start_at - [datetime] Filter to events created after this time (inclusive).
|
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 audit log events](/docs/audit-log-events#supported-audit-log-events) for a full list of values.
|
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
|
+
# actor_gid - [str] Filter to events triggered by the actor with this ID.
|
23
|
+
# resource_gid - [str] Filter to events with this resource ID.
|
24
|
+
# options - [Hash] the request I/O options
|
25
|
+
# > 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.'
|
26
|
+
# > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100.
|
27
|
+
def get_audit_log_events(client, workspace_gid: required("workspace_gid"), start_at: nil, end_at: nil, event_type: nil, actor_type: nil, actor_gid: nil, resource_gid: nil, options: {})
|
28
|
+
path = "/workspaces/{workspace_gid}/audit_log_events"
|
29
|
+
path["{workspace_gid}"] = workspace_gid
|
30
|
+
params = { start_at: start_at, end_at: end_at, event_type: event_type, actor_type: actor_type, actor_gid: actor_gid, resource_gid: resource_gid }.reject { |_,v| v.nil? || Array(v).empty? }
|
31
|
+
Collection.new(parse(client.get(path, params: params, options: options)), type: Resource, client: client)
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,83 @@
|
|
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 GoalRelationshipsBase < Resource
|
9
|
+
|
10
|
+
def self.inherited(base)
|
11
|
+
Registry.register(base)
|
12
|
+
end
|
13
|
+
|
14
|
+
class << self
|
15
|
+
# Add a supporting goal relationship
|
16
|
+
#
|
17
|
+
# goal_gid - [str] (required) Globally unique identifier for the goal.
|
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 add_supporting_relationship(client, goal_gid: required("goal_gid"), options: {}, **data)
|
23
|
+
path = "/goals/{goal_gid}/addSupportingRelationship"
|
24
|
+
path["{goal_gid}"] = goal_gid
|
25
|
+
parse(client.post(path, body: data, options: options)).first
|
26
|
+
end
|
27
|
+
|
28
|
+
# Get a goal relationship
|
29
|
+
#
|
30
|
+
# goal_relationship_gid - [str] (required) Globally unique identifier for the goal relationship.
|
31
|
+
# options - [Hash] the request I/O options
|
32
|
+
# > 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.
|
33
|
+
# > 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.
|
34
|
+
def get_goal_relationship(client, goal_relationship_gid: required("goal_relationship_gid"), options: {})
|
35
|
+
path = "/goal_relationships/{goal_relationship_gid}"
|
36
|
+
path["{goal_relationship_gid}"] = goal_relationship_gid
|
37
|
+
parse(client.get(path, options: options)).first
|
38
|
+
end
|
39
|
+
|
40
|
+
# Get goal relationships
|
41
|
+
#
|
42
|
+
|
43
|
+
# supported_goal - [str] (required) Globally unique identifier for the supported goal in the goal relationship.
|
44
|
+
# resource_subtype - [str] If provided, filter to goal relationships with a given resource_subtype.
|
45
|
+
# options - [Hash] the request I/O options
|
46
|
+
# > 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.
|
47
|
+
# > 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.
|
48
|
+
def get_goal_relationships(client, supported_goal: nil, resource_subtype: nil, options: {})
|
49
|
+
path = "/goal_relationships"
|
50
|
+
params = { supported_goal: supported_goal, resource_subtype: resource_subtype }.reject { |_,v| v.nil? || Array(v).empty? }
|
51
|
+
Collection.new(parse(client.get(path, params: params, options: options)), type: Resource, client: client)
|
52
|
+
end
|
53
|
+
|
54
|
+
# Removes a supporting goal relationship
|
55
|
+
#
|
56
|
+
# goal_gid - [str] (required) Globally unique identifier for the goal.
|
57
|
+
# options - [Hash] the request I/O options
|
58
|
+
# > 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.
|
59
|
+
# > 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.
|
60
|
+
# data - [Hash] the attributes to POST
|
61
|
+
def remove_supporting_relationship(client, goal_gid: required("goal_gid"), options: {}, **data)
|
62
|
+
path = "/goals/{goal_gid}/removeSupportingRelationship"
|
63
|
+
path["{goal_gid}"] = goal_gid
|
64
|
+
parse(client.post(path, body: data, options: options)).first
|
65
|
+
end
|
66
|
+
|
67
|
+
# Update a goal relationship
|
68
|
+
#
|
69
|
+
# goal_relationship_gid - [str] (required) Globally unique identifier for the goal relationship.
|
70
|
+
# options - [Hash] the request I/O options
|
71
|
+
# > 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.
|
72
|
+
# > 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.
|
73
|
+
# data - [Hash] the attributes to PUT
|
74
|
+
def update_goal_relationship(client, goal_relationship_gid: required("goal_relationship_gid"), options: {}, **data)
|
75
|
+
path = "/goal_relationships/{goal_relationship_gid}"
|
76
|
+
path["{goal_relationship_gid}"] = goal_relationship_gid
|
77
|
+
parse(client.put(path, body: data, options: options)).first
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|