Class: Asana::Resources::PortfolioMembership

Inherits:
PortfolioMembershipsBase show all
Defined in:
lib/asana/resources/portfolio_membership.rb

Overview

This object determines if a user is a member of a portfolio.

Instance Attribute Summary collapse

Class Method Summary collapse

Methods inherited from PortfolioMembershipsBase

get_portfolio_membership, get_portfolio_memberships, get_portfolio_memberships_for_portfolio, inherited

Methods inherited from Resource

#initialize, #method_missing, #refresh, #respond_to_missing?, #to_h, #to_s

Methods included from ResponseHelper

#parse

Constructor Details

This class inherits a constructor from Asana::Resources::Resource

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Asana::Resources::Resource

Instance Attribute Details

#gidObject (readonly)


9
10
11
# File 'lib/asana/resources/portfolio_membership.rb', line 9

def gid
  @gid
end

#portfolioObject (readonly)


15
16
17
# File 'lib/asana/resources/portfolio_membership.rb', line 15

def portfolio
  @portfolio
end

#resource_typeObject (readonly)


11
12
13
# File 'lib/asana/resources/portfolio_membership.rb', line 11

def resource_type
  @resource_type
end

#userObject (readonly)


13
14
15
# File 'lib/asana/resources/portfolio_membership.rb', line 13

def user
  @user
end

Class Method Details

.find_all(client, portfolio: nil, workspace: nil, user: nil, per_page: 20, options: {}) ⇒ Object

Returns the compact portfolio membership records for the portfolio. You must specify `portfolio`, `portfolio` and `user`, or `workspace` and `user`.

Parameters:

  • portfolio (Gid) (defaults to: nil)

    The portfolio for which to fetch memberships.

  • workspace (Gid) (defaults to: nil)

    The workspace for which to fetch memberships.

  • user (String) (defaults to: nil)

    The user to filter the memberships to.

  • per_page (Integer) (defaults to: 20)

    the number of records to fetch per page.

  • options (Hash) (defaults to: {})

    the request I/O options.


31
32
33
34
# File 'lib/asana/resources/portfolio_membership.rb', line 31

def find_all(client, portfolio: nil, workspace: nil, user: nil, per_page: 20, options: {})
  params = { portfolio: portfolio, workspace: workspace, user: user, limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? }
  Collection.new(parse(client.get("/portfolio_memberships", params: params, options: options)), type: Resource, client: client)
end

.find_by_id(client, id, options: {}) ⇒ Object

Returns the portfolio membership record.

Parameters:

  • id (Gid)

    Globally unique identifier for the portfolio membership.

  • options (Hash) (defaults to: {})

    the request I/O options.


52
53
54
55
# File 'lib/asana/resources/portfolio_membership.rb', line 52

def find_by_id(client, id, options: {})

  self.new(parse(client.get("/portfolio_memberships/#{id}", options: options)).first, client: client)
end

.find_by_portfolio(client, portfolio: required("portfolio"), user: nil, per_page: 20, options: {}) ⇒ Object

Returns the compact portfolio membership records for the portfolio.

Parameters:

  • portfolio (Gid) (defaults to: required("portfolio"))

    The portfolio for which to fetch memberships.

  • user (String) (defaults to: nil)

    If present, the user to filter the memberships to.

  • per_page (Integer) (defaults to: 20)

    the number of records to fetch per page.

  • options (Hash) (defaults to: {})

    the request I/O options.


42
43
44
45
# File 'lib/asana/resources/portfolio_membership.rb', line 42

def find_by_portfolio(client, portfolio: required("portfolio"), user: nil, per_page: 20, options: {})
  params = { user: user, limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? }
  Collection.new(parse(client.get("/portfolios/#{portfolio}/portfolio_memberships", params: params, options: options)), type: Resource, client: client)
end

.plural_nameObject

Returns the plural name of the resource.


19
20
21
# File 'lib/asana/resources/portfolio_membership.rb', line 19

def plural_name
  'portfolio_memberships'
end