Class: Podio::Profile

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

Overview

Serves as the base for Contacts and Organization Contacts

Direct Known Subclasses

Contact, OrganizationContact, SpaceContact

Instance Attribute Summary

Attributes inherited from ActivePodio::Base

#attributes, #error_code, #error_message, #error_parameters, #error_propagate

Class Method Summary collapse

Methods inherited from ActivePodio::Base

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

Constructor Details

This class inherits a constructor from ActivePodio::Base

Class Method Details

.all(options = {}) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/podio/models/profile.rb', line 39

def all(options={})
  options[:exclude_self] = (options[:exclude_self] == false ? "0" : "1" )

  list Podio.connection.get { |req|
    req.url("/contact/", options)
  }.body
end

.create_space_contact(space_id, attributes) ⇒ Object



152
153
154
155
156
157
158
159
# File 'lib/podio/models/profile.rb', line 152

def create_space_contact(space_id, attributes)
  response = Podio.connection.post do |req|
    req.url "/contact/space/#{space_id}/"
    req.body = attributes
  end

  response.body
end

.delete_contact(profile_id) ⇒ Object



161
162
163
# File 'lib/podio/models/profile.rb', line 161

def delete_contact(profile_id)
  Podio.connection.delete("/contact/#{profile_id}").body
end

.find(profile_id) ⇒ Object



71
72
73
74
75
76
77
78
# File 'lib/podio/models/profile.rb', line 71

def find(profile_id)
  result = Podio.connection.get("/contact/#{profile_id}/v2").body
  if result.is_a?(Array)
    return list result
  else
    return member result
  end
end

.find_all_for_connection(connection_id, options = {}) ⇒ Object



98
99
100
101
102
103
104
# File 'lib/podio/models/profile.rb', line 98

def find_all_for_connection(connection_id, options={})
  options[:type] ||= 'full'

  list Podio.connection.get { |req|
    req.url("/contact/connection/#{connection_id}", options)
  }.body      
end

.find_all_for_connection_type(connection_type, options = {}) ⇒ Object



106
107
108
109
110
111
112
# File 'lib/podio/models/profile.rb', line 106

def find_all_for_connection_type(connection_type, options={})
  options[:type] ||= 'full'

  list Podio.connection.get { |req|
    req.url("/contact/connection/#{connection_type}", options)
  }.body
end

.find_all_for_org(org_id, options = {}) ⇒ Object



80
81
82
83
84
85
86
87
# File 'lib/podio/models/profile.rb', line 80

def find_all_for_org(org_id, options={})
  options[:type] ||= 'full'
  options[:exclude_self] = (options[:exclude_self] == false ? "0" : "1" )

  list Podio.connection.get { |req|
    req.url("/contact/org/#{org_id}", options)
  }.body
end

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



89
90
91
92
93
94
95
96
# File 'lib/podio/models/profile.rb', line 89

def find_all_for_space(space_id, options={})
  options[:type] ||= 'full'
  options[:exclude_self] = (options[:exclude_self] == false ? "0" : "1" )

  list Podio.connection.get { |req|
    req.url("/contact/space/#{space_id}", options)
  }.body
end

.find_for_org(org_id) ⇒ Object



114
115
116
# File 'lib/podio/models/profile.rb', line 114

def find_for_org(org_id)
  member Podio.connection.get("/org/#{org_id}/billing").body
end

.find_for_user(user_id) ⇒ Object



118
119
120
# File 'lib/podio/models/profile.rb', line 118

def find_for_user(user_id)
  member Podio.connection.get("/contact/user/#{user_id}").body
end

.skills(options) ⇒ Object



138
139
140
141
142
# File 'lib/podio/models/profile.rb', line 138

def skills(options)
  Podio.connection.get { |req|
    req.url("/contact/skill/", options)
  }.body      
end

.top(options = {}) ⇒ Object



47
48
49
50
51
# File 'lib/podio/models/profile.rb', line 47

def top(options={})
  list Podio.connection.get { |req|
    req.url("/contact/top/", options)
  }.body
end

.top_for_org(org_id, options = {}) ⇒ Object



59
60
61
62
63
# File 'lib/podio/models/profile.rb', line 59

def top_for_org(org_id, options={})
  list Podio.connection.get { |req|
    req.url("/contact/org/#{org_id}/top/", options)
  }.body
end

.top_for_personal(options = {}) ⇒ Object



65
66
67
68
69
# File 'lib/podio/models/profile.rb', line 65

def top_for_personal(options={})
  list Podio.connection.get { |req|
    req.url("/contact/personal/top/", options)
  }.body
end

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



53
54
55
56
57
# File 'lib/podio/models/profile.rb', line 53

def top_for_space(space_id, options={})
  list Podio.connection.get { |req|
    req.url("/contact/space/#{space_id}/top/", options)
  }.body
end

.totals_by_orgObject



126
127
128
# File 'lib/podio/models/profile.rb', line 126

def totals_by_org
  Podio.connection.get("/contact/totals/").body
end

.totals_by_org_and_spaceObject



134
135
136
# File 'lib/podio/models/profile.rb', line 134

def totals_by_org_and_space
  Podio.connection.get("/contact/totals/v2/").body
end

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



144
145
146
147
148
149
150
# File 'lib/podio/models/profile.rb', line 144

def totals_by_space(space_id, options = {})
  options[:exclude_self] = (options[:exclude_self] == false ? "0" : "1" )
  
  Podio.connection.get { |req|
    req.url("/contact/space/#{space_id}/totals/", options)
  }.body
end

.totals_by_space_v2(space_id) ⇒ Object



130
131
132
# File 'lib/podio/models/profile.rb', line 130

def totals_by_space_v2(space_id)
  Podio.connection.get("/contact/space/#{space_id}/totals/space").body
end

.update_contact(profile_id, attributes) ⇒ Object



165
166
167
168
169
170
171
172
# File 'lib/podio/models/profile.rb', line 165

def update_contact(profile_id, attributes)
  response = Podio.connection.put do |req|
    req.url "/contact/#{profile_id}"
    req.body = attributes
  end

  response.body
end

.vcard(profile_id) ⇒ Object



122
123
124
# File 'lib/podio/models/profile.rb', line 122

def vcard(profile_id)
  Podio.connection.get("/contact/#{profile_id}/vcard").body
end