lib/checkoff/portfolios.rb in checkoff-0.197.0 vs lib/checkoff/portfolios.rb in checkoff-0.198.0
- old
+ new
@@ -5,10 +5,11 @@
require 'forwardable'
require 'cache_method'
require_relative 'internal/config_loader'
require_relative 'workspaces'
require_relative 'clients'
+require_relative 'projects'
# https://developers.asana.com/reference/portfolios
module Checkoff
# Pull portfolios from Asana
@@ -25,16 +26,19 @@
# @param config [Hash]
# @param workspaces [Checkoff::Workspaces]
# @param clients [Checkoff::Clients]
# @param client [Asana::Client]
+ # @param projects [Checkoff::Projects]
def initialize(config: Checkoff::Internal::ConfigLoader.load(:asana),
clients: Checkoff::Clients.new(config: config),
client: clients.client,
+ projects: Checkoff::Projects.new(config: config, client: client),
workspaces: Checkoff::Workspaces.new(config: config, client: client))
@workspaces = workspaces
@client = client
+ @projects = projects
end
# @param workspace_name [String]
# @param portfolio_name [String]
#
@@ -93,20 +97,20 @@
# @param portfolio [Asana::Resources::Portfolio]
# @param extra_project_fields [Array<String>]
#
# @return [Enumerable<Asana::Resources::Project>]
def projects_in_portfolio_obj(portfolio, extra_project_fields: [])
- options = {
- fields: ['name'],
- }
- options[:fields] += extra_project_fields
+ options = projects.project_options(extra_project_fields: extra_project_fields)
client.portfolios.get_items_for_portfolio(portfolio_gid: portfolio.gid, options: options)
end
private
# @return [Checkoff::Workspaces]
attr_reader :workspaces
+
+ # @return [Checkoff::Projects]
+ attr_reader :projects
# @return [Asana::Client]
attr_reader :client
# bundle exec ./portfolios.rb