Class: Spaceship::Portal::Persons

Inherits:
Spaceship::PortalBase show all
Defined in:
spaceship/lib/spaceship/portal/persons.rb

Instance Attribute Summary

Attributes inherited from Base

#client, #raw_data

Class Method Summary collapse

Methods inherited from Spaceship::PortalBase

client

Methods inherited from Base

attr_accessor, attr_mapping, attributes, #attributes, factory, #initialize, #inspect, mapping_module, method_missing, set_client, #setup, #to_s

Constructor Details

This class inherits a constructor from Spaceship::Base

Class Method Details

.allObject



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'spaceship/lib/spaceship/portal/persons.rb', line 8

def all
  members = client.team_members
  all_members = []
  member = factory_member(members["members"], "member")
  admins = factory_member(members["admins"], "admin")
  agent  = factory_member(members["agent"], "agent")

  all_members.concat(member)
  all_members.concat(admins)
  all_members << agent

  return all_members
end

.factory_invite(invitees) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'spaceship/lib/spaceship/portal/persons.rb', line 26

def factory_invite(invitees)
  if invitees.kind_of?(Hash)
    return Spaceship::Portal::Invite.factory(invitees)
  end
  final_invitees = []
  invitees.each do |invitee|
    final_invitees << Spaceship::Portal::Invite.factory(invitee)
  end
  return final_invitees
end

.factory_member(members, type) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'spaceship/lib/spaceship/portal/persons.rb', line 37

def factory_member(members, type)
  if members.kind_of?(Hash)
    attrs = members
    attrs[:type] = type
    return Spaceship::Portal::Person.factory(attrs)
  end
  final_members = []
  members.each do |member|
    attrs = member
    attrs[:type] = type
    final_members << Spaceship::Portal::Person.factory(attrs)
  end
  return final_members
end

.find(email) ⇒ Object



52
53
54
55
56
57
58
59
# File 'spaceship/lib/spaceship/portal/persons.rb', line 52

def find(email)
  all.each do |member|
    if member.email_address == email
      return member
    end
  end
  return nil
end

.invite(email, role) ⇒ Object



61
62
63
# File 'spaceship/lib/spaceship/portal/persons.rb', line 61

def invite(email, role)
  client.team_invite(email, role)
end

.invitedObject



22
23
24
# File 'spaceship/lib/spaceship/portal/persons.rb', line 22

def invited
  return factory_invite(client.team_invited["invites"])
end