Class: Podio::Rating

Inherits:
ActivePodio::Base show all
Defined in:
lib/podio/models/rating.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

.create(ref_type, ref_id, rating_type, value) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/podio/models/rating.rb', line 12

def create(ref_type, ref_id, rating_type, value)
  response = Podio.connection.post do |req|
    req.url "/rating/#{ref_type}/#{ref_id}/#{rating_type}"
    req.body = { :value => value }
  end

  response.body['rating_id']
end

.delete(ref_type, ref_id, rating_type) ⇒ Object



42
43
44
# File 'lib/podio/models/rating.rb', line 42

def delete(ref_type, ref_id, rating_type)
  Podio.connection.delete("/rating/#{ref_type}/#{ref_id}/#{rating_type}").body
end

.find(ref_type, ref_id, rating_type, user_id) ⇒ Object



27
28
29
# File 'lib/podio/models/rating.rb', line 27

def find(ref_type, ref_id, rating_type, user_id)
  Podio.connection.get("/rating/#{ref_type}/#{ref_id}/#{rating_type}/#{user_id}").body['value']
end

.find_all(ref_type, ref_id) ⇒ Object



22
23
24
# File 'lib/podio/models/rating.rb', line 22

def find_all(ref_type, ref_id)
  collection Podio.connection.get("/rating/#{ref_type}/#{ref_id}").body
end

.find_all_by_type(ref_type, ref_id, rating_type) ⇒ Object



37
38
39
# File 'lib/podio/models/rating.rb', line 37

def find_all_by_type(ref_type, ref_id, rating_type)
  collection Podio.connection.get("/rating/#{ref_type}/#{ref_id}/#{rating_type}").body
end

.find_own(ref_type, ref_id, rating_type) ⇒ Object



32
33
34
# File 'lib/podio/models/rating.rb', line 32

def find_own(ref_type, ref_id, rating_type)
  Podio.connection.get("/rating/#{ref_type}/#{ref_id}/#{rating_type}/self").body['value']
end

.like_count(ref_type, ref_id) ⇒ Object



54
55
56
# File 'lib/podio/models/rating.rb', line 54

def like_count(ref_type, ref_id)
  Podio.connection.get("/rating/#{ref_type}/#{ref_id}/like_count").body["like_count"]
end

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



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

def liked_by(ref_type, ref_id, options={})
  Podio.connection.get { |req|
    req.url("/rating/#{ref_type}/#{ref_id}/liked_by/", options)
  }.body.map{|values| Podio::Contact.new(values)}
end