Module: Orkut::Client::Comments

Includes:
Base
Included in:
Orkut::Client
Defined in:
lib/orkut/client/comments.rb

Constant Summary

Constants included from Base

Base::DEFAULT_COUNT, Base::DEFAULT_DATETIME_FORMAT, Base::DEFAULT_LANGUAGE

Instance Method Summary collapse

Methods included from Base

#default_headers, #format_datetime, #get_refresh_token, #request_id

Instance Method Details

#get_comments(options = {}) ⇒ Object

TODO implements features

Raises:



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/orkut/client/comments.rb', line 16

def get_comments(options={})
  raise(Orkut::Error, 'Parameter activity_id cannot be nil') if options[:activity_id].blank?
  params = {
    Orkut::Constants::Fields::USER_ID      => Orkut::Constants::InternalConstants::USERID_ME_SIMPLE,
    Orkut::Constants::Fields::ALT          => Orkut::Constants::Params::JSON,
    Orkut::Constants::Fields::ACTIVITY_ID  => options[:activity_id],
    Orkut::Constants::Fields::MAX_RESULTS  => (options[:count] || Orkut::Client::Base::DEFAULT_COUNT).to_s,
    Orkut::Constants::Fields::EXTRA_PARAMS => options
  }
  unless options[:page_token].blank?
    params[Orkut::Constants::Fields::PAGE_TOKEN] = options[:page_token]
  end
  MultiJson.decode(execute(Orkut::Constants::Fields::COMMENTS, Orkut::Constants::Action::LIST, params))
end

#insert_comment(options = {}) ⇒ Object

Raises:



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/orkut/client/comments.rb', line 31

def insert_comment(options={})
  raise(Orkut::Error, 'Parameters activity_id and content cannot be nil') if options[:activity_id].blank? or options[:content].blank?
  params = {
    Orkut::Constants::Fields::USER_ID      => Orkut::Constants::InternalConstants::USERID_ME_SIMPLE,
    Orkut::Constants::Fields::ALT          => Orkut::Constants::Params::JSON,
    Orkut::Constants::Fields::ACTIVITY_ID  => options[:activity_id],
    Orkut::Constants::Fields::EXTRA_PARAMS => options
  }
  body = {
    Orkut::Constants::Fields::CONTENT => options[:content]
  }.to_json
  MultiJson.decode(execute(Orkut::Constants::Fields::COMMENTS, Orkut::Constants::Action::INSERT, params, body.to_s, default_headers))
end