Module: Orkut::Client::Timelines

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

Overview

Defines methods related to timelines

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

#home_timeline(options = {}) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/orkut/client/timelines.rb', line 51

def home_timeline(options={})
  params = {
    Orkut::Constants::Fields::USER_ID      => Orkut::Constants::InternalConstants::USERID_ME_SIMPLE,
    Orkut::Constants::Fields::COLLECTION   => Orkut::Constants::Collection::STREAM,
    Orkut::Constants::Fields::ALT          => Orkut::Constants::Params::JSON,
    Orkut::Constants::Fields::MAX_RESULTS  => (options[:count] || Orkut::Client::Base::DEFAULT_COUNT).to_s,
    Orkut::Constants::Fields::LANGUAGE     => (options[:language] || Orkut::Client::Base::DEFAULT_LANGUAGE),
    Orkut::Constants::Fields::EXTRA_PARAMS => options
  }
  unless options[:page_token].blank?
    params[Orkut::Constants::Fields::PAGE_TOKEN] = options[:page_token]
  end
  result = execute(Orkut::Constants::Fields::ACTIVITIES, Orkut::Constants::Action::LIST, params)
  begin
    MultiJson.decode(result)
  rescue StandardError => exception
    puts exception.message
    puts result.inspect
    puts params.inspect
  end
end

#home_timeline_v1(options = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/orkut/client/timelines.rb', line 17

def home_timeline_v1(options={})
  params = [{
    Orkut::Constants::Fields::PARAMS => {
      Orkut::Constants::Fields::GROUP_ID    => Orkut::Constants::Group::ALL,
      Orkut::Constants::Fields::USER_ID     => Orkut::Constants::InternalConstants::USERID_ME,
      Orkut::Constants::Fields::COUNT       => (options[:count] || Orkut::Client::Base::DEFAULT_COUNT),
      Orkut::Constants::Fields::COALESCE    => true,
      Orkut::Constants::Fields::START_INDEX => 0
    },
    Orkut::Constants::Fields::ID     => request_id.to_s+'-'+Orkut::Constants::MethodNames::ACTIVITIES_GET,
    Orkut::Constants::Fields::METHOD => Orkut::Constants::MethodNames::ACTIVITIES_GET
  }]
  unless options[:updated_before].blank?
    params.first[Orkut::Constants::Fields::PARAMS][Orkut::Constants::Fields::UPDATED_BEFORE] = format_datetime(options[:updated_before])
  end
  MultiJson.decode(post_v1(nil, params.to_s, default_headers).body)
end

#scraps_timeline(options = {}) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/orkut/client/timelines.rb', line 73

def scraps_timeline(options={})
  params = {
    Orkut::Constants::Fields::USER_ID      => Orkut::Constants::InternalConstants::USERID_ME_SIMPLE,
    Orkut::Constants::Fields::COLLECTION   => Orkut::Constants::Collection::SCRAPS,
    Orkut::Constants::Fields::ALT          => Orkut::Constants::Params::JSON,
    Orkut::Constants::Fields::MAX_RESULTS  => (options[:count] || Orkut::Client::Base::DEFAULT_COUNT).to_s,
    Orkut::Constants::Fields::LANGUAGE     => (options[:language] || Orkut::Client::Base::DEFAULT_LANGUAGE),
    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::ACTIVITIES, Orkut::Constants::Action::LIST, params))
end

#scraps_timeline_v1(options = {}) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/orkut/client/timelines.rb', line 35

def scraps_timeline_v1(options={})
  params = [{
    Orkut::Constants::Fields::PARAMS => {
      Orkut::Constants::Fields::PAGE_TYPE      => Orkut::Constants::Params::PageType::FIRST,
      Orkut::Constants::Fields::MESSAGE_TYPE   => Orkut::Constants::InternalConstants::Values::PUBLIC_MESSAGE,
      Orkut::Constants::Fields::GROUP_ID       => Orkut::Constants::Group::FRIENDS,
      Orkut::Constants::Fields::USER_ID        => Orkut::Constants::InternalConstants::USERID_ME,
      Orkut::Constants::Fields::COUNT          => (options[:count] || Orkut::Client::Base::DEFAULT_COUNT),
      Orkut::Constants::Fields::MESSAGE_FORMAT => Orkut::Constants::Params::MessageFormat::FULL_HTML
    },
    Orkut::Constants::Fields::ID     => request_id.to_s+'-'+Orkut::Constants::MethodNames::MESSAGES_GET,
    Orkut::Constants::Fields::METHOD => Orkut::Constants::MethodNames::MESSAGES_GET
  }]
  MultiJson.decode(post_v1(nil, params.to_s, default_headers).body)
end