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

Class 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

.all(options = {}) ⇒ Object



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

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



130
131
132
133
134
135
136
137
# File 'lib/podio/models/profile.rb', line 130

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



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

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

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



50
51
52
53
54
55
56
57
58
59
60
# File 'lib/podio/models/profile.rb', line 50

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



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

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



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

def find_all_for_org(org_id, options={})
  options[:view] ||= '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



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

def find_all_for_space(space_id, options={})
  options[:view] ||= '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_all_for_users(user_ids) ⇒ Object



99
100
101
# File 'lib/podio/models/profile.rb', line 99

def find_all_for_users(user_ids)
  list Podio.connection.get("/contact/user/#{user_ids}").body
end

.find_for_org(org_id) ⇒ Object



89
90
91
# File 'lib/podio/models/profile.rb', line 89

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

.find_for_user(user_id) ⇒ Object



94
95
96
# File 'lib/podio/models/profile.rb', line 94

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

.skills(options) ⇒ Object



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

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

.totals_by_orgObject



108
109
110
# File 'lib/podio/models/profile.rb', line 108

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

.totals_by_org_and_spaceObject



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

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

.totals_by_space_v2(space_id) ⇒ Object



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

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

.update_contact(profile_id, attributes) ⇒ Object



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

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



104
105
106
# File 'lib/podio/models/profile.rb', line 104

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