rdmm 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fe940e5aad4abe9b0e14b6079c65e56cd6dd1aa5
4
- data.tar.gz: eafea0273111151c1e2d81db7dc75961afe931cb
3
+ metadata.gz: a98d46defda3eadf067187d2ed36c66011a4969c
4
+ data.tar.gz: e5e0f5665647578e2eb3beb620841f17e6f0d617
5
5
  SHA512:
6
- metadata.gz: 34aa24a950848b870d755ee50411482c2839e31aa9a10e61ea90ce5d7f86c9a0333434d1f06be7b2174e1c0e96246efb15edb346e0650ea142373374905a5e2c
7
- data.tar.gz: 22d6e35a24d8d9f7c6c14735ceb5dc472526c861d1c94a0dbef22c7df98c5f73081aacadd91bf7133486267dfb4385c5d29f8f2feb844300f7d35e407e5a81a4
6
+ metadata.gz: d2c9517b6cbcbb39e41e53b50a55bb9fe84f28867c09027abea0d6753a522db3e5ae2489e81eb2bdb4fef0a66964095f3c97c2eaa74b0b51c4b29c306153b86e
7
+ data.tar.gz: 0e0bb2b5ba4be165a802a6adcd9d0e5f0eb570e9486d2844d3f9af3d43da05a446a8c0c644408671055c0188c957c635723db5fba1913577865d6e2d31d78c5d
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.2.0
2
+
3
+ - Add some methods to `Rdmm::Responses::BaseResponse` for error handling
4
+ - Rename `:floor` to `:floor_code` on `Rdmm::Client#list_items`
5
+ - Rename `:service` to `:service_code` on `Rdmm::Client#list_items`
6
+
1
7
  ## 0.1.0
2
8
 
3
9
  - Add `Rdmm::Client#list_actresses`
data/README.md CHANGED
@@ -46,16 +46,21 @@ client = Rdmm::Client.new(affiliate_id: "dummy", api_id: "dummy")
46
46
  Available options:
47
47
 
48
48
  - `:id`
49
- - `:birthday`
50
- - `:bust`
51
- - `:height`
52
- - `:hip`
49
+ - `:birthday_from`
50
+ - `:birthday_to`
51
+ - `:bust_from`
52
+ - `:bust_to`
53
+ - `:height_from`
54
+ - `:height_to`
55
+ - `:hip_from`
56
+ - `:hip_to`
53
57
  - `:hits`
54
58
  - `:initial`
55
59
  - `:keyword`
56
60
  - `:offset`
57
61
  - `:sort`
58
- - `:waist`
62
+ - `:waist_from`
63
+ - `:waist_to`
59
64
 
60
65
  ```ruby
61
66
  client.list_actresses
@@ -108,14 +113,14 @@ Available options:
108
113
  - `:article`
109
114
  - `:article_id`
110
115
  - `:content_id`
111
- - `:floor`
116
+ - `:floor_code`
112
117
  - `:hits`
113
118
  - `:keyword`
114
119
  - `:mono_stock`
115
120
  - `:offset`
116
121
  - `:released_from`
117
122
  - `:released_to`
118
- - `:service`
123
+ - `:service_code`
119
124
  - `:site`
120
125
  - `:sort`
121
126
 
@@ -155,199 +160,121 @@ client.list_series(floor_id: 27)
155
160
 
156
161
  `https://api.dmm.com/affiliate/v3/SeriesSearch?affiliate_id=dummy&api_id=dummy&floor_id=27`
157
162
 
158
- ### Rdmm::Responses::BaseResponse#each
163
+ ### Rdmm::Responses::BaseResponse
159
164
 
160
- This class implements `Enumerable` module.
165
+ Available methods:
161
166
 
162
- ```ruby
163
- client.list_items(site: "DMM.com").map(&:title)
164
- ```
165
-
166
- <details>
167
- <summary>output</summary>
168
-
169
- ```ruby
170
- ["キングダム",
171
- "ハドソン川の奇跡",
172
- "ミュージカル『刀剣乱舞』 〜真剣乱舞祭 2016〜",
173
- "back number/アンコール",
174
- "パンフレット 舞台『刀剣乱舞』虚伝 燃ゆる本能寺(再演)",
175
- "終末のハーレム セミカラー版",
176
- "VOICEROID+ 東北きりたん EX ダウンロード版",
177
- "CHAOS;CHILD",
178
- "【8〜14泊】Travel house 軽量 TSAロック付き 4輪 93L スーツケース レッド",
179
- "ミュージカル『刀剣乱舞』真剣乱舞祭 2016 (ブルーレイディスク)",
180
- "シン・ゴジラ",
181
- "東京タラレバ娘",
182
- "舞台『刀剣乱舞』虚伝 燃ゆる本能寺 〜再演〜",
183
- "キングダム",
184
- "宇多田ヒカル/Fantome(SHM-CD)",
185
- "エルダー・スクロールズ・オンライン 日本語版 (インペリアルエディション)",
186
- "自炊・電子書籍化キット プラス裁断機PK-513L&ScanSnap iX500 FI-IX500A",
187
- "VOICEROID+ 結月ゆかり EX ダウンロード版",
188
- "映画 闇金ウシジマくんthe Final",
189
- "トレーディングブロマイド 25枚セット 舞台『刀剣乱舞』虚伝 燃ゆる本能寺(再演)"]
190
- ```
191
-
192
- </details>
193
-
194
- ### Rdmm::Responses::BaseResponse#first_position
195
-
196
- ```ruby
197
- client.list_items(site: "DMM.com").first_position
198
- ```
199
-
200
- <details>
201
- <summary>output</summary>
202
-
203
- ```ruby
204
- 1
205
- ```
206
-
207
- </details>
208
-
209
- ### Rdmm::Responses::BaseResponse#has_next_page?
210
-
211
- ```ruby
212
- client.list_items(site: "DMM.com").has_next_page?
213
- ```
214
-
215
- <details>
216
- <summary>output</summary>
217
-
218
- ```ruby
219
- true
220
- ```
221
-
222
- </details>
223
-
224
- ### Rdmm::Responses::BaseResponse#result_count
225
-
226
- ```ruby
227
- client.list_items(site: "DMM.com").result_count
228
- ```
229
-
230
- <details>
231
- <summary>output</summary>
232
-
233
- ```ruby
234
- 20
235
- ```
236
-
237
- </details>
238
-
239
- ### Rdmm::Responses::BaseResponse#total_count
240
-
241
- ```ruby
242
- client.list_items(site: "DMM.com").total_count
243
- ```
244
-
245
- <details>
246
- <summary>output</summary>
247
-
248
- ```ruby
249
- 50000
250
- ```
251
-
252
- </details>
167
+ - `#body`
168
+ - `#each`
169
+ - `#errors`
170
+ - `#first_position`
171
+ - `#has_error?`
172
+ - `#has_next_page?`
173
+ - `#headers`
174
+ - `#message`
175
+ - `#next_page_offset`
176
+ - `#resources`
177
+ - `#result_count`
178
+ - `#status`
179
+ - `#total_count`
253
180
 
254
181
  ### Rdmm::Resources::ActressResource
255
182
 
256
183
  Available attributes:
257
184
 
258
- - `birthday`
259
- - `blood_type`
260
- - `bust`
261
- - `cup`
262
- - `height`
263
- - `hobbies`
264
- - `id`
265
- - `image_url_large`
266
- - `image_url_small`
267
- - `list_url_digital`
268
- - `list_url_mono`
269
- - `list_url_monthly`
270
- - `list_url_ppm`
271
- - `list_url_rental`
272
- - `name`
273
- - `prefectures`
274
- - `ruby`
275
- - `waist`
185
+ - `#birthday`
186
+ - `#blood_type`
187
+ - `#bust`
188
+ - `#cup`
189
+ - `#height`
190
+ - `#hobbies`
191
+ - `#id`
192
+ - `#image_url_large`
193
+ - `#image_url_small`
194
+ - `#list_url_digital`
195
+ - `#list_url_mono`
196
+ - `#list_url_monthly`
197
+ - `#list_url_ppm`
198
+ - `#list_url_rental`
199
+ - `#name`
200
+ - `#prefectures`
201
+ - `#ruby`
202
+ - `#waist`
276
203
 
277
204
  ### Rdmm::Resources::AuthorResource
278
205
 
279
206
  Available attributes:
280
207
 
281
- - `another_name`
282
- - `id`
283
- - `list_url`
284
- - `name`
285
- - `ruby`
208
+ - `#another_name`
209
+ - `#id`
210
+ - `#list_url`
211
+ - `#name`
212
+ - `#ruby`
286
213
 
287
214
  ### Rdmm::Resources::FloorResource
288
215
 
289
216
  Available attributes:
290
217
 
291
- - `code`
292
- - `id`
293
- - `name`
294
- - `service_code`
295
- - `service_name`
296
- - `site_code`
297
- - `site_name`
218
+ - `#code`
219
+ - `#id`
220
+ - `#name`
221
+ - `#service_code`
222
+ - `#service_name`
223
+ - `#site_code`
224
+ - `#site_name`
298
225
 
299
226
  ### Rdmm::Resources::GenreResource
300
227
 
301
228
  Available attributes:
302
229
 
303
- - `id`
304
- - `list_url`
305
- - `name`
306
- - `ruby`
230
+ - `#id`
231
+ - `#list_url`
232
+ - `#name`
233
+ - `#ruby`
307
234
 
308
235
  ### Rdmm::Resources::ItemResource
309
236
 
310
237
  Available attributes:
311
238
 
312
- - `actors`
313
- - `actresses`
314
- - `affiliate_url`
315
- - `authors`
316
- - `category_name`
317
- - `content_id`
318
- - `directors`
319
- - `floor_code`
320
- - `floor_name`
321
- - `genres`
322
- - `labels`
323
- - `makers`
324
- - `prices`
325
- - `product_id`
326
- - `released_at`
327
- - `review_average`
328
- - `review_count`
329
- - `series`
330
- - `service_code`
331
- - `service_name`
332
- - `title`
333
- - `url`
334
- - `volume`
239
+ - `#actors`
240
+ - `#actresses`
241
+ - `#affiliate_url`
242
+ - `#authors`
243
+ - `#category_name`
244
+ - `#content_id`
245
+ - `#directors`
246
+ - `#floor_code`
247
+ - `#floor_name`
248
+ - `#genres`
249
+ - `#labels`
250
+ - `#makers`
251
+ - `#prices`
252
+ - `#product_id`
253
+ - `#released_at`
254
+ - `#review_average`
255
+ - `#review_count`
256
+ - `#series`
257
+ - `#service_code`
258
+ - `#service_name`
259
+ - `#title`
260
+ - `#url`
261
+ - `#volume`
335
262
 
336
263
  ### Rdmm::Resources::MakerResource
337
264
 
338
265
  Available attributes:
339
266
 
340
- - `id`
341
- - `list_url`
342
- - `name`
343
- - `ruby`
267
+ - `#id`
268
+ - `#list_url`
269
+ - `#name`
270
+ - `#ruby`
344
271
 
345
272
 
346
273
  ### Rdmm::Resources::SeriesResource
347
274
 
348
275
  Available attributes:
349
276
 
350
- - `id`
351
- - `list_url`
352
- - `name`
353
- - `ruby`
277
+ - `#id`
278
+ - `#list_url`
279
+ - `#name`
280
+ - `#ruby`
data/lib/rdmm/client.rb CHANGED
@@ -24,7 +24,6 @@ module Rdmm
24
24
  @connection ||= ::Faraday::Connection.new(url: BASE_URL) do |connection|
25
25
  connection.adapter :net_http
26
26
  connection.response :json
27
- connection.response :raise_error
28
27
  end
29
28
  end
30
29
 
@@ -36,10 +36,9 @@ module Rdmm
36
36
  options[:content_id]
37
37
  end
38
38
 
39
- # @note floor code
40
39
  # @return [String, nil]
41
40
  def floor
42
- options[:floor]
41
+ options[:floor_code]
43
42
  end
44
43
 
45
44
  # @return [String, nil]
@@ -81,10 +80,9 @@ module Rdmm
81
80
  options[:offset]
82
81
  end
83
82
 
84
- # @note service code
85
83
  # @return [String, nil]
86
84
  def service
87
- options[:service]
85
+ options[:service_code]
88
86
  end
89
87
 
90
88
  # @note One of the following values:
@@ -18,6 +18,16 @@ module Rdmm
18
18
  resources.each(&block)
19
19
  end
20
20
 
21
+ # @return [Hash, nil]
22
+ def errors
23
+ body["result"]["errors"]
24
+ end
25
+
26
+ # @return [Boolean]
27
+ def has_error?
28
+ status != 200
29
+ end
30
+
21
31
  # @return [Integer]
22
32
  def first_position
23
33
  body["result"]["first_position"]
@@ -33,6 +43,11 @@ module Rdmm
33
43
  faraday_response.headers
34
44
  end
35
45
 
46
+ # @return [String, nil]
47
+ def message
48
+ body["result"]["message"]
49
+ end
50
+
36
51
  # @return [Integer, nil]
37
52
  def next_page_offset
38
53
  if has_next_page?
@@ -40,9 +55,11 @@ module Rdmm
40
55
  end
41
56
  end
42
57
 
43
- # @return [Rdmm::Resources::BaseResource]
58
+ # @return [Array<Rdmm::Resources::BaseResource>]
44
59
  def resources
45
- raise ::NotImplementedError
60
+ (sources || []).map do |source|
61
+ resource_class.new(source)
62
+ end
46
63
  end
47
64
 
48
65
  # @return [Integer]
@@ -62,10 +79,23 @@ module Rdmm
62
79
 
63
80
  private
64
81
 
82
+ # @private
65
83
  # @return [Faraday::Response]
66
84
  def faraday_response
67
85
  @faraday_response
68
86
  end
87
+
88
+ # @private
89
+ # @return [Class]
90
+ def resource_class
91
+ raise ::NotImplementedError
92
+ end
93
+
94
+ # @private
95
+ # @return [Array<Hash>, nil]
96
+ def sources
97
+ raise ::NotImplementedError
98
+ end
69
99
  end
70
100
  end
71
101
  end
@@ -1,11 +1,16 @@
1
1
  module Rdmm
2
2
  module Responses
3
3
  class ListActressesResponse < BaseResponse
4
+ private
5
+
4
6
  # @note Override
5
- def resources
6
- body["result"]["actress"].map do |source|
7
- ::Rdmm::Resources::ActressResource.new(source)
8
- end
7
+ def resource_class
8
+ ::Rdmm::Resources::ActressResource
9
+ end
10
+
11
+ # @note Override
12
+ def sources
13
+ body["result"]["actress"]
9
14
  end
10
15
  end
11
16
  end
@@ -1,11 +1,16 @@
1
1
  module Rdmm
2
2
  module Responses
3
3
  class ListAuthorsResponse < BaseResponse
4
+ private
5
+
4
6
  # @note Override
5
- def resources
6
- (body["result"]["author"] || []).map do |source|
7
- ::Rdmm::Resources::AuthorResource.new(source)
8
- end
7
+ def resource_class
8
+ ::Rdmm::Resources::AuthorResource
9
+ end
10
+
11
+ # @note Override
12
+ def sources
13
+ body["result"]["author"]
9
14
  end
10
15
  end
11
16
  end
@@ -1,18 +1,23 @@
1
1
  module Rdmm
2
2
  module Responses
3
3
  class ListFloorsResponse < BaseResponse
4
+ private
5
+
4
6
  # @note Override
5
- def resources
7
+ def resource_class
8
+ ::Rdmm::Resources::FloorResource
9
+ end
10
+
11
+ # @note Override
12
+ def sources
6
13
  body["result"]["site"].flat_map do |site_source|
7
14
  site_source["service"].flat_map do |service_source|
8
15
  service_source["floor"].map do |source|
9
- ::Rdmm::Resources::FloorResource.new(
10
- source.merge(
11
- "site_code" => site_source["code"],
12
- "site_name" => site_source["name"],
13
- "service_code" => service_source["code"],
14
- "service_name" => service_source["name"],
15
- ),
16
+ source.merge(
17
+ "site_code" => site_source["code"],
18
+ "site_name" => site_source["name"],
19
+ "service_code" => service_source["code"],
20
+ "service_name" => service_source["name"],
16
21
  )
17
22
  end
18
23
  end
@@ -1,11 +1,16 @@
1
1
  module Rdmm
2
2
  module Responses
3
3
  class ListGenresResponse < BaseResponse
4
+ private
5
+
4
6
  # @note Override
5
- def resources
6
- body["result"]["genre"].map do |source|
7
- ::Rdmm::Resources::GenreResource.new(source)
8
- end
7
+ def resource_class
8
+ ::Rdmm::Resources::GenreResource
9
+ end
10
+
11
+ # @note Override
12
+ def sources
13
+ body["result"]["genre"]
9
14
  end
10
15
  end
11
16
  end
@@ -1,11 +1,16 @@
1
1
  module Rdmm
2
2
  module Responses
3
3
  class ListItemsResponse < BaseResponse
4
+ private
5
+
4
6
  # @note Override
5
- def resources
6
- body["result"]["items"].map do |source|
7
- ::Rdmm::Resources::ItemResource.new(source)
8
- end
7
+ def resource_class
8
+ ::Rdmm::Resources::ItemResource
9
+ end
10
+
11
+ # @note Override
12
+ def sources
13
+ body["result"]["items"]
9
14
  end
10
15
  end
11
16
  end
@@ -1,11 +1,16 @@
1
1
  module Rdmm
2
2
  module Responses
3
3
  class ListMakersResponse < BaseResponse
4
+ private
5
+
4
6
  # @note Override
5
- def resources
6
- body["result"]["maker"].map do |source|
7
- ::Rdmm::Resources::MakerResource.new(source)
8
- end
7
+ def resource_class
8
+ ::Rdmm::Resources::MakerResource
9
+ end
10
+
11
+ # @note Override
12
+ def sources
13
+ body["result"]["maker"]
9
14
  end
10
15
  end
11
16
  end
@@ -1,11 +1,16 @@
1
1
  module Rdmm
2
2
  module Responses
3
3
  class ListSeriesResponse < BaseResponse
4
+ private
5
+
4
6
  # @note Override
5
- def resources
6
- body["result"]["series"].map do |source|
7
- ::Rdmm::Resources::SeriesResource.new(source)
8
- end
7
+ def resource_class
8
+ ::Rdmm::Resources::SeriesResource
9
+ end
10
+
11
+ # @note Override
12
+ def sources
13
+ body["result"]["series"]
9
14
  end
10
15
  end
11
16
  end
data/lib/rdmm/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rdmm
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdmm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-08 00:00:00.000000000 Z
11
+ date: 2017-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday