Class: Podio::Reference

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

Overview

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

.count_users_with_access(ref_type, ref_id) ⇒ Object



46
47
48
# File 'lib/podio/models/reference.rb', line 46

def count_users_with_access(ref_type, ref_id)
  Podio.connection.get("/reference/#{ref_type}/#{ref_id}/accessible_by/count").body['count']
end

.find(ref_type, ref_id, options = {}) ⇒ Object



17
18
19
20
21
# File 'lib/podio/models/reference.rb', line 17

def find(ref_type, ref_id, options = {})
  member Podio.connection.get { |req|
    req.url("/reference/#{ref_type}/#{ref_id}", options)
  }.body
end

.find_users_with_access(ref_type, ref_id, options = {}) ⇒ Object



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

def find_users_with_access(ref_type, ref_id, options = {})
  self.klass_from_string('Contact').list Podio.connection.get { |req|
    req.url("/reference/#{ref_type}/#{ref_id}/accessible_by/", options)
  }.body
end

.search(target, query, limit, target_params = nil, subfield = nil) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/podio/models/reference.rb', line 24

def search(target, query, limit, target_params = nil, subfield = nil)
  response = Podio.connection.post do |req|
    req.url "/reference/search"
    req.body = {
      :target => target,
      :text => query,
      :limit => limit
    }
    req.body[:target_params] = target_params if target_params.present?
    req.body[:subfield] = subfield if subfield.present?
  end
  response.body
end