Class: Podio::Rating

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

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

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



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

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



35
36
37
# File 'lib/podio/models/rating.rb', line 35

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



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

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



19
20
21
# File 'lib/podio/models/rating.rb', line 19

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



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

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



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

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