Skip to content

jhonesgoncalves/marvel-wrapper

Repository files navigation

Marvel Wrapper

Build Status Coverage Status License: MIT

A wrapper to work with the Marvel Web API.

Browser Support

This library relies on Fetch API. And this API is supported in the following browsers.

Chrome Firefox Opera Safari IE
39+ ✔ 42+ ✔ 29+ ✔ 10.1+ ✔ Nope ✘

Dependencies

This library depends on fetch to make requests to the Marvel Web API. For environments that don't support fetch, you'll need to provide a polyfill to browser or polyfill to Node.

Installation

$ npm install marvel-wrapper --save

How to use

ES6

// to import a specific method
import MarvelWrapper from 'marvel-wrapper';

const marvel = new MarvelWrapper({
  privateKey: 'YOUR_PRIVATEKEY_HERE',
  publicKey: 'YOUR_PUBLICKEY_HERE',
  limit: 'OPTIONAL_LIMIT'
});

// using  method
marvel.comic.getComics();

CommonJS

const MarvelWrapper = require('marvel-wrapper').default;

const marvel = new MarvelWrapper({
  privateKey: 'YOUR_PRIVATEKEY_HERE',
  publicKey: 'YOUR_PUBLICKEY_HERE',
  limit: 'OPTIONAL_LIMIT'
});

UMD in Browser

<!-- to import non-minified version -->
<script src="marvel-wrapper.js"></script>

<!-- to import minified version -->
<script src="marvel-wrapper.min.js"></script>

After that the library will be available to the Global as MarvelWrapper. Follow an example:

const marvel = new MarvelWrapper({
  privateKey: 'YOUR_PRIVATEKEY_HERE',
  publicKey: 'YOUR_PUBLICKEY_HERE',
  limit: 'OPTIONAL_LIMIT'
});

const comics = marvel.comic.getComics();

Methods

Follow the methods that the library provides.

COMICS

comic.getComics()

Fetches lists of comics. Test in Marvel Web Console.

--

Example

marvel.comic.getComics()
  .then(reponse => {
    // do what you want with the response
    response => response.data.results.map(item => console.log(item))
  })

comic.getComic(id)

Fetch one comic by id. Test in Marvel Web Console.

Arguments

Argument Type Options
id string 'Any search id'

Example

marvel.comic.getComic('37504')
  .then(response => {
    // do what you want with the response
    response => response.data.results.map(item => console.log(item))
  })

comic.getCharacters(id)

Fetched list characters by id references comic. Test in Marvel Web Console.

Arguments

Argument Type Options
id string 'Any search id'

Example

marvel.comic.getCharacters('37504')
  .then(response => {
    // do what you want with the response
    response => response.data.results.map(item => console.log(item.name))
  })

comic.getEvents(id)

Fetched list events by id references comic. Test in Marvel Web Console.

Arguments

Argument Type Options
id string 'Any search id'

Example

marvel.comic.getEvents('37504')
  .then(response => {
    // do what you want with the response
    response => response.data.results.map(item => console.log(item.name))
  })

comic.getCreators(id)

Fetched list creators by id references comic. Test in Marvel Web Console.

Arguments

Argument Type Options
id string 'Any search id'

Example

marvel.comic.getCreators('37504')
  .then(response => {
    // do what you want with the response
    response => response.data.results.map(item => console.log(item.name))
  })

comic.getStories(id)

Fetched list stories by id references comic. Test in Marvel Web Console.

Arguments

Argument Type Options
id string 'Any search id'

Example

marvel.comic.search('spider')
  .then(response => {
    // do what you want with the response
    response => response.data.results.map(item => console.log(item))
  })

comic.getStories(id)

Fetched list stories by id references comic. Test in Marvel Web Console.

Arguments

Argument Type Options
id string 'Any search id'

Example

marvel.comic.getStories('37504')
  .then(response => {
    // do what you want with the response
    response => response.data.results.map(item => console.log(item.name))
  })

comic.search(startname)

Fetched list comics by start name of search. Test in Marvel Web Console.

Arguments

Argument Type Options
startname string 'Any search letter'

Example

marvel.comic.search('spider')
  .then(response => {
    // do what you want with the response
    response => response.data.results.map(item => console.log(item.name))
  })

CHARACTERS

character.getCharacters()

Fetches lists of characters. Test in Marvel Web Console.

--

Example

marvel.character.getCharacters()
  .then(reponse => {
    // do what you want with the response
    response => response.data.results.map(item => console.log(item))
  })

character.getCharacter(id)

Fetch one character by id. Test in Marvel Web Console.

Arguments

Argument Type Options
id string 'Any search id'

Example

marvel.character.getCharacter('37504')
  .then(response => {
    // do what you want with the response
    response => response.data.results.map(item => console.log(item))
  })

character.getComics(id)

Fetched list comics by id references character. Test in Marvel Web Console.

Arguments

Argument Type Options
id string 'Any search id'

Example

marvel.character.getComics('37504')
  .then(response => {
    // do what you want with the response
    response => response.data.results.map(item => console.log(item.name))
  })

character.getEvents(id)

Fetched list events by id references character. Test in Marvel Web Console.

Arguments

Argument Type Options
id string 'Any search id'

Example

marvel.character.getEvents('37504')
  .then(response => {
    // do what you want with the response
    response => response.data.results.map(item => console.log(item.name))
  })

character.getSeries(id)

Fetched list creators by id references character. Test in Marvel Web Console.

Arguments

Argument Type Options
id string 'Any search id'

Example

marvel.character.getSeries('37504')
  .then(response => {
    // do what you want with the response
    response => response.data.results.map(item => console.log(item.name))
  })

character.getStories(id)

Fetched list stories by id references character. Test in Marvel Web Console.

Arguments

Argument Type Options
id string 'Any search id'

Example

marvel.character.getStories('37504')
  .then(response => {
    // do what you want with the response
    response => response.data.results.map(item => console.log(item.name))
  })

character.search(startname)

Fetched list characters by start name of search. Test in Marvel Web Console.

Arguments

Argument Type Options
startname string 'Any search letter'

Example

marvel.character.search('spider')
  .then(response => {
    // do what you want with the response
    response => response.data.results.map(item => console.log(item))
  })

CREATORS

creator.getCreators()

Fetches lists of creators. Test in Marvel Web Console.

--

Example

marvel.creator.getCreators()
  .then(reponse => {
    // do what you want with the response
    response => response.data.results.map(item => console.log(item))
  })

creator.getCreator(id)

Fetch one creator by id. Test in Marvel Web Console.

Arguments

Argument Type Options
id string 'Any search id'

Example

marvel.creator.getCreator('37504')
  .then(response => {
    // do what you want with the response
    response => response.data.results.map(item => console.log(item))
  })

creator.getComics(id)

Fetched list comics by id references creator. Test in Marvel Web Console.

Arguments

Argument Type Options
id string 'Any search id'

Example

marvel.creator.getComics('37504')
  .then(response => {
    // do what you want with the response
    response => response.data.results.map(item => console.log(item.name))
  })

creator.getEvents(id)

Fetched list events by id references creator. Test in Marvel Web Console.

Arguments

Argument Type Options
id string 'Any search id'

Example

marvel.creator.getEvents('37504')
  .then(response => {
    // do what you want with the response
    response => response.data.results.map(item => console.log(item.name))
  })

creator.getSeries(id)

Fetched list creators by id references creator. Test in Marvel Web Console.

Arguments

Argument Type Options
id string 'Any search id'

Example

marvel.creator.getSeries('37504')
  .then(response => {
    // do what you want with the response
    response => response.data.results.map(item => console.log(item.name))
  })

creator.getStories(id)

Fetched list stories by id references creator. Test in Marvel Web Console.

Arguments

Argument Type Options
id string 'Any search id'

Example

marvel.creator.getStories('37504')
  .then(response => {
    // do what you want with the response
    response => response.data.results.map(item => console.log(item.name))
  })

creator.search(startname)

Fetched list creators by start name of search. Test in Marvel Web Console.

Arguments

Argument Type Options
startname string 'Any search letter'

Example

marvel.creator.search('spider')
  .then(response => {
    // do what you want with the response
    response => response.data.results.map(item => console.log(item))
  })

EVENTS

event.getEvents()

Fetches lists of Events. Test in Marvel Web Console.

--

Example

marvel.event.getEvents()
  .then(reponse => {
    // do what you want with the response
    response => response.data.results.map(item => console.log(item))
  })

event.getEvent(id)

Fetch one event by id. Test in Marvel Web Console.

Arguments

Argument Type Options
id string 'Any search id'

Example

marvel.event.getEvent('37504')
  .then(response => {
    // do what you want with the response
    response => response.data.results.map(item => console.log(item))
  })

event.getCharacters(id)

Fetched list characters by id references event. Test in Marvel Web Console.

Arguments

Argument Type Options
id string 'Any search id'

Example

marvel.event.getCharacters('37504')
  .then(response => {
    // do what you want with the response
    response => response.data.results.map(item => console.log(item.name))
  })

event.getComics(id)

Fetched list comics by id references event. Test in Marvel Web Console.

Arguments

Argument Type Options
id string 'Any search id'

Example

marvel.event.getComics('37504')
  .then(response => {
    // do what you want with the response
    response => response.data.results.map(item => console.log(item.name))
  })

event.getCreators(id)

Fetched list creators by id references event. Test in Marvel Web Console.

Arguments

Argument Type Options
id string 'Any search id'

Example

marvel.event.getCreators('37504')
  .then(response => {
    // do what you want with the response
    response => response.data.results.map(item => console.log(item.name))
  })

event.getSeries(id)

Fetched list events by id references event. Test in Marvel Web Console.

Arguments

Argument Type Options
id string 'Any search id'

Example

marvel.event.getSeries('37504')
  .then(response => {
    // do what you want with the response
    response => response.data.results.map(item => console.log(item.name))
  })

event.getStories(id)

Fetched list stories by id references event. Test in Marvel Web Console.

Arguments

Argument Type Options
id string 'Any search id'

Example

marvel.event.getStories('37504')
  .then(response => {
    // do what you want with the response
    response => response.data.results.map(item => console.log(item.name))
  })

event.search(startname)

Fetched list events by start name of search. Test in Marvel Web Console.

Arguments

Argument Type Options
startname string 'Any search letter'

Example

marvel.event.search('spider')
  .then(response => {
    // do what you want with the response
    response => response.data.results.map(item => console.log(item))
  })

SERIES

serie.getSeries()

Fetches lists of series. Test in Marvel Web Console.

--

Example

marvel.serie.getSeries()
  .then(reponse => {
    // do what you want with the response
    response => response.data.results.map(item => console.log(item))
  })

serie.getSerie(id)

Fetch one serie by id. Test in Marvel Web Console.

Arguments

Argument Type Options
id string 'Any search id'

Example

marvel.serie.getSerie('37504')
  .then(response => {
    // do what you want with the response
    response => response.data.results.map(item => console.log(item))
  })

serie.getCharacters(id)

Fetched list characters by id references serie. Test in Marvel Web Console.

Arguments

Argument Type Options
id string 'Any search id'

Example

marvel.serie.getCharacters('37504')
  .then(response => {
    // do what you want with the response
    response => response.data.results.map(item => console.log(item.name))
  })

serie.getComics(id)

Fetched list comics by id references serie. Test in Marvel Web Console.

Arguments

Argument Type Options
id string 'Any search id'

Example

marvel.serie.getComics('37504')
  .then(response => {
    // do what you want with the response
    response => response.data.results.map(item => console.log(item.name))
  })

serie.getCreators(id)

Fetched list creators by id references serie. Test in Marvel Web Console.

Arguments

Argument Type Options
id string 'Any search id'

Example

marvel.serie.getCreators('37504')
  .then(response => {
    // do what you want with the response
    response => response.data.results.map(item => console.log(item.name))
  })

serie.getEvents(id)

Fetched list events by id references serie. Test in Marvel Web Console.

Arguments

Argument Type Options
id string 'Any search id'

Example

marvel.serie.getEvents('37504')
  .then(response => {
    // do what you want with the response
    response => response.data.results.map(item => console.log(item.name))
  })

serie.getStories(id)

Fetched list stories by id references serie. Test in Marvel Web Console.

Arguments

Argument Type Options
id string 'Any search id'

Example

marvel.serie.getStories('37504')
  .then(response => {
    // do what you want with the response
    response => response.data.results.map(item => console.log(item.name))
  })

serie.search(startname)

Fetched list series by start name of search. Test in Marvel Web Console.

Arguments

Argument Type Options
startname string 'Any search letter'

Example

marvel.serie.search('spider')
  .then(response => {
    // do what you want with the response
    response => response.data.results.map(item => console.log(item))
  })

STORIES

storie.getStories()

Fetches lists of stories. Test in Marvel Web Console.

--

Example

marvel.storie.getStories()
  .then(reponse => {
    // do what you want with the response
    response => response.data.results.map(item => console.log(item))
  })

storie.getStorie(id)

Fetch one storie by id. Test in Marvel Web Console.

Arguments

Argument Type Options
id string 'Any search id'

Example

marvel.storie.getStorie('37504')
  .then(response => {
    // do what you want with the response
    response => response.data.results.map(item => console.log(item))
  })

storie.getCharacters(id)

Fetched list characters by id references storie. Test in Marvel Web Console.

Arguments

Argument Type Options
id string 'Any search id'

Example

marvel.storie.getCharacters('37504')
  .then(response => {
    // do what you want with the response
    response => response.data.results.map(item => console.log(item.name))
  })

storie.getComics(id)

Fetched list comics by id references storie. Test in Marvel Web Console.

Arguments

Argument Type Options
id string 'Any search id'

Example

marvel.storie.getComics('37504')
  .then(response => {
    // do what you want with the response
    response => response.data.results.map(item => console.log(item.name))
  })

storie.getCreators(id)

Fetched list creators by id references storie. Test in Marvel Web Console.

Arguments

Argument Type Options
id string 'Any search id'

Example

marvel.storie.getCreators('37504')
  .then(response => {
    // do what you want with the response
    response => response.data.results.map(item => console.log(item.name))
  })

storie.getEvents(id)

Fetched list events by id references storie. Test in Marvel Web Console.

Arguments

Argument Type Options
id string 'Any search id'

Example

marvel.storie.getEvents('37504')
  .then(response => {
    // do what you want with the response
    response => response.data.results.map(item => console.log(item.name))
  })

storie.getSeries(id)

Fetched list series by id references storie. Test in Marvel Web Console.

Arguments

Argument Type Options
id string 'Any search id'

Example

marvel.storie.getStories('37504')
  .then(response => {
    // do what you want with the response
    response => response.data.results.map(item => console.log(item.name))
  })

storie.search(startname)

Fetched list stories by start name of search. Test in Marvel Web Console.

Arguments

Argument Type Options
startname string 'Any search letter'

Example

marvel.storie.search('spider')
  .then(response => {
    // do what you want with the response
    response => response.data.results.map(item => console.log(item))
  })

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

Jhones Gonçalves
Jhones Gonçalves

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published