asana 0.10.3 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/build.yml +24 -0
  3. data/.github/workflows/pubilsh-to-rubygem.yml +18 -0
  4. data/.github/workflows/publish-to-github-releases.yml +16 -0
  5. data/.gitignore +0 -1
  6. data/.rubocop.yml +38 -3
  7. data/.ruby-version +1 -1
  8. data/Appraisals +8 -3
  9. data/Gemfile +7 -3
  10. data/Gemfile.lock +166 -0
  11. data/Guardfile +12 -10
  12. data/README.md +45 -20
  13. data/Rakefile +20 -27
  14. data/VERSION +1 -1
  15. data/asana.gemspec +20 -18
  16. data/examples/Gemfile.lock +2 -2
  17. data/examples/cli_app.rb +2 -2
  18. data/examples/events.rb +3 -3
  19. data/examples/personal_access_token.rb +2 -2
  20. data/lib/asana/authentication/oauth2/access_token_authentication.rb +4 -1
  21. data/lib/asana/authentication/oauth2/bearer_token_authentication.rb +3 -2
  22. data/lib/asana/authentication/oauth2/client.rb +2 -0
  23. data/lib/asana/authentication/oauth2.rb +6 -4
  24. data/lib/asana/authentication/token_authentication.rb +3 -1
  25. data/lib/asana/authentication.rb +2 -0
  26. data/lib/asana/client/configuration.rb +6 -5
  27. data/lib/asana/client.rb +13 -11
  28. data/lib/asana/errors.rb +16 -11
  29. data/lib/asana/http_client/environment_info.rb +9 -8
  30. data/lib/asana/http_client/error_handling.rb +26 -20
  31. data/lib/asana/http_client/response.rb +2 -0
  32. data/lib/asana/http_client.rb +66 -65
  33. data/lib/asana/resource_includes/attachment_uploading.rb +6 -6
  34. data/lib/asana/resource_includes/collection.rb +4 -4
  35. data/lib/asana/resource_includes/event.rb +2 -0
  36. data/lib/asana/resource_includes/event_subscription.rb +2 -0
  37. data/lib/asana/resource_includes/events.rb +4 -1
  38. data/lib/asana/resource_includes/registry.rb +2 -0
  39. data/lib/asana/resource_includes/resource.rb +8 -5
  40. data/lib/asana/resource_includes/response_helper.rb +2 -0
  41. data/lib/asana/resources/audit_log_api.rb +42 -0
  42. data/lib/asana/resources/gen/attachments_base.rb +7 -6
  43. data/lib/asana/resources/gen/audit_log_api_base.rb +37 -0
  44. data/lib/asana/resources/gen/goal_relationships_base.rb +83 -0
  45. data/lib/asana/resources/gen/goals_base.rb +153 -0
  46. data/lib/asana/resources/gen/memberships_base.rb +71 -0
  47. data/lib/asana/resources/gen/portfolios_base.rb +3 -3
  48. data/lib/asana/resources/gen/project_briefs_base.rb +68 -0
  49. data/lib/asana/resources/gen/project_templates_base.rb +73 -0
  50. data/lib/asana/resources/gen/projects_base.rb +17 -4
  51. data/lib/asana/resources/gen/status_updates_base.rb +72 -0
  52. data/lib/asana/resources/gen/tasks_base.rb +13 -15
  53. data/lib/asana/resources/gen/teams_base.rb +41 -13
  54. data/lib/asana/resources/gen/time_periods_base.rb +47 -0
  55. data/lib/asana/resources/gen/typeahead_base.rb +2 -2
  56. data/lib/asana/resources/gen/users_base.rb +3 -4
  57. data/lib/asana/resources/gen/webhooks_base.rb +13 -0
  58. data/lib/asana/resources/gen/workspaces_base.rb +1 -1
  59. data/lib/asana/resources/goal.rb +54 -0
  60. data/lib/asana/resources/goal_relationship.rb +32 -0
  61. data/lib/asana/resources/membership.rb +20 -0
  62. data/lib/asana/resources/portfolio.rb +3 -3
  63. data/lib/asana/resources/project_brief.rb +30 -0
  64. data/lib/asana/resources/project_template.rb +36 -0
  65. data/lib/asana/resources/status_update.rb +54 -0
  66. data/lib/asana/resources/time_period.rb +30 -0
  67. data/lib/asana/resources/typeahead.rb +1 -1
  68. data/lib/asana/resources.rb +4 -4
  69. data/lib/asana/ruby2_0_0_compatibility.rb +2 -0
  70. data/lib/asana/version.rb +1 -1
  71. data/lib/asana.rb +2 -0
  72. data/package-lock.json +115 -0
  73. data/samples/attachments_sample.yaml +4 -4
  74. data/samples/audit_log_api_sample.yaml +11 -0
  75. data/samples/goal_relationships_sample.yaml +51 -0
  76. data/samples/goals_sample.yaml +101 -0
  77. data/samples/memberships_sample.yaml +41 -0
  78. data/samples/project_briefs_sample.yaml +41 -0
  79. data/samples/project_templates_sample.yaml +41 -0
  80. data/samples/projects_sample.yaml +10 -0
  81. data/samples/status_updates_sample.yaml +41 -0
  82. data/samples/teams_sample.yaml +24 -4
  83. data/samples/time_periods_sample.yaml +21 -0
  84. data/samples/webhooks_sample.yaml +10 -0
  85. metadata +75 -40
  86. data/.travis.yml +0 -16
@@ -1,6 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'faraday'
2
- require 'faraday_middleware'
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'.freeze
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
- @config.call(builder) if @config
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 :multi_json
151
- builder.response :multi_json
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
- builder.use FaradayMiddleware::FollowRedirects
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
- STDERR.puts format('[%s] %s %s (%s)',
174
- self.class,
175
- method.to_s.upcase,
176
- url,
177
- body.inspect)
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 != nil
190
- accounted_for_flags = Array.new
194
+ return if change_header_key.nil?
191
195
 
192
- if request_headers == nil
193
- request_headers = {}
194
- end
195
- # Grab the request's asana-enable flags
196
- request_headers.each_key do |req_header|
197
- if req_header.downcase == 'asana-enable'
198
- request_headers[req_header].split(',').each do |flag|
199
- accounted_for_flags.push(flag)
200
- end
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
- changes = response_headers[change_header_key].split(',')
209
-
210
- changes.each do |unsplit_change|
211
- change = unsplit_change.split(';')
212
-
213
- name = nil
214
- info = nil
215
- affected = nil
216
-
217
- change.each do |unsplit_field|
218
- field = unsplit_field.split('=')
219
-
220
- field[0].strip!
221
- field[1].strip!
222
- if field[0] == 'name'
223
- name = field[1]
224
- elsif field[0] == 'info'
225
- info = field[1]
226
- elsif field[0] == 'affected'
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 'events'
2
4
 
3
5
  module Asana
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'events'
2
4
 
3
5
  module Asana
@@ -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 }.reject { |_, v| v.nil? }
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 'resource'
2
4
  require 'set'
3
5
 
@@ -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
@@ -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 for a task
39
+ # Get attachments from an object
40
40
  #
41
- # task_gid - [str] (required) The task to operate on.
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 get_attachments_for_task(client, task_gid: required("task_gid"), options: {})
48
- path = "/tasks/{task_gid}/attachments"
49
- path["{task_gid}"] = task_gid
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