Class: Traktr::Movie

Inherits:
Endpoint show all
Defined in:
lib/traktr/movie.rb

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
# File 'lib/traktr/movie.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

#library(movies) ⇒ Object



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

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


8
9
10
11
# File 'lib/traktr/movie.rb', line 8

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), :basic_auth => @auth)
end

#seen(movies) ⇒ Object



56
57
58
59
60
# File 'lib/traktr/movie.rb', line 56

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

#stats(title) ⇒ Object



13
14
15
# File 'lib/traktr/movie.rb', line 13

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

#summaries(titles, extended = nil) ⇒ Object



22
23
24
25
26
# File 'lib/traktr/movie.rb', line 22

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



17
18
19
20
# File 'lib/traktr/movie.rb', line 17

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.to_s, extended), :basic_auth => @auth)
end

#unlibrary(movies) ⇒ Object



38
39
40
41
42
# File 'lib/traktr/movie.rb', line 38

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

#unseen(movies) ⇒ Object



62
63
64
65
66
# File 'lib/traktr/movie.rb', line 62

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

#unwatchlist(movies) ⇒ Object



50
51
52
53
54
# File 'lib/traktr/movie.rb', line 50

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

#watchingnow(title) ⇒ Object



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

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

#watchlist(movies) ⇒ Object



44
45
46
47
48
# File 'lib/traktr/movie.rb', line 44

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