lib/marvel/client.rb in marvel_api-0.1.3 vs lib/marvel/client.rb in marvel_api-0.2.0
- old
+ new
@@ -35,236 +35,250 @@
# representation of the original JSON response
# Characters:
# fetches lists of characters
- def get_characters
+ def characters(options = {})
# v1/public/characters
+ get('characters', options)
end
# fetches a single character by id
- def get_character(id)
+ def character(id, options = {})
# v1/public/characters/{characterId}
- get("characters/#{id}#{auth}")
+ get("characters/#{id}", options)
end
# fetches lists of comics filtered by a character id
- def get_comics_by_character_id(id)
+ def character_comics(id, options = {})
# v1/public/characters/{characterId}/comics
- get("characters/#{id}/comics#{auth}")
+ get("characters/#{id}/comics", options)
end
# fetches lists of events filtered by a character id
- def get_events_by_character_id(id)
+ def character_events(id, options = {})
# v1/public/characters/{characterId}/events
- get("characters/#{id}/events#{auth}")
+ get("characters/#{id}/events", options)
end
+ # fetches lists of series filtered by a character id
+ def character_series(id, options = {})
+ # vi/public/characters/{characterId}/series
+ get("characters/#{id}/series", options)
+ end
+
# fetches lists of stories filtered by a character id
- def get_stories_by_character_id(id)
+ def character_stories(id, options = {})
# v1/public/characters/{characterId}/stories
- get("characters/#{id}/stories#{auth}")
+ get("characters/#{id}/stories", options)
end
# Comics:
# fetches lists of comics
- def get_comics
+ def comics(options = {})
# v1/public/comics
+ get('comics', options)
end
# fetches a single comic by id
- def get_comic(id)
+ def comic(id, options = {})
# v1/public/comics/{comicId}
- get("comics/#{id}#{auth}")
+ get("comics/#{id}", options)
end
# fetches lists of characters filtered by a comic id
- def get_characters_by_comic_id(id)
+ def comic_characters(id, options = {})
# v1/public/comics/{comicId}/characters
- get("comics/#{id}/characters#{auth}")
+ get("comics/#{id}/characters", options)
end
# fetches lists of creators filtered by a comic id
- def get_creators_by_comic_id(id)
+ def comic_creators(id, options = {})
# v1/public/comics/{comicId}/creators
- get("comics/#{id}/creators#{auth}")
+ get("comics/#{id}/creators", options)
end
# fetches lists of events filtered by a comic id
- def get_events_by_comic_id(id)
+ def comic_events(id, options = {})
# v1/public/comics/{comicId}/events
- get("comics/#{id}/events#{auth}")
+ get("comics/#{id}/events", options)
end
# fetches lists of stories filtered by a comic id
- def get_stories_by_comic_id(id)
+ def comic_stories(id, options = {})
# v1/public/comics/{comicId}/stories
- get("comics/#{id}/stories#{auth}")
+ get("comics/#{id}/stories", options)
end
# Creators:
# fetches lists of creators
- def get_creators
+ def creators(options = {})
# v1/public/creators
+ get('creators', options)
end
# fetches a single creator by id
- def get_creator(id)
+ def creator(id, options = {})
# v1/public/creators/{creatorId}
- get("creators/#{id}#{auth}")
+ get("creators/#{id}", options)
end
# fetches lists of comics filtered by a creator id
- def get_comics_by_creator_id(id)
+ def creator_comics(id, options = {})
# v1/public/creators/{creatorId}/comics
- get("creators/#{id}/comics#{auth}")
+ get("creators/#{id}/comics", options)
end
# fetches lists of events filtered by a creator id
- def get_events_by_creator_id(id)
+ def creator_events(id, options = {})
# v1/public/creators/{creatorId}/events
- get("creators/#{id}/events#{auth}")
+ get("creators/#{id}/events", options)
end
+ # fetches lists of series filtered by a creator id
+ def creator_series(id, options = {})
+ # v1/public/creators/{creatorId}/series
+ get("creators/#{id}/series", options)
+ end
+
# fetches lists of stories filtered by a creator id
- def get_stories_by_creator_id(id)
+ def creator_stories(id, options = {})
# v1/public/creators/{creatorId}/stories
- get("creators/#{id}/stories#{auth}")
+ get("creators/#{id}/stories", options)
end
# Events:
# fetches lists of events
- def get_events
+ def events(options = {})
# v1/public/events
+ get('events', options)
end
# fetches a single event by id
- def get_event(id)
+ def event(id, options = {})
# v1/public/events/{eventId}
- get("events/#{id}#{auth}")
+ get("events/#{id}", options)
end
# fetches lists of characters filtered by an event id
- def get_characters_by_event_id(id)
+ def event_characters(id, options = {})
# v1/public/events/{eventId}/characters
- get("events/#{id}/characters#{auth}")
+ get("events/#{id}/characters", options)
end
# fetches lists of comics filtered by an event id
- def get_comics_by_event_id(id)
+ def event_comics(id, options = {})
# v1/public/events/{eventId}/comics
- get("events/#{id}/comics#{auth}")
+ get("events/#{id}/comics", options)
end
# fetches lists of creators filtered by an event id
- def get_creators_by_event_id(id)
+ def event_creators(id, options = {})
# v1/public/events/{eventId}/creators
- get("events/#{id}/creators#{auth}")
+ get("events/#{id}/creators", options)
end
+ # fetches lists of series filtered by an event id
+ def event_series(id, options = {})
+ # vi/public/events/{eventId}/series
+ get("events/#{id}/series", options)
+ end
+
# fetches lists of stories filtered by an event id
- def get_stories_by_event_id(id)
+ def event_stories(id, options = {})
# v1/public/events/{eventId}/stories
- get("events/#{id}/stories#{auth}")
+ get("events/#{id}/stories", options)
end
# Series:
# fetches lists of series
- def get_series
+ def series(options = {})
# v1/public/series
+ get('series', options)
end
# fetches a single comic series by id
- def get_series_by_id(id)
+ def serie(id, options = {})
# v1/public/series/{seriesId}
- get("series/#{id}#{auth}")
+ get("series/#{id}", options)
end
# fetches lists of characters filtered by a series id
- def get_characters_by_series_id(id)
+ def series_characters(id, options = {})
# v1/public/series/{seriesId}/characters
- get("series/#{id}/characters#{auth}")
+ get("series/#{id}/characters", options)
end
# fetches lists of comics filtered by a series id
- def get_comics_by_series_id(id)
+ def series_comics(id, options = {})
# v1/public/series/{seriesId}/comics
- get("series/#{id}/comics#{auth}")
+ get("series/#{id}/comics", options)
end
# fetches lists of creators filtered by a series id
- def get_creators_by_series_id(id)
+ def series_creators(id, options = {})
# v1/public/series/{seriesId}/creators
- get("series/#{id}/creators#{auth}")
+ get("series/#{id}/creators", options)
end
# fetches lists of events filtered by a series id
- def get_events_by_series_id(id)
+ def series_events(id, options = {})
# v1/public/series/{seriesId}/events
- get("series/#{id}/events#{auth}")
+ get("series/#{id}/events", options)
end
# fetches lists of stories filtered by a series id
- def get_stories_by_series_id(id)
+ def series_stories(id, options = {})
# v1/public/series/{seriesId}/stories
- get("series/#{id}/stories#{auth}")
+ get("series/#{id}/stories", options)
end
# Stories:
# fetches lists of stories
- def get_stories
+ def stories(options = {})
# v1/public/stories
+ get('stories', options)
end
# fetches a single comic story by id
- def get_story(id)
+ def story(id, options = {})
# v1/public/stories/{storyId}
- get("stories/#{id}#{auth}")
+ get("stories/#{id}", options)
end
# fetches lists of characters filtered by a story id
- def get_characters_by_story_id(id)
+ def story_characters(id, options = {})
# v1/public/stories/{storyId}/characters
- get("stories/#{id}/characters#{auth}")
+ get("stories/#{id}/characters", options)
end
# fetches lists of comics filtered by a story id
- def get_comics_by_story_id(id)
+ def story_comics(id, options = {})
# v1/public/stories/{storyId}/comics
- get("stories/#{id}/comics#{auth}")
+ get("stories/#{id}/comics", options)
end
# fetches lists of creators filtered by a story id
- def get_creators_by_story_id(id)
+ def story_creators(id, options = {})
# v1/public/stories/{storyId}/creators
- get("stories/#{id}/creators#{auth}")
+ get("stories/#{id}/creators", options)
end
# fetches lists of events filtered by a story id
- def get_events_by_story_id(id)
+ def story_events(id, options = {})
# v1/public/stories/{storyId}/events
- get("stories/#{id}/events#{auth}")
+ get("stories/#{id}/events", options)
end
- private
-
- def auth
- ts = timestamp
- hsh = hash(ts)
- "?ts=#{ts}&apikey=#{api_key}&hash=#{hsh}"
- end
-
- def hash(ts)
- Digest::MD5.hexdigest(ts + private_key + api_key)
- end
-
- def timestamp
- Time.now.to_s
+ # fetches lists of series filtered by a story id
+ def story_series(id, options = {})
+ # v1/public/stories/{storyId}/series
+ get("stories/#{id}/series", options)
end
end
end
\ No newline at end of file