Class: Traktr::Show

Inherits:
Endpoint show all
Defined in:
lib/traktr/show.rb,
lib/traktr/show/season.rb,
lib/traktr/show/episode.rb

Defined Under Namespace

Classes: Episode, Season

Instance Method Summary collapse

Methods inherited from Endpoint

#initialize

Constructor Details

This class inherits a constructor from Traktr::Endpoint

Instance Method Details

#comments(title, type = :all) ⇒ Object



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

def comments(title, type = :all)
  type = [:all, :shouts, :reviews].include?(type) ? type.to_s : ""
  parse_response self.class.get("/" + File.join("comments.json", @client.api_key, title, type))

end

#episodeObject



74
75
76
# File 'lib/traktr/show.rb', line 74

def episode
  @episode ||= Traktr::Show::Episode.new(@client)
end

#library(show) ⇒ Object



47
48
49
50
# File 'lib/traktr/show.rb', line 47

def library(show)
  data = @auth.merge(show)
  parse_response self.class.post("/" + File.join("library", @client.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
end


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

def related(title, hidewatched = nil)
  hidewatched = hidewatched == false || hidewatched == nil ? "" : "hidewatched"
  parse_response self.class.get("/" + File.join("related.json", @client.api_key, title, hidewatched.to_s), :basic_auth => @auth)
end

#season(title = nil, season = nil) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/traktr/show.rb', line 14

def season(title = nil, season = nil)
  if title && season
    parse_response self.class.get("/" + File.join("season.json", @client.api_key, title, season.to_s), :basic_auth => @auth)
  elsif !title && !season
    @season ||= Traktr::Show::Season.new(@client)
  else
    raise ArgumentError.new("wrong number of arguments")
  end
end

#seasons(title) ⇒ Object



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

def seasons(title)
  parse_response self.class.get("/" + File.join("seasons.json", @client.api_key, title))
end

#seen(show) ⇒ Object



69
70
71
72
# File 'lib/traktr/show.rb', line 69

def seen(show)
  data = @auth.merge(show)
  parse_response self.class.post("/" + File.join("seen", @client.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
end

#stats(title) ⇒ Object



28
29
30
# File 'lib/traktr/show.rb', line 28

def stats(title)
  parse_response self.class.get('/' + File.join('stats.json', @client.api_key, title))
end

#summaries(titles, extended = nil) ⇒ Object



37
38
39
40
41
# File 'lib/traktr/show.rb', line 37

def summaries(titles, extended = nil)
  titles   = titles.join(",") if titles.class == Array
  extended = [:normal, :full].include?(extended) ? extended.to_s : ""
  parse_response self.class.get("/" + File.join("summaries.json", @client.api_key, titles, extended))
end

#summary(title, extended = nil) ⇒ Object



32
33
34
35
# File 'lib/traktr/show.rb', line 32

def summary(title, extended = nil)
  extended = [:normal, :full].include?(extended) ? extended.to_s : ""
  parse_response self.class.get("/" + File.join("summary.json", @client.api_key, title, extended), :basic_auth => @auth)
end

#unlibrary(show) ⇒ Object



52
53
54
55
# File 'lib/traktr/show.rb', line 52

def unlibrary(show)
  data = @auth.merge(show)
  parse_response self.class.post("/" + File.join("unlibrary", @client.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
end

#unwatchlist(shows) ⇒ Object



63
64
65
66
67
# File 'lib/traktr/show.rb', line 63

def unwatchlist(shows)
  shows = [ shows ] if shows.class != Array
  data = @auth.merge({ shows: shows })
  parse_response self.class.post("/" + File.join("unwatchlist", @client.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
end

#watchingnow(title) ⇒ Object



43
44
45
# File 'lib/traktr/show.rb', line 43

def watchingnow(title)
  parse_response self.class.get("/" + File.join("watchingnow.json", @client.api_key, title), :basic_auth => @auth)
end

#watchlist(shows) ⇒ Object



57
58
59
60
61
# File 'lib/traktr/show.rb', line 57

def watchlist(shows)
  shows = [ shows ] if shows.class != Array
  data = @auth.merge({ shows: shows })
  parse_response self.class.post("/" + File.join("watchlist", @client.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
end