Skip to content

Latest commit

 

History

History
99 lines (71 loc) · 3 KB

README.rdoc

File metadata and controls

99 lines (71 loc) · 3 KB

MARVEL API PROJECT

Before to run this project, please, follow the next steps.

Ruby and Rails versions

  • Ruby 2.3.1

  • Rails 4.2.3

  • SQLite (development)

  • Postgres (production)

Install rbenv or rvm to install the right ruby and rails versions

If you are using Rbenv, please run:

$ rbenv init

$ rbenv local 2.3.1

Before run rails server make sure that create your database.yml file and run:

$ bundle install

$ rake db:create

$ rake db:migrate

$ rake db:seed

To consume local API, follow the examples below:

To get all characters, just make a GET request to follow path:

GET http://localhost:3000/api/v1/characters/

And you will receive a JSON as follow:

{
"characters": [
    {
      "marvel_id": 1011334,
      "name": "3-D Man",
      "description": "",
      "image": "http://i.annihil.us/u/prod/marvel/i/mg/c/e0/535fecbbb9784",
      "modified_at": "2014-04-29T00:00:00.000Z"
    },
    {
      "marvel_id": 1017100,
      "name": "A-Bomb (HAS)",
      "description": "Rick Jones has been Hulk's best bud since day one, but now he's more than a friend...he's a teammate! Transformed by a Gamma energy explosion, A-Bomb's thick, armored skin is just as strong and powerful as it is blue. And when he curls into action, he uses it like a giant bowling ball of destruction! ",
      "image": "http://i.annihil.us/u/prod/marvel/i/mg/3/20/5232158de5b16",
      "modified_at": "2013-09-18T00:00:00.000Z"
    }
  ]
}

Or, if you want, you can use Postman and rock’on! o/

To get a singular character, you can run the follow command on Postman:

GET http://localhost:3000/api/v1/characters/:marvel_id

Where “marvel_id” is the key to access character by this API, and you will receive a JSON response with the character data and his comics (if exists).

{
  "marvel_id": 1009144,
  "name": "A.I.M.",
  "description": "AIM is a terrorist organization bent on destroying the world.",
  "modified_at": "2013-10-17T00:00:00.000Z",
  "image": "http://i.annihil.us/u/prod/marvel/i/mg/6/20/52602f21f29ec",
  "comics": [
    {
      "title": "Secret Avengers (2013) #16",
      "cover_number": 16,
      "image": "http://i.annihil.us/u/prod/marvel/i/mg/a/a0/579b65f99cde3"
    },
    {
      "title": "Secret Avengers (2013) #15",
      "cover_number": 15,
      "image": "http://i.annihil.us/u/prod/marvel/i/mg/f/70/52fa84fddcc44"
    },
    {
      "title": "Secret Avengers (2013) #14",
      "cover_number": 14,
      "image": "http://i.annihil.us/u/prod/marvel/i/mg/f/40/52cee157a8bfa"
    }
  ]
}

To create a new character you will need at least a marvel_id parameter, but we can do better ( ;) ) and add “name”, “description” and, as we said early, “marvel_id” parameters!

POST http://localhost:3000/api/v1/characters/new?name=Russel Crow&description=I'm Gladiator!&marvel_id=123212111

To update, its similar, you can do:

PUT http://localhost:3000/api/v1/characters/:marvel_id/edit?name=Sheila //for example

So, is it! Enjoy!