trakt_api 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +19 -0
  3. data/.travis.yml +4 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +252 -0
  7. data/Rakefile +1 -0
  8. data/lib/generators/templates/trakt_api.rb +5 -0
  9. data/lib/generators/trakt_api/install_generator.rb +12 -0
  10. data/lib/trakt_api.rb +22 -0
  11. data/lib/trakt_api/account.rb +16 -0
  12. data/lib/trakt_api/activity.rb +109 -0
  13. data/lib/trakt_api/base.rb +93 -0
  14. data/lib/trakt_api/calendar.rb +17 -0
  15. data/lib/trakt_api/client.rb +74 -0
  16. data/lib/trakt_api/comment.rb +16 -0
  17. data/lib/trakt_api/configuration.rb +7 -0
  18. data/lib/trakt_api/genres.rb +11 -0
  19. data/lib/trakt_api/lists.rb +26 -0
  20. data/lib/trakt_api/movie.rb +86 -0
  21. data/lib/trakt_api/movies.rb +11 -0
  22. data/lib/trakt_api/network.rb +26 -0
  23. data/lib/trakt_api/rate.rb +31 -0
  24. data/lib/trakt_api/recommendations.rb +21 -0
  25. data/lib/trakt_api/search.rb +26 -0
  26. data/lib/trakt_api/server.rb +6 -0
  27. data/lib/trakt_api/show.rb +152 -0
  28. data/lib/trakt_api/shows.rb +11 -0
  29. data/lib/trakt_api/user.rb +124 -0
  30. data/lib/trakt_api/version.rb +3 -0
  31. data/spec/integration_spec_helper.rb +3 -0
  32. data/spec/integrations/account_spec.rb +19 -0
  33. data/spec/integrations/calendar_spec.rb +31 -0
  34. data/spec/integrations/client_spec.rb +173 -0
  35. data/spec/integrations/genres_spec.rb +19 -0
  36. data/spec/integrations/movies_spec.rb +25 -0
  37. data/spec/integrations/network_spec.rb +37 -0
  38. data/spec/integrations/search_spec.rb +37 -0
  39. data/spec/integrations/server_spec.rb +13 -0
  40. data/spec/integrations/shows_spec.rb +25 -0
  41. data/spec/integrations/support/trakt_api.rb.example +5 -0
  42. data/spec/spec_helper.rb +43 -0
  43. data/spec/trakt_api/account_spec.rb +56 -0
  44. data/spec/trakt_api/activity_spec.rb +297 -0
  45. data/spec/trakt_api/base_spec.rb +147 -0
  46. data/spec/trakt_api/calendar_spec.rb +48 -0
  47. data/spec/trakt_api/client_spec.rb +101 -0
  48. data/spec/trakt_api/comment_spec.rb +69 -0
  49. data/spec/trakt_api/genres_spec.rb +24 -0
  50. data/spec/trakt_api/lists_spec.rb +111 -0
  51. data/spec/trakt_api/movie_spec.rb +333 -0
  52. data/spec/trakt_api/movies_spec.rb +38 -0
  53. data/spec/trakt_api/network_spec.rb +105 -0
  54. data/spec/trakt_api/rate_spec.rb +132 -0
  55. data/spec/trakt_api/recommendations_spec.rb +90 -0
  56. data/spec/trakt_api/search_spec.rb +81 -0
  57. data/spec/trakt_api/server_spec.rb +15 -0
  58. data/spec/trakt_api/show_spec.rb +588 -0
  59. data/spec/trakt_api/shows_spec.rb +38 -0
  60. data/spec/trakt_api/user_spec.rb +561 -0
  61. data/trakt_api.gemspec +29 -0
  62. metadata +232 -0
@@ -0,0 +1,6 @@
1
+ class TraktApi::Server < TraktApi::Base
2
+ # documentation: http://trakt.tv/api-docs/server-time
3
+ def time
4
+ get('server/time').response
5
+ end
6
+ end
@@ -0,0 +1,152 @@
1
+ class TraktApi::Show < TraktApi::Base
2
+ # documentation: http://trakt.tv/api-docs/show-cancelcheckin
3
+ def cancel_checkin
4
+ auth.post('show/cancelcheckin').response
5
+ end
6
+
7
+ # documentation: http://trakt.tv/api-docs/show-cancelwatching
8
+ def cancel_watching
9
+ auth.post('show/cancelwatching').response
10
+ end
11
+
12
+ # documentation: http://trakt.tv/api-docs/show-checkin
13
+ def check_in(options = {})
14
+ auth.post('show/checkin').params(options).response
15
+ end
16
+
17
+ # documentation: http://trakt.tv/api-docs/show-comments
18
+ def comments(options = {})
19
+ get('show/comments').restful_params(options, [:title, :type]).response
20
+ end
21
+
22
+ # documentation: http://trakt.tv/api-docs/show-episode-comments
23
+ def episode_comments(options = {})
24
+ get('show/episode/comments').restful_params(options, [:title, :season, :episode, :type]).response
25
+ end
26
+
27
+ # documentation: http://trakt.tv/api-docs/show-episode-library
28
+ def episode_library(options = {})
29
+ auth.post('show/episode/library').params(options).response
30
+ end
31
+
32
+ # documentation: http://trakt.tv/api-docs/show-episode-seen
33
+ def episode_seen(options = {})
34
+ auth.post('show/episode/seen').params(options).response
35
+ end
36
+
37
+ # documentation: http://trakt.tv/api-docs/show-episode-stats
38
+ def episode_stats(options = {})
39
+ get('show/episode/stats').restful_params(options, [:title, :season, :episode]).response
40
+ end
41
+
42
+ # documentation: http://trakt.tv/api-docs/show-episode-summary
43
+ def episode_summary(options = {})
44
+ optional_auth(options).get('show/episode/summary').restful_params(options, [:title, :season, :episode]).response
45
+ end
46
+
47
+ # documentation: http://trakt.tv/api-docs/show-episode-unlibrary
48
+ def episode_unlibrary(options = {})
49
+ auth.post('show/episode/unlibrary').params(options).response
50
+ end
51
+
52
+ # documentation: http://trakt.tv/api-docs/show-episode-unseen
53
+ def episode_unseen(options = {})
54
+ auth.post('show/episode/unseen').params(options).response
55
+ end
56
+
57
+ # documentation: http://trakt.tv/api-docs/show-episode-unwatchlist
58
+ def episode_unwatch_list(options = {})
59
+ auth.post('show/episode/unwatchlist').params(options).response
60
+ end
61
+
62
+ # documentation: http://trakt.tv/api-docs/show-episode-watchingnow
63
+ def episode_watching_now(options = {})
64
+ optional_auth(options).get('show/episode/watchingnow').restful_params(options, [:title, :season, :episode]).
65
+ response
66
+ end
67
+
68
+ # documentation: http://trakt.tv/api-docs/show-episode-watchlist
69
+ def episode_watch_list(options = {})
70
+ auth.post('show/episode/watchlist').params(options).response
71
+ end
72
+
73
+ # documentation: http://trakt.tv/api-docs/show-library
74
+ def library(options = {})
75
+ auth.post('show/library').params(options).response
76
+ end
77
+
78
+ # documentation: http://trakt.tv/api-docs/show-related
79
+ def related(options = {})
80
+ optional_auth(options).get('show/related').restful_params(options, [:title, :extended, :hidewatched]).response
81
+ end
82
+
83
+ # documentation: http://trakt.tv/api-docs/show-scrobble
84
+ def scrobble(options = {})
85
+ auth.post('show/scrobble').params(options).response
86
+ end
87
+
88
+ # documentation: http://trakt.tv/api-docs/show-season
89
+ def season(options = {})
90
+ optional_auth(options).get('show/season').restful_params(options, [:title, :season]).response
91
+ end
92
+
93
+ # documentation: http://trakt.tv/api-docs/show-season-library
94
+ def season_library(options = {})
95
+ auth.post('show/season/library').params(options).response
96
+ end
97
+
98
+ # documentation: http://trakt.tv/api-docs/show-season-seen
99
+ def season_seen(options = {})
100
+ auth.post('show/season/seen').params(options).response
101
+ end
102
+
103
+ # documentation: http://trakt.tv/api-docs/show-seasons
104
+ def seasons(options = {})
105
+ get('show/seasons').restful_params(options, [:title]).response
106
+ end
107
+
108
+ # documentation: http://trakt.tv/api-docs/show-seen
109
+ def seen(options = {})
110
+ auth.post('show/seen').params(options).response
111
+ end
112
+
113
+ # documentation: http://trakt.tv/api-docs/show-stats
114
+ def stats(options = {})
115
+ get('show/stats').restful_params(options, [:title]).response
116
+ end
117
+
118
+ # documentation: http://trakt.tv/api-docs/show-summary
119
+ def summary(options = {})
120
+ optional_auth(options).get('show/summary').restful_params(options, [:title, :extended]).response
121
+ end
122
+
123
+ # documentation: http://trakt.tv/api-docs/show-summaries
124
+ def summaries(options = {})
125
+ get('show/summaries').restful_params(options, [:title, :extended]).response
126
+ end
127
+
128
+ # documentation: http://trakt.tv/api-docs/show-unlibrary
129
+ def unlibrary(options = {})
130
+ auth.post('show/unlibrary').params(options).response
131
+ end
132
+
133
+ # documentation: http://trakt.tv/api-docs/show-unwatchlist
134
+ def unwatch_list(options = {})
135
+ auth.post('show/unwatchlist').params(options).response
136
+ end
137
+
138
+ # documentation: http://trakt.tv/api-docs/show-watching
139
+ def watching(options = {})
140
+ auth.post('show/watching').params(options).response
141
+ end
142
+
143
+ # documentation: http://trakt.tv/api-docs/show-watchingnow
144
+ def watching_now(options = {})
145
+ optional_auth(options).get('show/watchingnow').restful_params(options, [:title]).response
146
+ end
147
+
148
+ # documentation: http://trakt.tv/api-docs/show-watchlist
149
+ def watch_list(options = {})
150
+ auth.post('show/watchlist').params(options).response
151
+ end
152
+ end
@@ -0,0 +1,11 @@
1
+ class TraktApi::Shows < TraktApi::Base
2
+ # documentation: http://trakt.tv/api-docs/shows-trending
3
+ def trending(options = {})
4
+ optional_auth(options).get('shows/trending').response
5
+ end
6
+
7
+ # documentation: http://trakt.tv/api-docs/shows-updated
8
+ def updated(options = {})
9
+ get('shows/updated').restful_params(options, [:time]).response
10
+ end
11
+ end
@@ -0,0 +1,124 @@
1
+ class TraktApi::User < TraktApi::Base
2
+ # documentation: http://trakt.tv/api-docs/user-calendar-shows
3
+ def calendar_shows(options = {})
4
+ optional_auth(options).get('user/calendar/shows').restful_params(options, [:username, :date, :days]).response
5
+ end
6
+
7
+ # documentation: http://trakt.tv/api-docs/user-lastactivity
8
+ def last_activity(options = {})
9
+ optional_auth(options).get('user/lastactivity').restful_params(options, [:username]).response
10
+ end
11
+
12
+ # documentation: http://trakt.tv/api-docs/user-library-movies-all
13
+ def library_movies_all(options = {})
14
+ optional_auth(options).get('user/library/movies/all').restful_params(options, [:username]).params(options).response
15
+ end
16
+
17
+ # documentation: http://trakt.tv/api-docs/user-library-movies-collection
18
+ def library_movies_collection(options = {})
19
+ optional_auth(options).get('user/library/movies/collection').restful_params(options, [:username]).params(options).
20
+ response
21
+ end
22
+
23
+ # documentation: http://trakt.tv/api-docs/user-library-movies-watched
24
+ def library_movies_watched(options = {})
25
+ optional_auth(options).get('user/library/movies/watched').restful_params(options, [:username]).params(options).
26
+ response
27
+ end
28
+
29
+ # documentation: http://trakt.tv/api-docs/user-library-shows-all
30
+ def library_shows_all(options = {})
31
+ optional_auth(options).get('user/library/shows/all').restful_params(options, [:username]).params(options).
32
+ response
33
+ end
34
+
35
+ # documentation: http://trakt.tv/api-docs/user-library-shows-collection
36
+ def library_shows_collection(options = {})
37
+ optional_auth(options).get('user/library/shows/collection').restful_params(options, [:username]).params(options).
38
+ response
39
+ end
40
+
41
+ # documentation: http://trakt.tv/api-docs/user-library-shows-watched
42
+ def library_shows_watched(options = {})
43
+ optional_auth(options).get('user/library/shows/watched').restful_params(options, [:username]).params(options).
44
+ response
45
+ end
46
+
47
+ # documentation: http://trakt.tv/api-docs/user-list
48
+ def list(options = {})
49
+ optional_auth(options).get('user/list').restful_params(options, [:username, :slug]).params(options).response
50
+ end
51
+
52
+ # documentation: http://trakt.tv/api-docs/user-lists
53
+ def lists(options = {})
54
+ optional_auth(options).get('user/lists').restful_params(options, [:username]).params(options).response
55
+ end
56
+
57
+ # documentation: http://trakt.tv/api-docs/user-network-followers
58
+ def network_followers(options = {})
59
+ optional_auth(options).get('user/network/followers').restful_params(options, [:username]).params(options).response
60
+ end
61
+
62
+ # documentation: http://trakt.tv/api-docs/user-network-following
63
+ def network_following(options = {})
64
+ optional_auth(options).get('user/network/following').restful_params(options, [:username]).params(options).response
65
+ end
66
+
67
+ # documentation: http://trakt.tv/api-docs/user-network-friends
68
+ def network_friends(options = {})
69
+ optional_auth(options).get('user/network/friends').restful_params(options, [:username]).params(options).response
70
+ end
71
+
72
+ # documentation: http://trakt.tv/api-docs/user-profile
73
+ def profile(options = {})
74
+ optional_auth(options).get('user/profile').restful_params(options, [:username]).params(options).response
75
+ end
76
+
77
+ # documentation: http://trakt.tv/api-docs/user-progress-collected
78
+ def progress_collected(options = {})
79
+ optional_auth(options).get('user/progress/collected').
80
+ restful_params(options, [:username, :title, :sort, :extended]).response
81
+ end
82
+
83
+ # documentation: http://trakt.tv/api-docs/user-progress-watched
84
+ def progress_watched(options = {})
85
+ optional_auth(options).get('user/progress/watched').restful_params(options, [:username, :title, :sort, :extended]).
86
+ response
87
+ end
88
+
89
+ # documentation: http://trakt.tv/api-docs/user-ratings-episodes
90
+ def ratings_episodes(options = {})
91
+ optional_auth(options).get('user/ratings/episodes').restful_params(options, [:username, :rating, :extended]).
92
+ response
93
+ end
94
+
95
+ # documentation: http://trakt.tv/api-docs/user-ratings-movies
96
+ def ratings_movies(options = {})
97
+ optional_auth(options).get('user/ratings/movies').restful_params(options, [:username, :rating, :extended]).response
98
+ end
99
+
100
+ # documentation: http://trakt.tv/api-docs/user-ratings-shows
101
+ def ratings_shows(options = {})
102
+ optional_auth(options).get('user/ratings/shows').restful_params(options, [:username, :rating, :extended]).response
103
+ end
104
+
105
+ # documentation: http://trakt.tv/api-docs/user-watching
106
+ def watching(options = {})
107
+ optional_auth(options).get('user/watching').restful_params(options, [:username]).response
108
+ end
109
+
110
+ # documentation: http://trakt.tv/api-docs/user-watchlist-episodes
111
+ def watchlist_episode(options = {})
112
+ optional_auth(options).get('user/watchlist/episodes').restful_params(options, [:username]).response
113
+ end
114
+
115
+ # documentation: http://trakt.tv/api-docs/user-watchlist-movies
116
+ def watchlist_movies(options = {})
117
+ optional_auth(options).get('user/watchlist/movies').restful_params(options, [:username]).response
118
+ end
119
+
120
+ # documentation: http://trakt.tv/api-docs/user-watchlist-shows
121
+ def watchlist_shows(options = {})
122
+ optional_auth(options).get('user/watchlist/shows').restful_params(options, [:username]).response
123
+ end
124
+ end
@@ -0,0 +1,3 @@
1
+ module TraktApi
2
+ VERSION = '0.0.2'
3
+ end
@@ -0,0 +1,3 @@
1
+ require 'spec_helper'
2
+
3
+ require File.join(File.dirname(__FILE__), 'integrations/support/trakt_api.rb')
@@ -0,0 +1,19 @@
1
+ require 'integration_spec_helper'
2
+
3
+ describe TraktApi::Account do
4
+ let(:model) { TraktApi::Account.new(TraktApi::Client.new) }
5
+
6
+ describe 'real request' do
7
+ describe '.settings' do
8
+ it 'should return response class' do
9
+ model.settings.class.should == HTTParty::Response
10
+ end
11
+ end
12
+
13
+ describe '.test' do
14
+ it 'should return response class' do
15
+ model.test.class.should == HTTParty::Response
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,31 @@
1
+ require 'integration_spec_helper'
2
+
3
+ describe TraktApi::Calendar do
4
+ let(:model) { TraktApi::Calendar.new(TraktApi::Client.new) }
5
+
6
+ describe 'real request' do
7
+ describe '.premieres' do
8
+ it 'should return response class' do
9
+ model.premieres.class.should == HTTParty::Response
10
+ end
11
+
12
+ describe 'with authentication' do
13
+ it 'should return response class' do
14
+ model.premieres(date: Date.today, days: 7, auth: true).class.should == HTTParty::Response
15
+ end
16
+ end
17
+ end
18
+
19
+ describe '.shows' do
20
+ it 'should return response class' do
21
+ model.shows.class.should == HTTParty::Response
22
+ end
23
+
24
+ describe 'with authentication' do
25
+ it 'should return response class' do
26
+ model.shows(date: Date.today, days: 7, auth: true).class.should == HTTParty::Response
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,173 @@
1
+ require 'integration_spec_helper'
2
+
3
+ describe TraktApi::Client do
4
+ let(:client) { TraktApi::Client.new }
5
+
6
+ describe 'real request' do
7
+ describe '.account' do
8
+ describe '.settings' do
9
+ it 'should return response class' do
10
+ client.account.settings.class.should == HTTParty::Response
11
+ end
12
+ end
13
+
14
+ describe '.test' do
15
+ it 'should return hash' do
16
+ client.account.test.class.should == HTTParty::Response
17
+ end
18
+ end
19
+ end
20
+
21
+ describe '.calendar' do
22
+ describe '.premieres' do
23
+ it 'should return response class' do
24
+ client.calendar.premieres.class.should == HTTParty::Response
25
+ end
26
+
27
+ describe 'with authentication' do
28
+ it 'should return response class' do
29
+ client.calendar.premieres(date: Date.today, days: 7, auth: true).class.should == HTTParty::Response
30
+ end
31
+ end
32
+ end
33
+
34
+ describe '.shows' do
35
+ it 'should return response class' do
36
+ client.calendar.shows.class.should == HTTParty::Response
37
+ end
38
+
39
+ describe 'with authentication' do
40
+ it 'should return response class' do
41
+ client.calendar.shows(date: Date.today, days: 7, auth: true).class.should == HTTParty::Response
42
+ end
43
+ end
44
+ end
45
+ end
46
+
47
+ describe '.genres' do
48
+ describe '.movies' do
49
+ it 'should return response class' do
50
+ client.genres.movies.class.should == HTTParty::Response
51
+ end
52
+ end
53
+
54
+ describe '.shows' do
55
+ it 'should return response class' do
56
+ client.genres.shows.class.should == HTTParty::Response
57
+ end
58
+ end
59
+ end
60
+
61
+ describe '.movies' do
62
+ describe '.trending' do
63
+ it 'should return response class' do
64
+ client.movies.trending.class.should == HTTParty::Response
65
+ end
66
+
67
+ describe 'with authentication' do
68
+ it 'should return response class' do
69
+ client.movies.trending(auth: true).class.should == HTTParty::Response
70
+ end
71
+ end
72
+ end
73
+
74
+ describe '.updated' do
75
+ it 'should return response class' do
76
+ client.movies.updated(time: Time.now).class.should == HTTParty::Response
77
+ end
78
+ end
79
+ end
80
+
81
+ describe '.network' do
82
+ describe '.approve' do
83
+ it 'should return response class' do
84
+ client.network.approve(user: 'justin').class.should == HTTParty::Response
85
+ end
86
+ end
87
+
88
+ describe '.deny' do
89
+ it 'should return response class' do
90
+ client.network.deny(user: 'justin').class.should == HTTParty::Response
91
+ end
92
+ end
93
+
94
+ describe '.follow' do
95
+ it 'should return response class' do
96
+ client.network.follow(user: 'justin').class.should == HTTParty::Response
97
+ end
98
+ end
99
+
100
+ describe '.requests' do
101
+ it 'should return response class' do
102
+ client.network.requests.class.should == HTTParty::Response
103
+ end
104
+ end
105
+
106
+ describe '.unfollow' do
107
+ it 'should return response class' do
108
+ client.network.unfollow(user: 'justin').class.should == HTTParty::Response
109
+ end
110
+ end
111
+ end
112
+
113
+ describe '.search' do
114
+ describe '.episodes' do
115
+ it 'should return response class' do
116
+ client.search.episodes('test').class.should == HTTParty::Response
117
+ end
118
+ end
119
+
120
+ describe '.movies' do
121
+ it 'should return response class' do
122
+ client.search.movies('test').class.should == HTTParty::Response
123
+ end
124
+ end
125
+
126
+ describe '.people' do
127
+ it 'should return response class' do
128
+ client.search.people('test').class.should == HTTParty::Response
129
+ end
130
+ end
131
+
132
+ describe '.shows' do
133
+ it 'should return response class' do
134
+ client.search.shows('test').class.should == HTTParty::Response
135
+ end
136
+ end
137
+
138
+ describe '.users' do
139
+ it 'should return response class' do
140
+ client.search.users('test').class.should == HTTParty::Response
141
+ end
142
+ end
143
+ end
144
+
145
+ describe '.server' do
146
+ describe '.time' do
147
+ it 'should return response class' do
148
+ client.server.time.class.should == HTTParty::Response
149
+ end
150
+ end
151
+ end
152
+
153
+ describe '.shows' do
154
+ describe '.trending' do
155
+ it 'should return response class' do
156
+ client.shows.trending.class.should == HTTParty::Response
157
+ end
158
+
159
+ describe 'with authentication' do
160
+ it 'should return response class' do
161
+ client.shows.trending(auth: true).class.should == HTTParty::Response
162
+ end
163
+ end
164
+ end
165
+
166
+ describe '.updated' do
167
+ it 'should return response class' do
168
+ client.shows.updated(time: Time.now.strftime("%Y%m%d")).class.should == HTTParty::Response
169
+ end
170
+ end
171
+ end
172
+ end
173
+ end