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, #initialize_attributes, list, member, #new_record?, output_attribute_as_json, #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



161
162
163
164
165
166
167
168
# File 'lib/podio/models/profile.rb', line 161

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



170
171
172
# File 'lib/podio/models/profile.rb', line 170

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

.find(profile_id, options = {}) ⇒ Object



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

def find(profile_id, options = {})
  result = Podio.connection.get do |req|
    req.url("/contact/#{profile_id}/v2", options)
  end.body

  if result.is_a?(Array)
    return list result
  else
    return member result
  end
end

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



101
102
103
104
105
106
107
# File 'lib/podio/models/profile.rb', line 101

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



109
110
111
112
113
114
115
# File 'lib/podio/models/profile.rb', line 109

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_linked_account(id, options = {}) ⇒ Object



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

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

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



83
84
85
86
87
88
89
90
# File 'lib/podio/models/profile.rb', line 83

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



92
93
94
95
96
97
98
99
# File 'lib/podio/models/profile.rb', line 92

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



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

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

.find_for_user(user_id) ⇒ Object



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

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

.skills(options) ⇒ Object



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

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



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

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

.totals_by_org_and_spaceObject



143
144
145
# File 'lib/podio/models/profile.rb', line 143

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

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



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

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



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

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

.update_contact(profile_id, attributes) ⇒ Object



174
175
176
177
178
179
180
181
# File 'lib/podio/models/profile.rb', line 174

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



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

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