Class: Traktr::Activity

Inherits:
Endpoint show all
Defined in:
lib/traktr/activity.rb,
lib/traktr/activity/user.rb

Defined Under Namespace

Classes: User

Instance Method Summary collapse

Methods inherited from Endpoint

#initialize

Constructor Details

This class inherits a constructor from Traktr::Endpoint

Instance Method Details

#community(types = :all, actions = :all, start_ts = 0, end_ts = Time.now.to_i) ⇒ Object



3
4
5
6
7
# File 'lib/traktr/activity.rb', line 3

def community(types = :all, actions = :all, start_ts = 0, end_ts = Time.now.to_i)
  types   =   types.class == Array ?   types.join(",") :   types.to_s
  actions = actions.class == Array ? actions.join(",") : actions.to_s
  parse_response self.class.get('/' + File.join('community.json', @client.api_key, types, actions, start_ts.to_s, end_ts.to_s))
end

#episodes(title, season, episode, actions = :all, start_ts = 0, end_ts = Time.now.to_i) ⇒ Object



9
10
11
12
# File 'lib/traktr/activity.rb', line 9

def episodes(title, season, episode, actions = :all, start_ts = 0, end_ts = Time.now.to_i)
  actions = actions.class == Array ? actions.join(",") : actions.to_s
  parse_response self.class.get('/' + File.join('episodes.json', @client.api_key, title, season.to_s, episode.to_s, actions, start_ts.to_s, end_ts.to_s))
end

#friends(types = :all, actions = :all, start_ts = 0, end_ts = Time.now.to_i) ⇒ Object



39
40
41
42
43
# File 'lib/traktr/activity.rb', line 39

def friends(types = :all, actions = :all, start_ts = 0, end_ts = Time.now.to_i)
  types   =   types.class == Array ?   types.join(",") :   types.to_s
  actions = actions.class == Array ? actions.join(",") : actions.to_s
  parse_response self.class.post('/' + File.join('friends.json', @client.api_key, types, actions, start_ts.to_s, end_ts.to_s), body: @auth.to_json, headers: { 'Content-Type' => 'application/json'})
end

#movies(title, actions = :all, start_ts = 0, end_ts = Time.now.to_i) ⇒ Object



14
15
16
17
# File 'lib/traktr/activity.rb', line 14

def movies(title, actions = :all, start_ts = 0, end_ts = Time.now.to_i)
  actions = actions.class == Array ? actions.join(",") : actions.to_s
  parse_response self.class.get('/' + File.join('movies.json', @client.api_key, title, actions, start_ts.to_s, end_ts.to_s))
end

#seasons(title, season, actions = :all, start_ts = 0, end_ts = Time.now.to_i) ⇒ Object



19
20
21
22
# File 'lib/traktr/activity.rb', line 19

def seasons(title, season, actions = :all, start_ts = 0, end_ts = Time.now.to_i)
  actions = actions.class == Array ? actions.join(",") : actions.to_s
  parse_response self.class.get('/' + File.join('seasons.json', @client.api_key, title, season.to_s, actions, start_ts.to_s, end_ts.to_s))
end

#shows(title, actions = :all, start_ts = 0, end_ts = Time.now.to_i) ⇒ Object



24
25
26
27
# File 'lib/traktr/activity.rb', line 24

def shows(title, actions = :all, start_ts = 0, end_ts = Time.now.to_i)
  actions = actions.class == Array ? actions.join(",") : actions.to_s
  parse_response self.class.get('/' + File.join('shows.json', @client.api_key, title, actions, start_ts.to_s, end_ts.to_s))
end

#user(username = nil, types = :all, actions = :all, start_ts = 0, end_ts = Time.now.to_i) ⇒ Object



29
30
31
32
33
34
35
36
37
# File 'lib/traktr/activity.rb', line 29

def user(username = nil, types = :all, actions = :all, start_ts = 0, end_ts = Time.now.to_i)
  if username
    types   =   types.class == Array ?   types.join(",") :   types.to_s
    actions = actions.class == Array ? actions.join(",") : actions.to_s
    parse_response self.class.get('/' + File.join('user.json', @client.api_key, username, types, actions, start_ts.to_s, end_ts.to_s))
  else
    @user ||= Traktr::Activity::User.new(@client)
  end
end