Module: Totter::Client::Timelines

Included in:
Totter::Client
Defined in:
lib/totter/client/timelines.rb

Overview

Client methods for working with timelines.

Constant Summary collapse

DEFAULT_TIMELINE_OPTIONS =

Default options sent with every timeline request unless otherwise specified.

{
  :limit => 20
}

Instance Method Summary collapse

Instance Method Details

#flagged_timeline(options = DEFAULT_TIMELINE_OPTIONS) ⇒ Array

Get recent decisions from the flagged-for-review timeline

Examples:

Totter.global_timeline(limit: 20, since: '1,15')

Parameters:

  • options (Hash) (defaults to: DEFAULT_TIMELINE_OPTIONS)

    Parameters for returning selected items

Options Hash (options):

  • :limit (Numeric)

    Number of items to return. Default is 20

  • :since (String)

    A user_id/decision_id pair in the format ‘1,15’ when paging forward

  • :until (String)

    A user_id/decision_id pair in the format ‘1,15’ when paging backwards

Returns:

  • (Array)

    An array of ‘Hashie::Mash` objects representing decisions



86
87
88
# File 'lib/totter/client/timelines.rb', line 86

def flagged_timeline(options = DEFAULT_TIMELINE_OPTIONS)
  format_timeline_result get('timelines/flagged', options)
end

#friends_timeline(user_id, options = DEFAULT_TIMELINE_OPTIONS) ⇒ Array

Get the friends timeline (also known as “feed” or “home”) for a given user. Note, you must use the user ID that belongs to the access token as the ‘user_id` parameter.

Requires authenticatied client.

Examples:

Totter.friends_timeline(4, limit: 20, since: '1,15')

Parameters:

  • user_id (Fixnum)

    The user ID for the timeline you are trying to view.

  • options (Hash) (defaults to: DEFAULT_TIMELINE_OPTIONS)

    Parameters for returning selected items

Options Hash (options):

  • :limit (Numeric)

    Number of items to return. Default is 20

  • :since (String)

    A user_id/decision_id pair in the format ‘1,15’ when paging forward

  • :until (String)

    A user_id/decision_id pair in the format ‘1,15’ when paging backwards

Returns:

  • (Array)

    An array of ‘Hashie::Mash` objects representing decisions



117
118
119
# File 'lib/totter/client/timelines.rb', line 117

def friends_timeline(user_id, options = DEFAULT_TIMELINE_OPTIONS)
  format_timeline_result get("users/#{user_id}/timelines/friends", options)
end

#global_timeline(options = DEFAULT_TIMELINE_OPTIONS) ⇒ Array

Get recent decisions from the global timeline.

Examples:

Totter.global_timeline(limit: 20, since: '1,15')

Parameters:

  • options (Hash) (defaults to: DEFAULT_TIMELINE_OPTIONS)

    Parameters for returning selected items

Options Hash (options):

  • :limit (Numeric)

    Number of items to return. Default is 20

  • :since (String)

    A user_id/decision_id pair in the format ‘1,15’ when paging forward

  • :until (String)

    A user_id/decision_id pair in the format ‘1,15’ when paging backwards

Returns:

  • (Array)

    An array of ‘Hashie::Mash` objects representing decisions



19
20
21
# File 'lib/totter/client/timelines.rb', line 19

def global_timeline(options = DEFAULT_TIMELINE_OPTIONS)
  format_timeline_result get('timelines/global', options)
end

#hashtag_timeline(hashtag, options = DEFAULT_TIMELINE_OPTIONS) ⇒ Array

Get recent decisions from a hashtag timeline

Examples:

Totter.global_timeline(limit: 20, since: '1,15')

Parameters:

  • hashtag (String)

    The hashtag to return

  • options (Hash) (defaults to: DEFAULT_TIMELINE_OPTIONS)

    Parameters for returning selected items

Options Hash (options):

  • :limit (Numeric)

    Number of items to return. Default is 20

  • :since (String)

    A user_id/decision_id pair in the format ‘1,15’ when paging forward

  • :until (String)

    A user_id/decision_id pair in the format ‘1,15’ when paging backwards

Returns:

  • (Array)

    An array of ‘Hashie::Mash` objects representing decisions



33
34
35
# File 'lib/totter/client/timelines.rb', line 33

def hashtag_timeline(hashtag, options = DEFAULT_TIMELINE_OPTIONS)
  format_timeline_result get('timelines/global', options.merge({:hashtag => hashtag}))
end

#random_timeline_decision(options = {}) ⇒ Object

Get random decision from current timeline

Examples:

Totter.random_timeline_decision(hashtag: 'testhashtag')

Parameters:

  • options (Hash) (defaults to: {})

    Parameters for returning selected item, defaults to golbal timeline

Options Hash (options):

  • :hashtag (String)

    The hashtag timeline to use for random decision

  • :sticker (String)

    The sticker timeline to use for random decision

Returns:

  • Decision A ‘Hashie::Mash` object representing a random decision



59
60
61
# File 'lib/totter/client/timelines.rb', line 59

def random_timeline_decision(options = {})
  get('timelines/global/random', options.merge({:limit => 1})).body
end

#search_timeline(query, options = DEFAULT_TIMELINE_OPTIONS) ⇒ Array

Search for published items

Examples:

Totter.global_timeline(limit: 20, since: '1,15')

Parameters:

  • query (String)

    The query to search for

  • options (Hash) (defaults to: DEFAULT_TIMELINE_OPTIONS)

    Parameters for returning selected items

Options Hash (options):

  • :limit (Numeric)

    Number of items to return. Default is 20

  • :since (String)

    A user_id/decision_id pair in the format ‘1,15’ when paging forward

  • :until (String)

    A user_id/decision_id pair in the format ‘1,15’ when paging backwards

Returns:

  • (Array)

    An array of ‘Hashie::Mash` objects representing decisions



73
74
75
# File 'lib/totter/client/timelines.rb', line 73

def search_timeline(query, options = DEFAULT_TIMELINE_OPTIONS)
  format_timeline_result get('timelines/search', options.merge({:query => query}))
end

#sticker_timeline(sticker, options = DEFAULT_TIMELINE_OPTIONS) ⇒ Array

Get recent decisions from a sticker timeline

Examples:

Totter.global_timeline(limit: 20, since: '1,15')

Parameters:

  • sticker (String)

    The sticker to return

  • options (Hash) (defaults to: DEFAULT_TIMELINE_OPTIONS)

    Parameters for returning selected items

Options Hash (options):

  • :limit (Numeric)

    Number of items to return. Default is 20

  • :since (String)

    A user_id/decision_id pair in the format ‘1,15’ when paging forward

  • :until (String)

    A user_id/decision_id pair in the format ‘1,15’ when paging backwards

Returns:

  • (Array)


47
48
49
# File 'lib/totter/client/timelines.rb', line 47

def sticker_timeline(sticker, options = DEFAULT_TIMELINE_OPTIONS)
  format_timeline_result get('timelines/global', options.merge({:sticker => sticker}))
end

#user_timeline(user_id, options = DEFAULT_TIMELINE_OPTIONS) ⇒ Array

Get recent decisions from a given user.

Examples:

Totter.user_timeline(4, limit: 20, since: '1,15')

Parameters:

  • user_id (Fixnum)

    The user ID for the timeline you are trying to view.

  • options (Hash) (defaults to: DEFAULT_TIMELINE_OPTIONS)

    Parameters for returning selected items

Options Hash (options):

  • :limit (Numeric)

    Number of items to return. Default is 20

  • :since (String)

    A user_id/decision_id pair in the format ‘1,15’ when paging forward

  • :until (String)

    A user_id/decision_id pair in the format ‘1,15’ when paging backwards

Returns:

  • (Array)

    An array of ‘Hashie::Mash` objects representing decisions



100
101
102
# File 'lib/totter/client/timelines.rb', line 100

def user_timeline(user_id, options = DEFAULT_TIMELINE_OPTIONS)
  format_timeline_result get("users/#{user_id}/timelines/user", options)
end