annict 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d6d9c1b29febe4a9f29f7c56706166545af49f31
4
+ data.tar.gz: 968b74252e25211d855a0387dc7c9ab1fe007cd5
5
+ SHA512:
6
+ metadata.gz: 5cbf62a72fff4cb9a33dc37c618fe3c9e344347b92f65fe571eb592a35c0182532b5b28d872d9512a5ab54eb53944de0671bd9093404ec78df4d5e1fcc8653e5
7
+ data.tar.gz: 3c104295c433fd15d40665113403a76d68aa8896416fa5e3476baed51215fa8a13532841e5095fc50258e5a1de9d04b8fca8b8ffbff8e7d98f0c8cb3bd4e46c4
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.0
5
+ before_install: gem install bundler -v 1.14.3
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in annict.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 alitaso345
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,246 @@
1
+ # annict-ruby
2
+
3
+ A Ruby interface for Annict API
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'annict'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install annict
20
+
21
+ ## Documentation
22
+ https://docs.annict.com/
23
+
24
+ ## Usage
25
+ ## Annict::Client.new
26
+ ```ruby
27
+ require 'annict'
28
+ client = Annict::Client.new(access_token: 'annict_access_token')
29
+ ```
30
+
31
+ ## Annict::Client#works
32
+ Available params
33
+
34
+ - `:fields`
35
+ - `:filter_ids`
36
+ - `:filter_season`
37
+ - `:filter_title`
38
+ - `:page`
39
+ - `:per_page`
40
+ - `:sort_id`
41
+ - `:sort_season`
42
+ - `sort_watchers_count`
43
+
44
+ ```ruby
45
+ client.works
46
+ #=> GET /v1/works
47
+ ```
48
+
49
+ ## Annict::Client#episodes
50
+ Available params
51
+
52
+ - `:fields`
53
+ - `:filter_ids`
54
+ - `:filter_work_id`
55
+ - `:page`
56
+ - `:per_page`
57
+ - `:sort_id`
58
+ - `:sort_sort_number`
59
+
60
+ ```ruby
61
+ client.episodes
62
+ #=> GET /v1/episodes
63
+ ```
64
+
65
+ ## Annict::Client#records
66
+ Available params
67
+
68
+ - `:fields`
69
+ - `:filter_ids`
70
+ - `:filter_episode_id`
71
+ - `:filter_has_record_comment`
72
+ - `:page`
73
+ - `:per_page`
74
+ - `:sort_id`
75
+ - `:sort_likes_count`
76
+
77
+ ```ruby
78
+ client.records
79
+ #=> GET /v1/records
80
+ ```
81
+
82
+ ## Annict::Client#users
83
+ Available params
84
+
85
+ - `:fields`
86
+ - `:filter_ids`
87
+ - `:filter_usernames`
88
+ - `:page`
89
+ - `:per_page`
90
+ - `:sort_id`
91
+
92
+ ```ruby
93
+ client.users
94
+ #=> GET /v1/users
95
+ ```
96
+
97
+ ## Annict::Client#following
98
+ Available params
99
+
100
+ - `:fields`
101
+ - `:filter_user_id`
102
+ - `:filter_usernames`
103
+ - `:page`
104
+ - `:per_page`
105
+ - `:sort_id`
106
+
107
+ ```ruby
108
+ client.following
109
+ #=> GET /v1/following
110
+ ```
111
+
112
+ ## Annict::Client#followers
113
+ Available params
114
+
115
+ - `:fields`
116
+ - `:filter_user_id`
117
+ - `:filter_usernames`
118
+ - `:page`
119
+ - `:per_page`
120
+ - `:sort_id`
121
+
122
+ ```ruby
123
+ client.followers
124
+ #=> GET /v1/followers
125
+ ```
126
+
127
+ ## Annict::Client#activities
128
+ Available params
129
+
130
+ - `:fields`
131
+ - `:filter_user_id`
132
+ - `:filter_usernames`
133
+ - `:page`
134
+ - `:per_page`
135
+ - `:sort_id`
136
+
137
+ ```ruby
138
+ client.activities
139
+ #=> GET /v1/activities
140
+ ```
141
+
142
+ ## Annict::Client#me
143
+ Available params
144
+
145
+ - `:fields`
146
+
147
+ ```ruby
148
+ client.me
149
+ #=> GET /v1/me
150
+ ```
151
+
152
+ ## Annict::Client#change_status
153
+ Necessary params
154
+
155
+ - `:word_id`
156
+ - `:kind`
157
+
158
+ ```ruby
159
+ client.change_status({ work_id: 1808, kind: 'wanna_watch' })
160
+ #=> POST /v1/me/statuses
161
+ ```
162
+
163
+ ## Annict::Client#add_record
164
+ Necessary params
165
+
166
+ - `:episode_id`
167
+
168
+ Available params
169
+
170
+ - `:comment`
171
+ - `:rating`
172
+ - `:share_twitter`
173
+ - `:share_facebook`
174
+
175
+ ```ruby
176
+ client.add_record({ episode_id: 1808, comment: 'えるたそ〜' })
177
+ #=> POST /v1/me/records
178
+ ```
179
+
180
+ ## Annict::Client#own_works
181
+ Available params
182
+
183
+ - `:fields`
184
+ - `:filter_ids`
185
+ - `:filter_season`
186
+ - `:filter_title`
187
+ - `:filter_status`
188
+ - `:page`
189
+ - `:per_page`
190
+ - `:sort_id`
191
+ - `:sort_season`
192
+ - `:sort_watchers_count`
193
+
194
+ ```ruby
195
+ client.own_works
196
+ #=> GET /v1/me/works
197
+ ```
198
+
199
+ ## Annict:Client#programs
200
+ Available params
201
+
202
+ - `:fields`
203
+ - `:filter_ids`
204
+ - `:filter_channel_ids`
205
+ - `:filter_work_ids`
206
+ - `:filter_started_at_gt`
207
+ - `:filter_started_at_lt`
208
+ - `:filter_unwatched`
209
+ - `:filter_rebroadcast`
210
+ - `:page`
211
+ - `:per_page`
212
+ - `:sort_id`
213
+ - `:sort_started_at`
214
+
215
+ ```ruby
216
+ client.programs
217
+ #=> GET /v1/me/programs
218
+ ```
219
+
220
+ ## Annict::Client#following_activities
221
+ Available params
222
+
223
+ - `:fields`
224
+ - `:filter_actions`
225
+ - `:filter_muted`
226
+ - `:page`
227
+ - `:per_page`
228
+ - `:sort_id`
229
+
230
+ ```ruby
231
+ client.following_activities
232
+ #=> GET /v1/me/following_activities
233
+ ```
234
+
235
+ ## Contributing
236
+
237
+ 1. Fork it ( https://github.com/alitaso345/annict-ruby/fork )
238
+ 2. Create your feature branch (git checkout -b my-new-feature)
239
+ 3. Commit your changes (git commit -am 'Add some feature')
240
+ 4. Push to the branch (git push origin my-new-feature)
241
+ 5. Create a new Pull Request
242
+
243
+ ## License
244
+
245
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
246
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'annict/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "annict"
8
+ spec.version = Annict::VERSION
9
+ spec.authors = ["alitaso345"]
10
+ spec.email = ["a.maruyama@uec.ac.jp"]
11
+
12
+ spec.summary = %q{Simple wrapper for the Annict API}
13
+ spec.description = %q{Annict API v1 client library, written in Ruby}
14
+ spec.homepage = "https://github.com/alitaso345/annict-ruby"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_runtime_dependency "faraday", "~> 0.9"
25
+ spec.add_runtime_dependency "faraday_middleware"
26
+ spec.add_development_dependency "bundler", "~> 1.14"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+ spec.add_development_dependency "rspec", "~> 3.0"
29
+ spec.add_development_dependency "pry"
30
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "annict"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,5 @@
1
+ require "faraday"
2
+ require "faraday_middleware"
3
+
4
+ require "annict/version"
5
+ require "annict/client"
@@ -0,0 +1,55 @@
1
+ module Annict
2
+ module ApiMethods
3
+ def works(params = {})
4
+ send_get("/v1/works", params)
5
+ end
6
+
7
+ def episodes(params = {})
8
+ send_get("/v1/episodes", params)
9
+ end
10
+
11
+ def records(params = {})
12
+ send_get("/v1/records", params)
13
+ end
14
+
15
+ def users(params = {})
16
+ send_get("/v1/users", params)
17
+ end
18
+
19
+ def following(params = {})
20
+ send_get("/v1/following", params)
21
+ end
22
+
23
+ def followers(params = {})
24
+ send_get("/v1/followers", params)
25
+ end
26
+
27
+ def activities(params = {})
28
+ send_get("/v1/activities", params)
29
+ end
30
+
31
+ def me(params = {})
32
+ send_get("/v1/me", params)
33
+ end
34
+
35
+ def change_status(params = {})
36
+ send_post("/v1/me/statuses", params)
37
+ end
38
+
39
+ def add_record(params = {})
40
+ send_post("/v1/me/records", params)
41
+ end
42
+
43
+ def own_works(params = {})
44
+ send_get("/v1/me/works", params)
45
+ end
46
+
47
+ def programs(params = {})
48
+ send_get("/v1/me/programs", params)
49
+ end
50
+
51
+ def following_activities(params = {})
52
+ send_get("/v1/me/following_activities", params)
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,58 @@
1
+ require "faraday"
2
+ require "faraday_middleware"
3
+ require "annict/api_methods"
4
+ require "annict/response"
5
+
6
+ module Annict
7
+ class Client
8
+ include ApiMethods
9
+
10
+ ENDPOINT_BASE_URL = "https://api.annict.com"
11
+
12
+ def initialize(access_token: nil)
13
+ @access_token = access_token
14
+ end
15
+ attr_reader :access_token
16
+
17
+ def send_get(path, params = {})
18
+ send_request(:get, path, params)
19
+ end
20
+
21
+ def send_post(path, params = {})
22
+ send_request(:post, path, params)
23
+ end
24
+
25
+ def send_request(method, path, params)
26
+ Annict::Response.new(annict_connection.send(method, path, params))
27
+ end
28
+
29
+ def annict_connection
30
+ @annict_connection ||= Faraday.new(faraday_options) do |faraday|
31
+ faraday.request :json
32
+ faraday.response :json
33
+ faraday.adapter Faraday.default_adapter
34
+ end
35
+ end
36
+
37
+ private
38
+
39
+ def faraday_options
40
+ {
41
+ url: ENDPOINT_BASE_URL,
42
+ headers: faraday_headers
43
+ }
44
+ end
45
+
46
+ def faraday_headers
47
+ return default_headers unless access_token
48
+ default_headers.merge(Authorization: "Bearer #{access_token}")
49
+ end
50
+
51
+ def default_headers
52
+ {
53
+ 'Accept' => 'application/json',
54
+ 'User-Agent' => "Annict Ruby Gem #{Annict::VERSION}"
55
+ }
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,11 @@
1
+ module Annict
2
+ class Response
3
+ attr_reader :body, :headers, :status
4
+
5
+ def initialize(faraday_response)
6
+ @body = faraday_response.body
7
+ @headers = faraday_response.headers
8
+ @status = faraday_response.status
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module Annict
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,143 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: annict
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - alitaso345
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-03-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.9'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday_middleware
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.14'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.14'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Annict API v1 client library, written in Ruby
98
+ email:
99
+ - a.maruyama@uec.ac.jp
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".rspec"
106
+ - ".travis.yml"
107
+ - Gemfile
108
+ - LICENSE.txt
109
+ - README.md
110
+ - Rakefile
111
+ - annict.gemspec
112
+ - bin/console
113
+ - bin/setup
114
+ - lib/annict.rb
115
+ - lib/annict/api_methods.rb
116
+ - lib/annict/client.rb
117
+ - lib/annict/response.rb
118
+ - lib/annict/version.rb
119
+ homepage: https://github.com/alitaso345/annict-ruby
120
+ licenses:
121
+ - MIT
122
+ metadata: {}
123
+ post_install_message:
124
+ rdoc_options: []
125
+ require_paths:
126
+ - lib
127
+ required_ruby_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ required_rubygems_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ requirements: []
138
+ rubyforge_project:
139
+ rubygems_version: 2.6.8
140
+ signing_key:
141
+ specification_version: 4
142
+ summary: Simple wrapper for the Annict API
143
+ test_files: []