Skip to content

Fichen/api-starwars

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Swapi

Extending data model with proxies

SWAPI provides information about the Star Wars universe. Extend this API to manage the inventory of starships and vehicles.

Scope

  • consume the information from SWAPI: https://swapi.dev/documentation for starships and vehicles
  • extend the data model and implement functionality to keep track of the amount of units for starships and vehicles. This can be achieved by adding the count property.
  • allow to get the total number of units for a specific starship or vehicle Example: get how many Death Stars are in the inventory of starships
  • allow to set the total number of units for a specific starship or vehicle Example: set the number Death Stars in the inventory of starships
  • allow to increment the the total number of units for a specific starship or vehicle Example: increment by x units the number Death Stars in the inventory for starships
  • allow to decrement the the total number of units for a specific starship or vehicle Example: decrement by x units the number Death Stars in the inventory for starships Dillinger is a cloud-enabled, mobile-ready, offline-storage compatible, AngularJS-powered HTML5 Markdown editor.

Approach

It was decided to implement a extended data model between the real API and the new one. The main reason for this decision was that this application does not own the vast majority of the data, so knowing that the developement of theses APIs could finishing in complex solution for updating the local data model. What I assumed here was that data could change (I know the probabbly not 😛, but it was a good exercise think about that). I have intended to reproduce the behaviour of the official API. The amount of units for a specific items are showed as a attached attribute of its with the name "qty".

The endpoints for starships and vehicles are mostly the same, the main visible change are the attributes from the model.

It was developed with Laravel 8

Server requirements

  • Docker
  • Docker-compose

Install

  • Clone the repository from here
  • Run
docker-compose up -d --build
docker exec -ti api-starwars_api_1 bash
composer dump-autoload
php artisan migrate
php artisan migrate:refresh --env=testing --database=sqlite
exit

Note The base url to access the app is http://127.56.0.1:8080.

The Docker image has all the base code as well. If you wish you can look for it on this link

How to run it?

As I comment before, for vehicles is the same behaviour.You only need to change the url path to http://127.56.0.1:8080/api/vehicles

There are some automated test cases for starship endpoints. If you wish you can run it doing:

docker exec -t api-starwars_api_1 vendor/bin/phpunit

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages