marvel_api 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -1
- data/README.md +302 -3
- data/VERSION +1 -1
- data/lib/marvel/client.rb +92 -78
- data/lib/marvel/request.rb +16 -2
- data/marvel_api.gemspec +13 -9
- data/spec/marvel_api/client_spec.rb +7 -0
- data/spec/marvel_api_spec.rb +9 -0
- data/spec/spec_helper.rb +1 -1
- metadata +43 -28
- data/spec/marvel_spec.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9133e1fdec31b9c7841f6e23729cd412a10aa310
|
4
|
+
data.tar.gz: 96b3b3becbda0afe29f29938444b042f7ec1d974
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9410f5d4c555781945893a5e618ecfdef1dc48a4bb7d522a8b2f9b6af5f3bcab6d669aac104d88f67ad855e2790796d41f249d09686f56e88af58b323b9325d0
|
7
|
+
data.tar.gz: 85b4a94ee6394355350f55819009b6c00c0687b14abf1f84384bba2780a02752edbbd3be441cd375e0bc8e84cfc9628c51fd3c33f1c7c17e6d0a771a5537ac56
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,14 +1,313 @@
|
|
1
1
|
# marvel_api
|
2
2
|
|
3
|
-
Ruby bindings for the [Marvel API](http://developer.marvel.com/). Still under construction... Feel free to contribute!
|
3
|
+
Ruby bindings for the [Marvel API](http://developer.marvel.com/). Still under construction... Feel free to contribute! In the meantime, check out the [marvelite](https://github.com/antillas21/marvelite/) gem for something that's further along in development (and likely a lot stabler :-).
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
7
|
`gem install 'marvel_api'` or add `gem 'marvel_api'` to your Gemfile.
|
8
8
|
|
9
|
-
##
|
9
|
+
## Configuration
|
10
10
|
|
11
|
-
|
11
|
+
You'll need an API key — get yours [here](http://developer.marvel.com). Configure like so:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
@client = Marvel::Client.new
|
15
|
+
|
16
|
+
@client.configure do |config|
|
17
|
+
config.api_key = 'YOUR_API_KEY'
|
18
|
+
config.private_key = 'YOUR_PRIVATE_KEY'
|
19
|
+
end
|
20
|
+
```
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
Descriptions and examples of the supported actions are below. Note, all methods currently return a `Hashie:Mash` object if successful. For a more detailed explanation of available actions and an exhaustive list of acceptable query parameters, see Marvel's own developer [documentation](http://developer.marvel.com/docs). Each method described below links to the associated call in Marvel's interactive API tester.
|
25
|
+
|
26
|
+
### Characters
|
27
|
+
|
28
|
+
- Fetches lists of characters. [`GET /v1/public/characters`](http://developer.marvel.com/docs#!/public/getCreatorCollection_get_0)
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
@client.characters
|
32
|
+
@client.characters(name: 'Thanos')
|
33
|
+
@client.characters(nameStartsWith: 'Th', orderBy: 'modified')
|
34
|
+
```
|
35
|
+
|
36
|
+
- Fetches a single character by id. [`GET /v1/public/characters/{characterId}`](http://developer.marvel.com/docs#!/public/getCharacterIndividual_get_1)
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
@client.character(1009652)
|
40
|
+
```
|
41
|
+
|
42
|
+
- Fetches lists of comics filtered by a character id. [`GET /v1/public/characters/{characterId}/comics`](http://developer.marvel.com/docs#!/public/getComicsCharacterCollection_get_2)
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
@client.character_comics(1009652)
|
46
|
+
@client.character_comics(1009652, titleStartsWith: 'Infinity', hasDigitalIssue: true)
|
47
|
+
```
|
48
|
+
|
49
|
+
- Fetches lists of events filtered by a character id. [`GET /v1/public/characters/{characterId}/events`](http://developer.marvel.com/docs#!/public/getCharacterEventsCollection_get_3)
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
@client.character_events(1009652)
|
53
|
+
@client.character_events(1009652, name: 'Infinity Gauntlet')
|
54
|
+
```
|
55
|
+
|
56
|
+
- Fetches lists of series filtered by a character id. [`GET /v1/public/characters/{characterId}/series`](http://developer.marvel.com/docs#!/public/getCharacterSeriesCollection_get_4)
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
@client.character_series(1009652)
|
60
|
+
@client.character_series(1009652, contains: 'hardcover')
|
61
|
+
```
|
62
|
+
|
63
|
+
- Fetches lists of stories filtered by a character id. [`GET /v1/public/characters/{characterId}/stories`](http://developer.marvel.com/docs#!/public/getCharacterStoryCollection_get_5)
|
64
|
+
|
65
|
+
```ruby
|
66
|
+
@client.character_stories(1009652)
|
67
|
+
@client.character_stories(1009652, limit: 50)
|
68
|
+
```
|
69
|
+
|
70
|
+
### Comics
|
71
|
+
|
72
|
+
- Fetches lists of comics. [`GET /v1/public/comics`](http://developer.marvel.com/docs#!/public/getComicsCollection_get_6)
|
73
|
+
|
74
|
+
```ruby
|
75
|
+
@client.comics
|
76
|
+
@client.comics(title: 'Daredevil')
|
77
|
+
@client.comics(startYear: 1950, issueNumber: 1)
|
78
|
+
```
|
79
|
+
|
80
|
+
- Fetches a single comic by id. [`GET /v1/public/comics/{comicId}`](http://developer.marvel.com/docs#!/public/getComicIndividual_get_7)
|
81
|
+
|
82
|
+
```ruby
|
83
|
+
@client.comic(29380)
|
84
|
+
```
|
85
|
+
|
86
|
+
- Fetches lists of characters filtered by a comic id. [`GET /v1/public/comics/{comicId}/characters`](http://developer.marvel.com/docs#!/public/getComicCharacterCollection_get_8)
|
87
|
+
|
88
|
+
```ruby
|
89
|
+
@client.comic_characters(34249)
|
90
|
+
@client.comic_characters(34249, orderBy: 'name')
|
91
|
+
```
|
92
|
+
|
93
|
+
- Fetches lists of creators filtered by a comic id. [`GET /v1/public/comics/{comicId}/creators`](http://developer.marvel.com/docs#!/public/getCreatorCollection_get_9)
|
94
|
+
|
95
|
+
```ruby
|
96
|
+
@client.comic_creators(34249)
|
97
|
+
@client.comic_creators(34249, lastNameStartsWith: 'V')
|
98
|
+
```
|
99
|
+
|
100
|
+
- Fetches lists of events filtered by a comic id. [`GET /v1/public/comics/{comicId}/events`](http://developer.marvel.com/docs#!/public/getIssueEventsCollection_get_10)
|
101
|
+
|
102
|
+
```ruby
|
103
|
+
@client.comic_events(27272)
|
104
|
+
@client.comic_events(27272, orderBy: '-startDate')
|
105
|
+
```
|
106
|
+
|
107
|
+
- Fetches lists of stories filtered by a comic id. [`GET /v1/public/comics/{comicId}/stories`](http://developer.marvel.com/docs#!/public/getComicStoryCollection_get_11)
|
108
|
+
|
109
|
+
```ruby
|
110
|
+
@client.comic_stories(27272)
|
111
|
+
@client.comic_stories(27272, creators: [600, 801])
|
112
|
+
```
|
113
|
+
|
114
|
+
### Creators
|
115
|
+
|
116
|
+
- Fetches lists of creators. [`GET /v1/public/creators`](http://developer.marvel.com/docs#!/public/getCreatorCollection_get_12)
|
117
|
+
|
118
|
+
```ruby
|
119
|
+
@client.creators
|
120
|
+
@client.creators(firstName: 'Frank', lastName: 'Miller')
|
121
|
+
@client.creators(lastNameStartsWith: 'Mo', limit: 20, offset: 20)
|
122
|
+
|
123
|
+
```
|
124
|
+
|
125
|
+
- Fetches a single creator by id. [`GET /v1/public/creators/{creatorId}`](http://developer.marvel.com/docs#!/public/getCreatorIndividual_get_13)
|
126
|
+
|
127
|
+
```ruby
|
128
|
+
@client.creator(15)
|
129
|
+
```
|
130
|
+
|
131
|
+
- Fetches lists of comics filtered by a creator id. [`GET /v1/public/creators/{creatorId}/comics`](http://developer.marvel.com/docs#!/public/getComicsCollection_get_14)
|
132
|
+
|
133
|
+
```ruby
|
134
|
+
@client.creator_comics(15)
|
135
|
+
@client.creator_comics(15, format: 'trade paperback')
|
136
|
+
```
|
137
|
+
|
138
|
+
- Fetches lists of events filtered by a creator id. [`GET /v1/public/creators/{creatorId}/events`](http://developer.marvel.com/docs#!/public/getCreatorEventsCollection_get_15)
|
139
|
+
|
140
|
+
```ruby
|
141
|
+
@client.creator_events(30)
|
142
|
+
@client.creator_events(30, nameStartsWith: 'Civil')
|
143
|
+
```
|
144
|
+
|
145
|
+
- Fetches lists of series filtered by a creator id. [`GET /v1/public/creators/{creatorId}/series`](http://developer.marvel.com/docs#!/public/getCreatorSeriesCollection_get_16)
|
146
|
+
|
147
|
+
```ruby
|
148
|
+
@client.creator_series(30)
|
149
|
+
@client.creator_series(30, seriesType: 'limited')
|
150
|
+
```
|
151
|
+
|
152
|
+
- Fetches lists of stories filtered by a creator id. [`GET /v1/public/creators/{creatorId}/stories`](http://developer.marvel.com/docs#!/public/getCreatorStoryCollection_get_17)
|
153
|
+
|
154
|
+
```ruby
|
155
|
+
@client.creator_stories(30)
|
156
|
+
@client.creator_stories(30, limit: 40, offset: 7750)
|
157
|
+
```
|
158
|
+
|
159
|
+
### Events
|
160
|
+
|
161
|
+
- Fetches lists of events. [`GET /v1/public/events`](http://developer.marvel.com/docs#!/public/getEventsCollection_get_18)
|
162
|
+
|
163
|
+
```ruby
|
164
|
+
@client.events
|
165
|
+
@client.events(name: 'Infinity Gauntlet')
|
166
|
+
@client.events(characters: [1009156, 1009652])
|
167
|
+
```
|
168
|
+
|
169
|
+
- Fetches a single event by id. [`GET /v1/public/events/{eventId}`](http://developer.marvel.com/docs#!/public/getEventIndividual_get_19)
|
170
|
+
|
171
|
+
```ruby
|
172
|
+
@client.event(227)
|
173
|
+
```
|
174
|
+
|
175
|
+
- Fetches lists of characters filtered by an event id. [`GET /v1/public/events/{eventId}/characters`](http://developer.marvel.com/docs#!/public/getEventCharacterCollection_get_20)
|
176
|
+
|
177
|
+
```ruby
|
178
|
+
@client.event_characters(227)
|
179
|
+
@client.event_characters(227, modifiedSince: '2014-04-29')
|
180
|
+
```
|
181
|
+
|
182
|
+
- Fetches lists of comics filtered by an event id. [`GET /v1/public/events/{eventId}/comics`](http://developer.marvel.com/docs#!/public/getComicsCollection_get_21)
|
183
|
+
|
184
|
+
```ruby
|
185
|
+
@client.event_comics(227)
|
186
|
+
@client.event_comics(227, hasDigitalIssue: true, orderBy: 'onsaleDate')
|
187
|
+
```
|
188
|
+
|
189
|
+
- Fetches lists of creators filtered by an event id. [`GET /v1/public/events/{eventId}/creators`](http://developer.marvel.com/docs#!/public/getCreatorCollection_get_22)
|
190
|
+
|
191
|
+
```ruby
|
192
|
+
@client.event_creators(227)
|
193
|
+
@@client.event_creators(227, lastNameStartsWith: 'Lar')
|
194
|
+
```
|
195
|
+
|
196
|
+
- Fetches lists of series filtered by an event id. [`GET /v1/public/events/{eventId}/series`](http://developer.marvel.com/docs#!/public/getEventSeriesCollection_get_23)
|
197
|
+
|
198
|
+
```ruby
|
199
|
+
@client.event_series(227)
|
200
|
+
@client.event_series(227, startYear: 1995, seriesType: 'limited')
|
201
|
+
```
|
202
|
+
|
203
|
+
- Fetches lists of stories filtered by an event id. [`GET /v1/public/events/{eventId}/stories`](http://developer.marvel.com/docs#!/public/getEventStoryCollection_get_24)
|
204
|
+
|
205
|
+
```ruby
|
206
|
+
@client.event_stories(227)
|
207
|
+
@client.event_stories(227, orderBy: 'id', limit: 30, offset: 20)
|
208
|
+
```
|
209
|
+
|
210
|
+
### Series
|
211
|
+
|
212
|
+
- Fetches lists of series. [`GET /v1/public/series`](http://developer.marvel.com/docs#!/public/getSeriesCollection_get_25)
|
213
|
+
|
214
|
+
```ruby
|
215
|
+
@client.series
|
216
|
+
@client.series(title: 'Uncanny X-Men')
|
217
|
+
@client.series(titleStartsWith: 'Astonishing', orderBy: 'startDate', limit: 100)
|
218
|
+
```
|
219
|
+
|
220
|
+
- Fetches a single comic series by id. [`GET /v1/public/series/{seriesId}`](http://developer.marvel.com/docs#!/public/getSeriesIndividual_get_26)
|
221
|
+
|
222
|
+
```ruby
|
223
|
+
@client.serie(354)
|
224
|
+
```
|
225
|
+
|
226
|
+
- Fetches lists of characters filtered by a series id. [`GET /v1/public/series/{seriesId}/characters`](http://developer.marvel.com/docs#!/public/getSeriesCharacterWrapper_get_27)
|
227
|
+
|
228
|
+
```ruby
|
229
|
+
@client.series_characters(354)
|
230
|
+
@client.series_characters(354, nameStartsWith: 'Iron')
|
231
|
+
```
|
232
|
+
|
233
|
+
- Fetches lists of comics filtered by a series id. [`GET /v1/public/series/{seriesId}/comics`](http://developer.marvel.com/docs#!/public/getComicsCollection_get_28)
|
234
|
+
|
235
|
+
```ruby
|
236
|
+
@client.series_comics(354)
|
237
|
+
@client.series_comics(354, issueNumber: 1)
|
238
|
+
```
|
239
|
+
|
240
|
+
- Fetches lists of creators filtered by a series id. [`GET /v1/public/series/{seriesId}/creators`](http://developer.marvel.com/docs#!/public/getCreatorCollection_get_29)
|
241
|
+
|
242
|
+
```ruby
|
243
|
+
@client.series_creators(354)
|
244
|
+
@client.series_creators(354, lastName: 'Kirby')
|
245
|
+
```
|
246
|
+
|
247
|
+
- Fetches lists of events filtered by a series id. [`GET /v1/public/series/{seriesId}/events`](http://developer.marvel.com/docs#!/public/getEventsCollection_get_30)
|
248
|
+
|
249
|
+
```ruby
|
250
|
+
@client.series_events(354)
|
251
|
+
@client.series_events(354, orderBy: 'startDate')
|
252
|
+
```
|
253
|
+
|
254
|
+
- Fetches lists of stories filtered by a series id. [`GET /v1/public/series/{seriesId}/stories`](http://developer.marvel.com/docs#!/public/getSeriesStoryCollection_get_31)
|
255
|
+
|
256
|
+
```ruby
|
257
|
+
@client.series_stories(354)
|
258
|
+
@client.series_stories(354, modifiedSince: '2013-06-01')
|
259
|
+
```
|
260
|
+
|
261
|
+
### Stories
|
262
|
+
|
263
|
+
- Fetches lists of stories. [`GET /v1/public/stories`](http://developer.marvel.com/docs#!/public/getStoryCollection_get_32)
|
264
|
+
|
265
|
+
```ruby
|
266
|
+
@client.stories
|
267
|
+
@client.stories(creators: 15)
|
268
|
+
@client.stories(characters: [1009156, 1009652], orderBy: '-modified')
|
269
|
+
```
|
270
|
+
|
271
|
+
- Fetches a single comic story by id. [`GET /v1/public/stories/{storyId}`](http://developer.marvel.com/docs#!/public/getStoryIndividual_get_33)
|
272
|
+
|
273
|
+
```ruby
|
274
|
+
@client.story(6320)
|
275
|
+
```
|
276
|
+
|
277
|
+
- Fetches lists of characters filtered by a story id. [`GET /v1/public/stories/{storyId}/characters`](http://developer.marvel.com/docs#!/public/getCreatorCollection_get_34)
|
278
|
+
|
279
|
+
```ruby
|
280
|
+
@client.story_characters(14410)
|
281
|
+
@client.story_characters(14410, nameStartsWith: 'D')
|
282
|
+
```
|
283
|
+
|
284
|
+
- Fetches lists of comics filtered by a story id. [`GET /v1/public/stories/{storyId}/comics`](http://developer.marvel.com/docs#!/public/getComicsCollection_get_35)
|
285
|
+
|
286
|
+
```ruby
|
287
|
+
@client.story_comics(126)
|
288
|
+
@client.story_comics(126, format: 'trade paperback')
|
289
|
+
```
|
290
|
+
|
291
|
+
- Fetches lists of creators filtered by a story id. [`GET /v1/public/stories/{storyId}/creators`](http://developer.marvel.com/docs#!/public/getCreatorCollection_get_36)
|
292
|
+
|
293
|
+
```ruby
|
294
|
+
@client.story_creators(126)
|
295
|
+
@client.story_creators(126, lastNameStartsWith: 'S')
|
296
|
+
```
|
297
|
+
|
298
|
+
- Fetches lists of events filtered by a story id. [`GET /v1/public/stories/{storyId}/events`](http://developer.marvel.com/docs#!/public/getEventsCollection_get_37)
|
299
|
+
|
300
|
+
```ruby
|
301
|
+
@client.story_events(12964)
|
302
|
+
@client.story_events(12964, orderBy: 'name')
|
303
|
+
```
|
304
|
+
|
305
|
+
- Fetches lists of series filtered by a story id. [`GET /v1/public/stories/{storyId}/series`](http://developer.marvel.com/docs#!/public/getStorySeriesCollection_get_38)
|
306
|
+
|
307
|
+
```ruby
|
308
|
+
@client.story_series(126)
|
309
|
+
@client.story_series(126, titleStartsWith: 'Infinity')
|
310
|
+
```
|
12
311
|
|
13
312
|
## Contributing to marvel_api
|
14
313
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/lib/marvel/client.rb
CHANGED
@@ -37,234 +37,248 @@ module Marvel
|
|
37
37
|
# Characters:
|
38
38
|
|
39
39
|
# fetches lists of characters
|
40
|
-
def
|
40
|
+
def characters(options = {})
|
41
41
|
# v1/public/characters
|
42
|
+
get('characters', options)
|
42
43
|
end
|
43
44
|
|
44
45
|
# fetches a single character by id
|
45
|
-
def
|
46
|
+
def character(id, options = {})
|
46
47
|
# v1/public/characters/{characterId}
|
47
|
-
get("characters/#{id}
|
48
|
+
get("characters/#{id}", options)
|
48
49
|
end
|
49
50
|
|
50
51
|
# fetches lists of comics filtered by a character id
|
51
|
-
def
|
52
|
+
def character_comics(id, options = {})
|
52
53
|
# v1/public/characters/{characterId}/comics
|
53
|
-
get("characters/#{id}/comics
|
54
|
+
get("characters/#{id}/comics", options)
|
54
55
|
end
|
55
56
|
|
56
57
|
# fetches lists of events filtered by a character id
|
57
|
-
def
|
58
|
+
def character_events(id, options = {})
|
58
59
|
# v1/public/characters/{characterId}/events
|
59
|
-
get("characters/#{id}/events
|
60
|
+
get("characters/#{id}/events", options)
|
61
|
+
end
|
62
|
+
|
63
|
+
# fetches lists of series filtered by a character id
|
64
|
+
def character_series(id, options = {})
|
65
|
+
# vi/public/characters/{characterId}/series
|
66
|
+
get("characters/#{id}/series", options)
|
60
67
|
end
|
61
68
|
|
62
69
|
# fetches lists of stories filtered by a character id
|
63
|
-
def
|
70
|
+
def character_stories(id, options = {})
|
64
71
|
# v1/public/characters/{characterId}/stories
|
65
|
-
get("characters/#{id}/stories
|
72
|
+
get("characters/#{id}/stories", options)
|
66
73
|
end
|
67
74
|
|
68
75
|
# Comics:
|
69
76
|
|
70
77
|
# fetches lists of comics
|
71
|
-
def
|
78
|
+
def comics(options = {})
|
72
79
|
# v1/public/comics
|
80
|
+
get('comics', options)
|
73
81
|
end
|
74
82
|
|
75
83
|
# fetches a single comic by id
|
76
|
-
def
|
84
|
+
def comic(id, options = {})
|
77
85
|
# v1/public/comics/{comicId}
|
78
|
-
get("comics/#{id}
|
86
|
+
get("comics/#{id}", options)
|
79
87
|
end
|
80
88
|
|
81
89
|
# fetches lists of characters filtered by a comic id
|
82
|
-
def
|
90
|
+
def comic_characters(id, options = {})
|
83
91
|
# v1/public/comics/{comicId}/characters
|
84
|
-
get("comics/#{id}/characters
|
92
|
+
get("comics/#{id}/characters", options)
|
85
93
|
end
|
86
94
|
|
87
95
|
# fetches lists of creators filtered by a comic id
|
88
|
-
def
|
96
|
+
def comic_creators(id, options = {})
|
89
97
|
# v1/public/comics/{comicId}/creators
|
90
|
-
get("comics/#{id}/creators
|
98
|
+
get("comics/#{id}/creators", options)
|
91
99
|
end
|
92
100
|
|
93
101
|
# fetches lists of events filtered by a comic id
|
94
|
-
def
|
102
|
+
def comic_events(id, options = {})
|
95
103
|
# v1/public/comics/{comicId}/events
|
96
|
-
get("comics/#{id}/events
|
104
|
+
get("comics/#{id}/events", options)
|
97
105
|
end
|
98
106
|
|
99
107
|
# fetches lists of stories filtered by a comic id
|
100
|
-
def
|
108
|
+
def comic_stories(id, options = {})
|
101
109
|
# v1/public/comics/{comicId}/stories
|
102
|
-
get("comics/#{id}/stories
|
110
|
+
get("comics/#{id}/stories", options)
|
103
111
|
end
|
104
112
|
|
105
113
|
# Creators:
|
106
114
|
|
107
115
|
# fetches lists of creators
|
108
|
-
def
|
116
|
+
def creators(options = {})
|
109
117
|
# v1/public/creators
|
118
|
+
get('creators', options)
|
110
119
|
end
|
111
120
|
|
112
121
|
# fetches a single creator by id
|
113
|
-
def
|
122
|
+
def creator(id, options = {})
|
114
123
|
# v1/public/creators/{creatorId}
|
115
|
-
get("creators/#{id}
|
124
|
+
get("creators/#{id}", options)
|
116
125
|
end
|
117
126
|
|
118
127
|
# fetches lists of comics filtered by a creator id
|
119
|
-
def
|
128
|
+
def creator_comics(id, options = {})
|
120
129
|
# v1/public/creators/{creatorId}/comics
|
121
|
-
get("creators/#{id}/comics
|
130
|
+
get("creators/#{id}/comics", options)
|
122
131
|
end
|
123
132
|
|
124
133
|
# fetches lists of events filtered by a creator id
|
125
|
-
def
|
134
|
+
def creator_events(id, options = {})
|
126
135
|
# v1/public/creators/{creatorId}/events
|
127
|
-
get("creators/#{id}/events
|
136
|
+
get("creators/#{id}/events", options)
|
137
|
+
end
|
138
|
+
|
139
|
+
# fetches lists of series filtered by a creator id
|
140
|
+
def creator_series(id, options = {})
|
141
|
+
# v1/public/creators/{creatorId}/series
|
142
|
+
get("creators/#{id}/series", options)
|
128
143
|
end
|
129
144
|
|
130
145
|
# fetches lists of stories filtered by a creator id
|
131
|
-
def
|
146
|
+
def creator_stories(id, options = {})
|
132
147
|
# v1/public/creators/{creatorId}/stories
|
133
|
-
get("creators/#{id}/stories
|
148
|
+
get("creators/#{id}/stories", options)
|
134
149
|
end
|
135
150
|
|
136
151
|
# Events:
|
137
152
|
|
138
153
|
# fetches lists of events
|
139
|
-
def
|
154
|
+
def events(options = {})
|
140
155
|
# v1/public/events
|
156
|
+
get('events', options)
|
141
157
|
end
|
142
158
|
|
143
159
|
# fetches a single event by id
|
144
|
-
def
|
160
|
+
def event(id, options = {})
|
145
161
|
# v1/public/events/{eventId}
|
146
|
-
get("events/#{id}
|
162
|
+
get("events/#{id}", options)
|
147
163
|
end
|
148
164
|
|
149
165
|
# fetches lists of characters filtered by an event id
|
150
|
-
def
|
166
|
+
def event_characters(id, options = {})
|
151
167
|
# v1/public/events/{eventId}/characters
|
152
|
-
get("events/#{id}/characters
|
168
|
+
get("events/#{id}/characters", options)
|
153
169
|
end
|
154
170
|
|
155
171
|
# fetches lists of comics filtered by an event id
|
156
|
-
def
|
172
|
+
def event_comics(id, options = {})
|
157
173
|
# v1/public/events/{eventId}/comics
|
158
|
-
get("events/#{id}/comics
|
174
|
+
get("events/#{id}/comics", options)
|
159
175
|
end
|
160
176
|
|
161
177
|
# fetches lists of creators filtered by an event id
|
162
|
-
def
|
178
|
+
def event_creators(id, options = {})
|
163
179
|
# v1/public/events/{eventId}/creators
|
164
|
-
get("events/#{id}/creators
|
180
|
+
get("events/#{id}/creators", options)
|
181
|
+
end
|
182
|
+
|
183
|
+
# fetches lists of series filtered by an event id
|
184
|
+
def event_series(id, options = {})
|
185
|
+
# vi/public/events/{eventId}/series
|
186
|
+
get("events/#{id}/series", options)
|
165
187
|
end
|
166
188
|
|
167
189
|
# fetches lists of stories filtered by an event id
|
168
|
-
def
|
190
|
+
def event_stories(id, options = {})
|
169
191
|
# v1/public/events/{eventId}/stories
|
170
|
-
get("events/#{id}/stories
|
192
|
+
get("events/#{id}/stories", options)
|
171
193
|
end
|
172
194
|
|
173
195
|
|
174
196
|
# Series:
|
175
197
|
|
176
198
|
# fetches lists of series
|
177
|
-
def
|
199
|
+
def series(options = {})
|
178
200
|
# v1/public/series
|
201
|
+
get('series', options)
|
179
202
|
end
|
180
203
|
|
181
204
|
# fetches a single comic series by id
|
182
|
-
def
|
205
|
+
def serie(id, options = {})
|
183
206
|
# v1/public/series/{seriesId}
|
184
|
-
get("series/#{id}
|
207
|
+
get("series/#{id}", options)
|
185
208
|
end
|
186
209
|
|
187
210
|
# fetches lists of characters filtered by a series id
|
188
|
-
def
|
211
|
+
def series_characters(id, options = {})
|
189
212
|
# v1/public/series/{seriesId}/characters
|
190
|
-
get("series/#{id}/characters
|
213
|
+
get("series/#{id}/characters", options)
|
191
214
|
end
|
192
215
|
|
193
216
|
# fetches lists of comics filtered by a series id
|
194
|
-
def
|
217
|
+
def series_comics(id, options = {})
|
195
218
|
# v1/public/series/{seriesId}/comics
|
196
|
-
get("series/#{id}/comics
|
219
|
+
get("series/#{id}/comics", options)
|
197
220
|
end
|
198
221
|
|
199
222
|
# fetches lists of creators filtered by a series id
|
200
|
-
def
|
223
|
+
def series_creators(id, options = {})
|
201
224
|
# v1/public/series/{seriesId}/creators
|
202
|
-
get("series/#{id}/creators
|
225
|
+
get("series/#{id}/creators", options)
|
203
226
|
end
|
204
227
|
|
205
228
|
# fetches lists of events filtered by a series id
|
206
|
-
def
|
229
|
+
def series_events(id, options = {})
|
207
230
|
# v1/public/series/{seriesId}/events
|
208
|
-
get("series/#{id}/events
|
231
|
+
get("series/#{id}/events", options)
|
209
232
|
end
|
210
233
|
|
211
234
|
# fetches lists of stories filtered by a series id
|
212
|
-
def
|
235
|
+
def series_stories(id, options = {})
|
213
236
|
# v1/public/series/{seriesId}/stories
|
214
|
-
get("series/#{id}/stories
|
237
|
+
get("series/#{id}/stories", options)
|
215
238
|
end
|
216
239
|
|
217
240
|
# Stories:
|
218
241
|
|
219
242
|
# fetches lists of stories
|
220
|
-
def
|
243
|
+
def stories(options = {})
|
221
244
|
# v1/public/stories
|
245
|
+
get('stories', options)
|
222
246
|
end
|
223
247
|
|
224
248
|
# fetches a single comic story by id
|
225
|
-
def
|
249
|
+
def story(id, options = {})
|
226
250
|
# v1/public/stories/{storyId}
|
227
|
-
get("stories/#{id}
|
251
|
+
get("stories/#{id}", options)
|
228
252
|
end
|
229
253
|
|
230
254
|
# fetches lists of characters filtered by a story id
|
231
|
-
def
|
255
|
+
def story_characters(id, options = {})
|
232
256
|
# v1/public/stories/{storyId}/characters
|
233
|
-
get("stories/#{id}/characters
|
257
|
+
get("stories/#{id}/characters", options)
|
234
258
|
end
|
235
259
|
|
236
260
|
# fetches lists of comics filtered by a story id
|
237
|
-
def
|
261
|
+
def story_comics(id, options = {})
|
238
262
|
# v1/public/stories/{storyId}/comics
|
239
|
-
get("stories/#{id}/comics
|
263
|
+
get("stories/#{id}/comics", options)
|
240
264
|
end
|
241
265
|
|
242
266
|
# fetches lists of creators filtered by a story id
|
243
|
-
def
|
267
|
+
def story_creators(id, options = {})
|
244
268
|
# v1/public/stories/{storyId}/creators
|
245
|
-
get("stories/#{id}/creators
|
269
|
+
get("stories/#{id}/creators", options)
|
246
270
|
end
|
247
271
|
|
248
272
|
# fetches lists of events filtered by a story id
|
249
|
-
def
|
273
|
+
def story_events(id, options = {})
|
250
274
|
# v1/public/stories/{storyId}/events
|
251
|
-
get("stories/#{id}/events
|
252
|
-
end
|
253
|
-
|
254
|
-
private
|
255
|
-
|
256
|
-
def auth
|
257
|
-
ts = timestamp
|
258
|
-
hsh = hash(ts)
|
259
|
-
"?ts=#{ts}&apikey=#{api_key}&hash=#{hsh}"
|
260
|
-
end
|
261
|
-
|
262
|
-
def hash(ts)
|
263
|
-
Digest::MD5.hexdigest(ts + private_key + api_key)
|
275
|
+
get("stories/#{id}/events", options)
|
264
276
|
end
|
265
277
|
|
266
|
-
|
267
|
-
|
278
|
+
# fetches lists of series filtered by a story id
|
279
|
+
def story_series(id, options = {})
|
280
|
+
# v1/public/stories/{storyId}/series
|
281
|
+
get("stories/#{id}/series", options)
|
268
282
|
end
|
269
283
|
end
|
270
284
|
end
|
data/lib/marvel/request.rb
CHANGED
@@ -6,11 +6,25 @@ module Marvel
|
|
6
6
|
|
7
7
|
private
|
8
8
|
|
9
|
-
def request(method, path, options)
|
9
|
+
def request(method, path, options = {})
|
10
10
|
response = connection.send(method) do |request|
|
11
|
-
request.url(path, options)
|
11
|
+
request.url(path, options.merge(auth))
|
12
12
|
end
|
13
13
|
response.body
|
14
14
|
end
|
15
|
+
|
16
|
+
def auth
|
17
|
+
ts = timestamp
|
18
|
+
hsh = hash(ts)
|
19
|
+
{ ts: ts, apikey: api_key, hash: hsh }
|
20
|
+
end
|
21
|
+
|
22
|
+
def hash(ts)
|
23
|
+
Digest::MD5.hexdigest(ts + private_key + api_key)
|
24
|
+
end
|
25
|
+
|
26
|
+
def timestamp
|
27
|
+
Time.now.to_s
|
28
|
+
end
|
15
29
|
end
|
16
30
|
end
|
data/marvel_api.gemspec
CHANGED
@@ -2,15 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: marvel_api 0.
|
5
|
+
# stub: marvel_api 0.2.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "marvel_api"
|
9
|
-
s.version = "0.
|
9
|
+
s.version = "0.2.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib"]
|
12
13
|
s.authors = ["Rahul Hor\u{e9}"]
|
13
|
-
s.date = "2014-
|
14
|
+
s.date = "2014-05-20"
|
14
15
|
s.description = "Marvel_API is a Ruby gem that lets you explore the Marvel Universe like never before."
|
15
16
|
s.email = "hore.rahul@gmail.com"
|
16
17
|
s.extra_rdoc_files = [
|
@@ -31,20 +32,21 @@ Gem::Specification.new do |s|
|
|
31
32
|
"lib/marvel/request.rb",
|
32
33
|
"lib/marvel_api.rb",
|
33
34
|
"marvel_api.gemspec",
|
34
|
-
"spec/
|
35
|
+
"spec/marvel_api/client_spec.rb",
|
36
|
+
"spec/marvel_api_spec.rb",
|
35
37
|
"spec/spec_helper.rb"
|
36
38
|
]
|
37
39
|
s.homepage = "http://github.com/O-I/marvel"
|
38
40
|
s.licenses = ["MIT"]
|
39
|
-
s.
|
40
|
-
s.rubygems_version = "2.1.9"
|
41
|
+
s.rubygems_version = "2.2.2"
|
41
42
|
s.summary = "Ruby bindings for the Marvel API"
|
42
43
|
|
43
44
|
if s.respond_to? :specification_version then
|
44
45
|
s.specification_version = 4
|
45
46
|
|
46
47
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
47
|
-
s.add_runtime_dependency(%q<faraday>, ["
|
48
|
+
s.add_runtime_dependency(%q<faraday>, [">= 0"])
|
49
|
+
s.add_runtime_dependency(%q<faraday_middleware>, [">= 0"])
|
48
50
|
s.add_runtime_dependency(%q<hashie>, [">= 0"])
|
49
51
|
s.add_development_dependency(%q<pry>, [">= 0"])
|
50
52
|
s.add_development_dependency(%q<rspec>, [">= 0"])
|
@@ -54,7 +56,8 @@ Gem::Specification.new do |s|
|
|
54
56
|
s.add_development_dependency(%q<jeweler>, ["~> 1.8.7"])
|
55
57
|
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
56
58
|
else
|
57
|
-
s.add_dependency(%q<faraday>, ["
|
59
|
+
s.add_dependency(%q<faraday>, [">= 0"])
|
60
|
+
s.add_dependency(%q<faraday_middleware>, [">= 0"])
|
58
61
|
s.add_dependency(%q<hashie>, [">= 0"])
|
59
62
|
s.add_dependency(%q<pry>, [">= 0"])
|
60
63
|
s.add_dependency(%q<rspec>, [">= 0"])
|
@@ -65,7 +68,8 @@ Gem::Specification.new do |s|
|
|
65
68
|
s.add_dependency(%q<simplecov>, [">= 0"])
|
66
69
|
end
|
67
70
|
else
|
68
|
-
s.add_dependency(%q<faraday>, ["
|
71
|
+
s.add_dependency(%q<faraday>, [">= 0"])
|
72
|
+
s.add_dependency(%q<faraday_middleware>, [">= 0"])
|
69
73
|
s.add_dependency(%q<hashie>, [">= 0"])
|
70
74
|
s.add_dependency(%q<pry>, [">= 0"])
|
71
75
|
s.add_dependency(%q<rspec>, [">= 0"])
|
data/spec/spec_helper.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
2
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
3
|
require 'rspec'
|
4
|
-
require '
|
4
|
+
require 'marvel_api'
|
5
5
|
|
6
6
|
# Requires supporting files with custom matchers and macros, etc,
|
7
7
|
# in ./support/ and its subdirectories.
|
metadata
CHANGED
@@ -1,139 +1,153 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: marvel_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rahul Horé
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0
|
19
|
+
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0
|
26
|
+
version: '0'
|
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'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: hashie
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
|
-
- -
|
45
|
+
- - ">="
|
32
46
|
- !ruby/object:Gem::Version
|
33
47
|
version: '0'
|
34
48
|
type: :runtime
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
|
-
- -
|
52
|
+
- - ">="
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: pry
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
|
-
- -
|
59
|
+
- - ">="
|
46
60
|
- !ruby/object:Gem::Version
|
47
61
|
version: '0'
|
48
62
|
type: :development
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
|
-
- -
|
66
|
+
- - ">="
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: rspec
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
|
-
- -
|
73
|
+
- - ">="
|
60
74
|
- !ruby/object:Gem::Version
|
61
75
|
version: '0'
|
62
76
|
type: :development
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
|
-
- -
|
80
|
+
- - ">="
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: shoulda
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
|
-
- -
|
87
|
+
- - ">="
|
74
88
|
- !ruby/object:Gem::Version
|
75
89
|
version: '0'
|
76
90
|
type: :development
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
|
-
- -
|
94
|
+
- - ">="
|
81
95
|
- !ruby/object:Gem::Version
|
82
96
|
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: rdoc
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
|
-
- - ~>
|
101
|
+
- - "~>"
|
88
102
|
- !ruby/object:Gem::Version
|
89
103
|
version: '3.12'
|
90
104
|
type: :development
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
|
-
- - ~>
|
108
|
+
- - "~>"
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: '3.12'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: bundler
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
100
114
|
requirements:
|
101
|
-
- - ~>
|
115
|
+
- - "~>"
|
102
116
|
- !ruby/object:Gem::Version
|
103
117
|
version: '1.0'
|
104
118
|
type: :development
|
105
119
|
prerelease: false
|
106
120
|
version_requirements: !ruby/object:Gem::Requirement
|
107
121
|
requirements:
|
108
|
-
- - ~>
|
122
|
+
- - "~>"
|
109
123
|
- !ruby/object:Gem::Version
|
110
124
|
version: '1.0'
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: jeweler
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
114
128
|
requirements:
|
115
|
-
- - ~>
|
129
|
+
- - "~>"
|
116
130
|
- !ruby/object:Gem::Version
|
117
131
|
version: 1.8.7
|
118
132
|
type: :development
|
119
133
|
prerelease: false
|
120
134
|
version_requirements: !ruby/object:Gem::Requirement
|
121
135
|
requirements:
|
122
|
-
- - ~>
|
136
|
+
- - "~>"
|
123
137
|
- !ruby/object:Gem::Version
|
124
138
|
version: 1.8.7
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
140
|
name: simplecov
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
128
142
|
requirements:
|
129
|
-
- -
|
143
|
+
- - ">="
|
130
144
|
- !ruby/object:Gem::Version
|
131
145
|
version: '0'
|
132
146
|
type: :development
|
133
147
|
prerelease: false
|
134
148
|
version_requirements: !ruby/object:Gem::Requirement
|
135
149
|
requirements:
|
136
|
-
- -
|
150
|
+
- - ">="
|
137
151
|
- !ruby/object:Gem::Version
|
138
152
|
version: '0'
|
139
153
|
description: Marvel_API is a Ruby gem that lets you explore the Marvel Universe like
|
@@ -145,8 +159,8 @@ extra_rdoc_files:
|
|
145
159
|
- LICENSE.txt
|
146
160
|
- README.md
|
147
161
|
files:
|
148
|
-
- .document
|
149
|
-
- .rspec
|
162
|
+
- ".document"
|
163
|
+
- ".rspec"
|
150
164
|
- Gemfile
|
151
165
|
- LICENSE.txt
|
152
166
|
- README.md
|
@@ -158,7 +172,8 @@ files:
|
|
158
172
|
- lib/marvel/request.rb
|
159
173
|
- lib/marvel_api.rb
|
160
174
|
- marvel_api.gemspec
|
161
|
-
- spec/
|
175
|
+
- spec/marvel_api/client_spec.rb
|
176
|
+
- spec/marvel_api_spec.rb
|
162
177
|
- spec/spec_helper.rb
|
163
178
|
homepage: http://github.com/O-I/marvel
|
164
179
|
licenses:
|
@@ -170,17 +185,17 @@ require_paths:
|
|
170
185
|
- lib
|
171
186
|
required_ruby_version: !ruby/object:Gem::Requirement
|
172
187
|
requirements:
|
173
|
-
- -
|
188
|
+
- - ">="
|
174
189
|
- !ruby/object:Gem::Version
|
175
190
|
version: '0'
|
176
191
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
177
192
|
requirements:
|
178
|
-
- -
|
193
|
+
- - ">="
|
179
194
|
- !ruby/object:Gem::Version
|
180
195
|
version: '0'
|
181
196
|
requirements: []
|
182
197
|
rubyforge_project:
|
183
|
-
rubygems_version: 2.
|
198
|
+
rubygems_version: 2.2.2
|
184
199
|
signing_key:
|
185
200
|
specification_version: 4
|
186
201
|
summary: Ruby bindings for the Marvel API
|