marvelite 0.0.3 → 0.0.4

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: bcf2ccb0ede4085ab09804bc5d5cf1510d75a382
4
- data.tar.gz: 7ade97ec9ff11f4880ce79ee2ca4a4751cf9eb1a
3
+ metadata.gz: 5869a9c08209ca2f9f7e12da466a094c90896c8b
4
+ data.tar.gz: 223abc8115a7c6f52e49f336ab552dfede7bdd2f
5
5
  SHA512:
6
- metadata.gz: e0284135f3777d78c31ecd91dcb3f2f2c15d2744cfa28a21286211a03f5ec8f60f84625c873d16d12d1483ec537524ffb1498512df6ef9e88bede7f683f71d79
7
- data.tar.gz: 151a57db1addd05f107654ca8b504cd199060432df8b714dfd4374be79e4634d117dc5a6e8671ab4dc65299e22a23a608f05c9f16b962da5fa1bab2d9ca8718d
6
+ metadata.gz: ecea6aebd6822352fc79508ec0871782276fe4e8296d43f97686a274e37bd4316a06eb2be6324c1c7aa47409de0faa29e61cd6003034d2288974f45a54871dff
7
+ data.tar.gz: e8b51d2cc3bdd8f347b081a1e0837a755a41052c9a1064003f7b44c9c8d5fcfaa1dcd49a0f8a70c6132def107c10d93ade4ecc80640f95bffd71069b2afff8ef
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  ## Changelog
2
2
 
3
+ ### 0.0.4
4
+ * Adds the following endpoints:
5
+ * retrieve comics by connecting to the API's `/comics` endpoint
6
+ * retieve a comic by connecting to the API's `/comics/:id` enpoint
7
+ * retrieve comic characters by connecting to the API's `/comics/:id/characters` endpoint.
8
+ * retrieve comic creators by connecting to the API's `/comics/:id/creators` endpoint.
9
+ * retrieve comic events by connecting to the API's `/comics/:id/events` endpoint.
10
+ * retrieve comic stories by connecting to the API's `/comics/:id/stories` endpoint.
11
+
3
12
  ### 0.0.3
4
13
  * Adds basic testing setup
5
14
  * Adds the ability to retrieve:
data/README.md CHANGED
@@ -49,6 +49,13 @@ client = Marvelite::API::Client.new(
49
49
  | [#character_events](#character_events) | Fetches a list of events in which a specific character appears. |
50
50
  | [#character_series](#character_series) | Fetches a list of comic series in which a specific character appears. |
51
51
  | [#character_stories](#character_stories) | Fetches a list of comic stories featuring a specific character. |
52
+ | [#comics](#comics) | Fetches a list of comics. |
53
+ | [#comic](#comic) | Fetches a single comic resource. |
54
+ | [#comic_characters](#comic_characters) | Fetches a list of characters which appear in a specific comic. |
55
+ | [#comic_creators](#comic_creators) | Fetches a list of comic creators whose work appears in a specific comic. |
56
+ | [#comic_events](#comic_events) | Fetches a list of events in which a comic appears. |
57
+ | [#comic_stories](#comic_stories) | Fetches a list of comic stories in a specific comic issue. |
58
+
52
59
 
53
60
  #### characters
54
61
  Fetches a list of comic characters. Can receive optional params.
@@ -142,6 +149,71 @@ client.character_stories('Spider-Man', { :limit => 10, :offset => 20 })
142
149
 
143
150
  See the [Marvel Comics Interactive API Tester](http://developer.marvel.com/docs#!/public/getCharacterStoryCollection_get_5) for a complete list of params that you can pass to the `#character_stories` method.
144
151
 
152
+
153
+ #### comics
154
+
155
+ Fetches a list of comics. Accepts optional params.
156
+
157
+ ```ruby
158
+ client.comics
159
+ client.comics(:format => 'graphic novel', :limit => 10, :offset => 20 })
160
+ ```
161
+
162
+ See the [Marvel Comics Interactive API Tester](http://developer.marvel.com/docs#!/public/getComicsCollection_get_6) for a complete list of params that you can pass to the `#comics` method.
163
+
164
+ #### comic
165
+
166
+ Fetches a single comic resource. Requires a comic id value (integer).
167
+
168
+ ```ruby
169
+ client.comic(40128)
170
+ ```
171
+
172
+ #### comic_characters
173
+
174
+ Fetches a list of characters which appear in a specific comic. Requires a comic id value (integer). Accepts optional params.
175
+
176
+ ```ruby
177
+ client.comic_characters(40128)
178
+ client.comic_characters(40128, :orderBy => 'name', :limit => 30, :offset => 20)
179
+ ```
180
+
181
+ See the [Marvel Comics Interactive API Tester](http://developer.marvel.com/docs#!/public/getComicCharacterCollection_get_8) for a complete list of params that you can pass to the `#comic_characters` method.
182
+
183
+ #### comic_creators
184
+
185
+ Fetches a list of comic creators whose work appears in a specific comic. Requires a comic id value (integer). Accepts optional params.
186
+
187
+ ```ruby
188
+ client.comic_creators(40128)
189
+ client.comic_creators(40128, :lastName => 'Romita')
190
+ ```
191
+
192
+ See the [Marvel Comics Interactive API Tester](http://developer.marvel.com/docs#!/public/getCreatorCollection_get_9) for a complete list of params that you can pass to the `#comic_creators` method.
193
+
194
+ #### comic_events
195
+
196
+ Fetches a list of events in which a comic appears. Requires a comic id value (integer). Accepts optional params.
197
+
198
+ ```ruby
199
+ client.comic_events(40128)
200
+ client.comic_events(40128, :orderBy => 'name', :limit => 10)
201
+ ```
202
+
203
+ See the [Marvel Comics Interactive API Tester](http://developer.marvel.com/docs#!/public/getIssueEventsCollection_get_10) for a complete list of params that you can pass to the `#comic_events` method.
204
+
205
+ #### comic_stories
206
+
207
+ Fetches a list of comic stories in a specific comic issue. Requires a comic id value (integer). Accepts optional params.
208
+
209
+ ```ruby
210
+ client.comic_stories(40128)
211
+ client.comic_stories(40128, :orderBy => 'name', :limit => 10)
212
+ ```
213
+
214
+ See the [Marvel Comics Interactive API Tester](http://developer.marvel.com/docs#!/public/getComicStoryCollection_get_11) for a complete list of params that you can pass to the `#comic_stories` method.
215
+
216
+
145
217
  ## Responses
146
218
 
147
219
  All requests to the API, return a `Marvelite::API::Response` object if successful or a `Marvelite::API::ErrorResponse` if API response returns an error. These objects are nothing more than the raw API response enhanced with Hashie methods.
data/lib/marvelite.rb CHANGED
@@ -5,6 +5,8 @@ require 'hashie'
5
5
 
6
6
  require "marvelite/version"
7
7
  require "marvelite/api/router"
8
+ require "marvelite/api/character_methods"
9
+ require "marvelite/api/comic_methods"
8
10
  require "marvelite/api/client"
9
11
  require "marvelite/api/response"
10
12
 
@@ -0,0 +1,62 @@
1
+ module Marvelite
2
+ module API
3
+ module CharacterMethods
4
+ def characters(query_params = {})
5
+ response = self.class.get("/#{api_version}/#{router.characters_path}", :query => params(query_params))
6
+ build_response_object(response)
7
+ end
8
+
9
+ def character(value)
10
+ by_name = value.is_a?(String) ? true : false
11
+ response = if by_name
12
+ find_character_by_name(value)
13
+ else
14
+ self.class.get("/#{api_version}/#{router.character_path(value)}", :query => params)
15
+ end
16
+
17
+ build_response_object(response)
18
+ end
19
+
20
+ def character_comics(id, query_params = {})
21
+ if id.is_a?(String)
22
+ character = find_character_by_name(id)
23
+ return false unless character
24
+ id = character.id
25
+ end
26
+
27
+ response = self.class.get("/#{api_version}/#{router.character_comics_path(id)}", :query => params(query_params))
28
+ build_response_object(response)
29
+ end
30
+
31
+ def character_events(id, query_params = {})
32
+ if id.is_a?(String)
33
+ character = find_character_by_name(id)
34
+ return false unless character
35
+ id = character.id
36
+ end
37
+ response = self.class.get("/#{api_version}/#{router.character_events_path(id)}", :query => params(query_params))
38
+ build_response_object(response)
39
+ end
40
+
41
+ def character_series(id, query_params = {})
42
+ if id.is_a?(String)
43
+ character = find_character_by_name(id)
44
+ return false unless character
45
+ id = character.id
46
+ end
47
+ response = self.class.get("/#{api_version}/#{router.character_series_path(id)}", :query => params(query_params))
48
+ build_response_object(response)
49
+ end
50
+
51
+ def character_stories(id, query_params = {})
52
+ if id.is_a?(String)
53
+ character = find_character_by_name(id)
54
+ return false unless character
55
+ id = character.id
56
+ end
57
+ response = self.class.get("/#{api_version}/#{router.character_stories_path(id)}", :query => params(query_params))
58
+ build_response_object(response)
59
+ end
60
+ end
61
+ end
62
+ end
@@ -2,6 +2,10 @@ module Marvelite
2
2
  module API
3
3
  class Client
4
4
  include ActiveModel::Model
5
+
6
+ include Marvelite::API::CharacterMethods
7
+ include Marvelite::API::ComicMethods
8
+
5
9
  include HTTParty
6
10
  base_uri 'http://gateway.marvel.com'
7
11
 
@@ -16,63 +20,6 @@ module Marvelite
16
20
  @api_version = attrs.fetch(:api_version) { 'v1' }
17
21
  end
18
22
 
19
- def characters(query_params = {})
20
- response = self.class.get("/#{api_version}/#{router.characters_path}", :query => params(query_params))
21
- build_response_object(response)
22
- end
23
-
24
- def character(value)
25
- by_name = value.is_a?(String) ? true : false
26
- response = if by_name
27
- find_character_by_name(value)
28
- else
29
- self.class.get("/#{api_version}/#{router.character_path(value)}", :query => params)
30
- end
31
-
32
- build_response_object(response)
33
- end
34
-
35
- def character_comics(id, query_params = {})
36
- if id.is_a?(String)
37
- character = find_character_by_name(id)
38
- return false unless character
39
- id = character.id
40
- end
41
-
42
- response = self.class.get("/#{api_version}/#{router.character_comics_path(id)}", :query => params(query_params))
43
- build_response_object(response)
44
- end
45
-
46
- def character_events(id, query_params = {})
47
- if id.is_a?(String)
48
- character = find_character_by_name(id)
49
- return false unless character
50
- id = character.id
51
- end
52
- response = self.class.get("/#{api_version}/#{router.character_events_path(id)}", :query => params(query_params))
53
- build_response_object(response)
54
- end
55
-
56
- def character_series(id, query_params = {})
57
- if id.is_a?(String)
58
- character = find_character_by_name(id)
59
- return false unless character
60
- id = character.id
61
- end
62
- response = self.class.get("/#{api_version}/#{router.character_series_path(id)}", :query => params(query_params))
63
- build_response_object(response)
64
- end
65
-
66
- def character_stories(id, query_params = {})
67
- if id.is_a?(String)
68
- character = find_character_by_name(id)
69
- return false unless character
70
- id = character.id
71
- end
72
- response = self.class.get("/#{api_version}/#{router.character_stories_path(id)}", :query => params(query_params))
73
- build_response_object(response)
74
- end
75
-
76
23
  private
77
24
  def params(additional_params = {})
78
25
  base_hash = { :apikey => public_key, :ts => ts, :hash => request_hash }
@@ -0,0 +1,35 @@
1
+ module Marvelite
2
+ module API
3
+ module ComicMethods
4
+ def comics(query_params = {})
5
+ response = self.class.get("/#{api_version}/#{router.comics_path}", :query => params(query_params))
6
+ build_response_object(response)
7
+ end
8
+
9
+ def comic(id)
10
+ response = self.class.get("/#{api_version}/#{router.comic_path(id)}", :query => params)
11
+ build_response_object(response)
12
+ end
13
+
14
+ def comic_characters(id, query_params = {})
15
+ response = self.class.get("/#{api_version}/#{router.comic_characters_path(id)}", :query => params(query_params))
16
+ build_response_object(response)
17
+ end
18
+
19
+ def comic_events(id, query_params = {})
20
+ response = self.class.get("/#{api_version}/#{router.comic_events_path(id)}", :query => params(query_params))
21
+ build_response_object(response)
22
+ end
23
+
24
+ def comic_creators(id, query_params = {})
25
+ response = self.class.get("/#{api_version}/#{router.comic_creators_path(id)}", :query => params(query_params))
26
+ build_response_object(response)
27
+ end
28
+
29
+ def comic_stories(id, query_params = {})
30
+ response = self.class.get("/#{api_version}/#{router.comic_stories_path(id)}", :query => params(query_params))
31
+ build_response_object(response)
32
+ end
33
+ end
34
+ end
35
+ end
@@ -24,6 +24,30 @@ module Marvelite
24
24
  def character_stories_path(id)
25
25
  "public/characters/#{id}/stories"
26
26
  end
27
+
28
+ def comics_path
29
+ "public/comics"
30
+ end
31
+
32
+ def comic_path(id)
33
+ "public/comics/#{id}"
34
+ end
35
+
36
+ def comic_characters_path(id)
37
+ "public/comics/#{id}/characters"
38
+ end
39
+
40
+ def comic_creators_path(id)
41
+ "public/comics/#{id}/creators"
42
+ end
43
+
44
+ def comic_events_path(id)
45
+ "public/comics/#{id}/events"
46
+ end
47
+
48
+ def comic_stories_path(id)
49
+ "public/comics/#{id}/stories"
50
+ end
27
51
  end
28
52
  end
29
53
  end
@@ -1,3 +1,3 @@
1
1
  module Marvelite
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -0,0 +1,259 @@
1
+ {
2
+ "code": 200,
3
+ "status": "Ok",
4
+ "etag": "7dff68517455de2200bde0216974bf20ae7f3dc3",
5
+ "data": {
6
+ "offset": 0,
7
+ "limit": 20,
8
+ "total": 1,
9
+ "count": 1,
10
+ "results": [
11
+ {
12
+ "id": 40128,
13
+ "digitalId": 28117,
14
+ "title": "Amazing Spider-Man (1999) #700",
15
+ "issueNumber": 700,
16
+ "variantDescription": "",
17
+ "description": null,
18
+ "modified": "2013-02-01T15:45:55-0500",
19
+ "isbn": "",
20
+ "upc": 75960604716170000,
21
+ "diamondCode": "OCT120626",
22
+ "ean": "",
23
+ "issn": "0274-5232",
24
+ "format": "Comic",
25
+ "pageCount": 104,
26
+ "textObjects": [],
27
+ "resourceURI": "http://gateway.marvel.com/v1/public/comics/40128",
28
+ "urls": [
29
+ {
30
+ "type": "detail",
31
+ "url": "http://marvel.com/comics/issue/40128/amazing_spider-man_1999_700?utm_campaign=apiRef&utm_source=85ec0830b5958f4f46ea2fa898a76ef2"
32
+ },
33
+ {
34
+ "type": "purchase",
35
+ "url": "http://comicstore.marvel.com/Amazing-Spider-Man-700/digital-comic/28117?utm_campaign=apiRef&utm_source=85ec0830b5958f4f46ea2fa898a76ef2"
36
+ },
37
+ {
38
+ "type": "reader",
39
+ "url": "http://marvel.com/digitalcomics/view.htm?iid=28117&utm_campaign=apiRef&utm_source=85ec0830b5958f4f46ea2fa898a76ef2"
40
+ },
41
+ {
42
+ "type": "inAppLink",
43
+ "url": "http://applink.marvel.com/issue/28117?utm_campaign=apiRef&utm_source=85ec0830b5958f4f46ea2fa898a76ef2"
44
+ }
45
+ ],
46
+ "series": {
47
+ "resourceURI": "http://gateway.marvel.com/v1/public/series/454",
48
+ "name": "Amazing Spider-Man (1999 - 2013)"
49
+ },
50
+ "variants": [
51
+ {
52
+ "resourceURI": "http://gateway.marvel.com/v1/public/comics/49353",
53
+ "name": "Amazing Spider-Man (1999) #700 (Ramos 5th Printing Variant)"
54
+ },
55
+ {
56
+ "resourceURI": "http://gateway.marvel.com/v1/public/comics/47884",
57
+ "name": "Amazing Spider-Man (1999) #700 (4th Printing Variant)"
58
+ },
59
+ {
60
+ "resourceURI": "http://gateway.marvel.com/v1/public/comics/47631",
61
+ "name": "Amazing Spider-Man (1999) #700 (Camuncoli 3rd Printing Variant)"
62
+ },
63
+ {
64
+ "resourceURI": "http://gateway.marvel.com/v1/public/comics/47350",
65
+ "name": "Amazing Spider-Man (1999) #700 (Ramos 2nd Printing Variant)"
66
+ },
67
+ {
68
+ "resourceURI": "http://gateway.marvel.com/v1/public/comics/44623",
69
+ "name": "Amazing Spider-Man (1999) #700 (Martin Variant)"
70
+ },
71
+ {
72
+ "resourceURI": "http://gateway.marvel.com/v1/public/comics/42440",
73
+ "name": "Amazing Spider-Man (1999) #700 (Asm 50th Anniversary Variant)"
74
+ },
75
+ {
76
+ "resourceURI": "http://gateway.marvel.com/v1/public/comics/44620",
77
+ "name": "Amazing Spider-Man (1999) #700 (Ramos Wraparound Variant)"
78
+ },
79
+ {
80
+ "resourceURI": "http://gateway.marvel.com/v1/public/comics/44621",
81
+ "name": "Amazing Spider-Man (1999) #700 (Quesada Wraparound Variant)"
82
+ },
83
+ {
84
+ "resourceURI": "http://gateway.marvel.com/v1/public/comics/44622",
85
+ "name": "Amazing Spider-Man (1999) #700 (Ditko Variant)"
86
+ },
87
+ {
88
+ "resourceURI": "http://gateway.marvel.com/v1/public/comics/44624",
89
+ "name": "Amazing Spider-Man (1999) #700 (Coipel Variant)"
90
+ },
91
+ {
92
+ "resourceURI": "http://gateway.marvel.com/v1/public/comics/46995",
93
+ "name": "Amazing Spider-Man (1999) #700 (Quesada Wraparound Sketch Variant)"
94
+ }
95
+ ],
96
+ "collections": [],
97
+ "collectedIssues": [],
98
+ "dates": [
99
+ {
100
+ "type": "onsaleDate",
101
+ "date": "2012-12-26T00:00:00-0500"
102
+ },
103
+ {
104
+ "type": "focDate",
105
+ "date": "2012-12-04T00:00:00-0500"
106
+ },
107
+ {
108
+ "type": "unlimitedDate",
109
+ "date": "2013-06-24T13:04:49-0400"
110
+ },
111
+ {
112
+ "type": "digitalPurchaseDate",
113
+ "date": "2012-12-26T00:00:00-0500"
114
+ }
115
+ ],
116
+ "prices": [
117
+ {
118
+ "type": "printPrice",
119
+ "price": 7.99
120
+ },
121
+ {
122
+ "type": "digitalPurchasePrice",
123
+ "price": 3.99
124
+ }
125
+ ],
126
+ "thumbnail": {
127
+ "path": "http://i.annihil.us/u/prod/marvel/i/mg/3/b0/510c2957c9b75",
128
+ "extension": "jpg"
129
+ },
130
+ "images": [
131
+ {
132
+ "path": "http://i.annihil.us/u/prod/marvel/i/mg/3/b0/510c2957c9b75",
133
+ "extension": "jpg"
134
+ },
135
+ {
136
+ "path": "http://i.annihil.us/u/prod/marvel/i/mg/3/60/508841f5f024d",
137
+ "extension": "jpg"
138
+ },
139
+ {
140
+ "path": "http://i.annihil.us/u/prod/marvel/i/mg/e/60/504fb308babca",
141
+ "extension": "jpg"
142
+ },
143
+ {
144
+ "path": "http://i.annihil.us/u/prod/marvel/i/mg/9/b0/504fb2946ee9a",
145
+ "extension": "jpg"
146
+ },
147
+ {
148
+ "path": "http://i.annihil.us/u/prod/marvel/i/mg/5/f0/504fb1d794b20",
149
+ "extension": "jpg"
150
+ }
151
+ ],
152
+ "creators": {
153
+ "available": 12,
154
+ "collectionURI": "http://gateway.marvel.com/v1/public/comics/40128/creators",
155
+ "items": [
156
+ {
157
+ "resourceURI": "http://gateway.marvel.com/v1/public/creators/105",
158
+ "name": "Sal Buscema",
159
+ "role": "inker"
160
+ },
161
+ {
162
+ "resourceURI": "http://gateway.marvel.com/v1/public/creators/447",
163
+ "name": "Victor Olazaba",
164
+ "role": "inker"
165
+ },
166
+ {
167
+ "resourceURI": "http://gateway.marvel.com/v1/public/creators/9461",
168
+ "name": "Stephanie Buscema",
169
+ "role": "artist"
170
+ },
171
+ {
172
+ "resourceURI": "http://gateway.marvel.com/v1/public/creators/1141",
173
+ "name": "Giuseppe Camuncoli",
174
+ "role": "penciler"
175
+ },
176
+ {
177
+ "resourceURI": "http://gateway.marvel.com/v1/public/creators/72",
178
+ "name": "Humberto Ramos",
179
+ "role": "penciler"
180
+ },
181
+ {
182
+ "resourceURI": "http://gateway.marvel.com/v1/public/creators/430",
183
+ "name": "Edgar Delgado",
184
+ "role": "colorist"
185
+ },
186
+ {
187
+ "resourceURI": "http://gateway.marvel.com/v1/public/creators/428",
188
+ "name": "Antonio Fabela",
189
+ "role": "colorist"
190
+ },
191
+ {
192
+ "resourceURI": "http://gateway.marvel.com/v1/public/creators/6986",
193
+ "name": "J. M. DeMatteis",
194
+ "role": "writer"
195
+ },
196
+ {
197
+ "resourceURI": "http://gateway.marvel.com/v1/public/creators/626",
198
+ "name": "Dan Slott",
199
+ "role": "writer"
200
+ },
201
+ {
202
+ "resourceURI": "http://gateway.marvel.com/v1/public/creators/11788",
203
+ "name": "Jennifer Van Meter",
204
+ "role": "writer"
205
+ },
206
+ {
207
+ "resourceURI": "http://gateway.marvel.com/v1/public/creators/452",
208
+ "name": "Chris Eliopoulos",
209
+ "role": "letterer"
210
+ },
211
+ {
212
+ "resourceURI": "http://gateway.marvel.com/v1/public/creators/11879",
213
+ "name": "Stephen Wacker",
214
+ "role": "editor"
215
+ }
216
+ ],
217
+ "returned": 12
218
+ },
219
+ "characters": {
220
+ "available": 1,
221
+ "collectionURI": "http://gateway.marvel.com/v1/public/comics/40128/characters",
222
+ "items": [
223
+ {
224
+ "resourceURI": "http://gateway.marvel.com/v1/public/characters/1009610",
225
+ "name": "Spider-Man"
226
+ }
227
+ ],
228
+ "returned": 1
229
+ },
230
+ "stories": {
231
+ "available": 2,
232
+ "collectionURI": {
233
+ "service": "comic_issueStories",
234
+ "id": 40128
235
+ },
236
+ "items": [
237
+ {
238
+ "resourceURI": "http://gateway.marvel.com/v1/public/stories/91053",
239
+ "name": "Cover #91053",
240
+ "type": "cover"
241
+ },
242
+ {
243
+ "resourceURI": "http://gateway.marvel.com/v1/public/stories/91054",
244
+ "name": "Interior #91054",
245
+ "type": "interiorStory"
246
+ }
247
+ ],
248
+ "returned": 2
249
+ },
250
+ "events": {
251
+ "available": 0,
252
+ "collectionURI": "http://gateway.marvel.com/v1/public/comics/40128/events",
253
+ "items": [],
254
+ "returned": 0
255
+ }
256
+ }
257
+ ]
258
+ }
259
+ }