Module: Orkut::Client::Messages

Includes:
Base
Included in:
Orkut::Client
Defined in:
lib/orkut/client/messages.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

#post_message(options = {}) ⇒ Object

Raises:



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/orkut/client/messages.rb', line 9

def post_message(options={})
  raise(Orkut::Error, "Parameters body cannot be nil") if options[:body].blank?
  params = [{
    Orkut::Constants::Fields::PARAMS => {
      Orkut::Constants::Fields::MESSAGE_TYPE => Orkut::Constants::InternalConstants::Values::PUBLIC_MESSAGE,
      Orkut::Constants::Fields::GROUP_ID => Orkut::Constants::Group::SELF,
      Orkut::Constants::Fields::USER_ID  => Orkut::Constants::InternalConstants::USERID_VIEWER,
      Orkut::Constants::Fields::APP_ID   => Orkut::Constants::InternalConstants::Values::APP,
      Orkut::Constants::Fields::ACTIVITY => {
        Orkut::Constants::Fields::TITLE => options[:title],
        Orkut::Constants::Fields::BODY  => options[:body]
      }
    },
    Orkut::Constants::Fields::ID     => request_id.to_s+'-'+Orkut::Constants::MethodNames::CREATE_ACTIVITIES,
    Orkut::Constants::Fields::METHOD => Orkut::Constants::MethodNames::CREATE_ACTIVITIES
  }]
  MultiJson.decode(post_v1(nil, params.to_s, default_headers).body)
end

#post_scrap(options = {}) ⇒ Object

Raises:



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

def post_scrap(options={})
  raise(Orkut::Error, "Parameters user_id and body cannot be nil") if options[:user_id].blank? and options[:body].blank?
  params = [{
    Orkut::Constants::Fields::PARAMS => {
      Orkut::Constants::Fields::MESSAGE_TYPE => Orkut::Constants::InternalConstants::Values::PUBLIC_MESSAGE,
      Orkut::Constants::Fields::GROUP_ID     => Orkut::Constants::Group::SELF,
      Orkut::Constants::Fields::USER_ID      => (options[:user_id] || Orkut::Constants::InternalConstants::USERID_VIEWER),
      Orkut::Constants::Fields::MESSAGE => {
        Orkut::Constants::Fields::BODY  => options[:body]
      }
    },
    Orkut::Constants::Fields::ID     => request_id.to_s+'-'+Orkut::Constants::MethodNames::MESSAGES_CREATE,
    Orkut::Constants::Fields::METHOD => Orkut::Constants::MethodNames::MESSAGES_CREATE
  }]
  MultiJson.decode(post_v1(nil, params.to_s, default_headers).body)
end

#update_status(options = {}) ⇒ Object

Raises:



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/orkut/client/messages.rb', line 45

def update_status(options={})
  raise(Orkut::Error, "Parameters body cannot be nil") if options[:body].blank?
  params = [{
    Orkut::Constants::Fields::PARAMS => {
      Orkut::Constants::Fields::GROUP_ID     => Orkut::Constants::Group::SELF,
      Orkut::Constants::Fields::USER_ID      => Orkut::Constants::InternalConstants::USERID_ME,
      Orkut::Constants::Fields::PERSON => {
        Orkut::Constants::Fields::STATUS  => options[:status]
      }
    },
    Orkut::Constants::Fields::ID     => request_id.to_s+'-'+Orkut::Constants::MethodNames::PEOPLE_UPDATE,
    Orkut::Constants::Fields::METHOD => Orkut::Constants::MethodNames::PEOPLE_UPDATE
  }]
  MultiJson.decode(post_v1(nil, params.to_s, default_headers).body)
end