Class: Podio::SpaceMember

Inherits:
ActivePodio::Base show all
Defined in:
lib/podio/models/space_member.rb

Overview

Encapsulates a user’s membership of a space.

Instance Attribute Summary

Attributes inherited from ActivePodio::Base

#attributes

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ActivePodio::Base

#==, #[], #[]=, #api_friendly_ref_type, #as_json, collection, delegate_to_hash, has_many, has_one, #hash, #initialize, #initialize_attributes, klass_from_string, list, member, #new_record?, output_attribute_as_json, #parent_model, #persisted?, property, #to_param

Constructor Details

This class inherits a constructor from ActivePodio::Base

Class Method Details

.accept_membership_request(space_id, space_member_request_id) ⇒ Object



97
98
99
# File 'lib/podio/models/space_member.rb', line 97

def accept_membership_request(space_id, space_member_request_id)
  Podio.connection.post("/space/#{space_id}/member_request/#{space_member_request_id}/accept").status
end

.end_membership(space_id, user_id) ⇒ Object



69
70
71
# File 'lib/podio/models/space_member.rb', line 69

def end_membership(space_id, user_id)
  Podio.connection.delete("/space/#{space_id}/member/#{user_id}").status
end

.find_all(space_id, options = {}) ⇒ Object



50
51
52
# File 'lib/podio/models/space_member.rb', line 50

def find_all(space_id, options = {})
  list Podio.connection.get("/space/#{space_id}/member/", options).body
end

.find_all_ended(space_id) ⇒ Object



43
44
45
46
47
# File 'lib/podio/models/space_member.rb', line 43

def find_all_ended(space_id)
  list Podio.connection.get { |req|
    req.url("/space/#{space_id}/member/ended/")
  }.body
end

.find_all_for_role(space_id, role) ⇒ Object



29
30
31
32
33
# File 'lib/podio/models/space_member.rb', line 29

def find_all_for_role(space_id, role)
  list Podio.connection.get { |req|
    req.url("/space/#{space_id}/member/#{role}/")
  }.body
end

.find_all_for_space(space_id, options = {}) ⇒ Object



55
56
57
# File 'lib/podio/models/space_member.rb', line 55

def find_all_for_space(space_id, options = {})
  list Podio.connection.get("/space/#{space_id}/member/v2/", options).body
end

.find_membership(space_id, user_id) ⇒ Object



36
37
38
39
40
41
# File 'lib/podio/models/space_member.rb', line 36

def find_membership(space_id, user_id)
  response = Podio.connection.get { |req|
    req.url("/space/#{space_id}/member/#{user_id}/v2")
  }
  member response.body
end

.find_memberships_for_user_in_org(org_id, user_id) ⇒ Object



87
88
89
# File 'lib/podio/models/space_member.rb', line 87

def find_memberships_for_user_in_org(org_id, user_id)
  list Podio.connection.get("/org/#{org_id}/member/#{user_id}/space_member/").body
end

.find_top_active(space_id, options = {}) ⇒ Object



82
83
84
85
# File 'lib/podio/models/space_member.rb', line 82

def find_top_active(space_id, options = {})
  response = Podio.connection.get("/space/#{space_id}/member/top_active/", options)
  response.body.map { |profile| Contact.new(profile) }
end

.find_top_contacts(space_id, options = {}) ⇒ Object



74
75
76
77
78
79
80
# File 'lib/podio/models/space_member.rb', line 74

def find_top_contacts(space_id, options = {})
  result = Podio.connection.get("/space/#{space_id}/member/top/", options).body
  %w(employee external).each do |section|
    result[section]['profiles'].map! { |profile| Contact.new(profile) } if result[section].present? && result[section]['profiles'].present?
  end
  result
end

.get_members_count(space_id) ⇒ Object



101
102
103
# File 'lib/podio/models/space_member.rb', line 101

def get_members_count(space_id)
  Podio.connection.get("/space/#{space_id}/member/total").body
end

.request_membership(space_id) ⇒ Object



92
93
94
# File 'lib/podio/models/space_member.rb', line 92

def request_membership(space_id)
  Podio.connection.post("/space/#{space_id}/member_request/").status
end

.update_role(space_id, user_id, role) ⇒ Object



60
61
62
63
64
65
66
# File 'lib/podio/models/space_member.rb', line 60

def update_role(space_id, user_id, role)
  response = Podio.connection.put do |req|
    req.url "/space/#{space_id}/member/#{user_id}"
    req.body = { :role => role.to_s }
  end
  response.status
end

Instance Method Details

#employee?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/podio/models/space_member.rb', line 19

def employee?
  employee
end

#external?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/podio/models/space_member.rb', line 23

def external?
  !employee
end