Class: Podio::Comment

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

Overview

Instance Attribute Summary collapse

Attributes inherited from ActivePodio::Base

#attributes

Class Method Summary collapse

Instance 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

Instance Attribute Details

#commentable_idObject

Returns the value of attribute commentable_id.



30
31
32
# File 'lib/podio/models/comment.rb', line 30

def commentable_id
  @commentable_id
end

#commentable_typeObject

Returns the value of attribute commentable_type.



30
31
32
# File 'lib/podio/models/comment.rb', line 30

def commentable_type
  @commentable_type
end

Class Method Details

.create(commentable_type, commentable_id, attributes, options = {}) ⇒ Object



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

def create(commentable_type, commentable_id, attributes, options={})
  response = Podio.connection.post do |req|
    req.url("/comment/#{commentable_type}/#{commentable_id}", options)
    req.body = attributes
  end

  response.body
end

.delete(id) ⇒ Object



61
62
63
# File 'lib/podio/models/comment.rb', line 61

def delete(id)
  Podio.connection.delete("/comment/#{id}").status
end

.find(id) ⇒ Object



66
67
68
# File 'lib/podio/models/comment.rb', line 66

def find(id)
  member Podio.connection.get("/comment/#{id}").body
end

.find_all_for(commentable_type, commentable_id) ⇒ Object



71
72
73
# File 'lib/podio/models/comment.rb', line 71

def find_all_for(commentable_type, commentable_id)
  list Podio.connection.get("/comment/#{commentable_type}/#{commentable_id}").body
end

.find_recent_for_shareObject



75
76
77
78
# File 'lib/podio/models/comment.rb', line 75

def find_recent_for_share
  #Internal
  list Podio.connection.get("/comment/share/").body
end

.liked_by(id) ⇒ Object



81
82
83
# File 'lib/podio/models/comment.rb', line 81

def liked_by(id)
  Podio.connection.get("/comment/#{id}/liked_by/").body.map{|values| Podio::Contact.new(values)}
end

.update(id, attributes) ⇒ Object



51
52
53
54
55
56
57
58
# File 'lib/podio/models/comment.rb', line 51

def update(id, attributes)
  response = Podio.connection.put do |req|
    req.url "/comment/#{id}"
    req.body = attributes
  end

  response.status
end

Instance Method Details

#create(options = {}) ⇒ Object



33
34
35
36
37
# File 'lib/podio/models/comment.rb', line 33

def create(options={})
  updated_attributes = Comment.create(self.commentable_type, self.commentable_id, self.attributes, options)
  self.attributes = updated_attributes.symbolize_keys
  self.initialize_attributes(self.attributes)
end