Giter Site home page Giter Site logo

bilemo's Introduction

Bilemo API

Version 1.0.0

This project is a REST API for Bilemo to allow partners to display their mobile phones catalog. This API was built with Symfony 3.4. It's the 7th OpenClassRooms PHP/Symfony Developer project. A working documentation demo can be found here.

Codacy Badge Maintainability Build Status


As you can see there are two folders:

API instructions

Below the instructions to use Bilemo REST API from your application.

Prerequisites

  • PHP >=7.0.10
  • MySQL
  • PHPUnit 6.5
  • Composer to install Symfony 3.4 and project dependencies

Dependencies

This project uses:

Those dependencies are included in composer.json.

Installation

  1. Clone this repository on your local machine by using this command line in your folder git clone https://github.com/bhalexx/bilemo.git.
  2. In project folder open a new terminal window and execute command line composer install.
  3. Rename bilemo/app/config/parameters.yml.dist in bilemo/app/config/parameters.dist and edit database parameters with yours.
  4. Edit root, root_uri and picture_path parameters in config_dev.yml with your project path.
  5. Execute command line php bin/console bilemo:fixtures:load. This command will create database and load some fixtures.
  6. Your project is now up to date!

Authentication to access API

This API is restricted to Bilemo partners. When a Bilemo admin adds your application as a new partner, your credentials are sent by email.

Become a Bilemo partner

For demo you can also run this command to create your application as a Bilemo partner:

php bin/console bilemo:partner:create {YourApplicationName} {YourPassword} {YourEmail} {YourRedirectURI}

This command will output:

username: {YourApplicationName}
password: {YourPassword}
client_id: {YourClientId}
client_secret: {YourClientSecret}

Now that you're a Bilemo partner, you need to get an access token to access API methods.

Set Content-Type: application/json in your request headers and do a POST request on /oauth/v2/token with those JSON parameters in request body:

{
  "grant_type": "password",
  "client_id": "{YourClientId}",
  "client_secret": "{YourClientSecret}",
  "username": "{YourApplicationName}",
  "password": "{YourPassword}"
}

You will get an access_token and a refresh_token and you can now access API endpoints by setting those parameters in each request headers:

Content-Type: application/json
Authorization: Bearer {YourAccessToken}

Your access token expires after 1 hour. To get a new access token use your refresh token in your POST request headers on /oauth/v2/token with those parameters:

{
  "grant_type": "refresh_token",
  "client_id": "{YourClientId}",
  "client_secret": "{YourClientSecret}",
  "refresh_token": "{YourRefreshToken}"
}

Now you'ready to enjoy! Refer to documentation to use API endpoints according to your needs.

Become a Bilemo admin

Still for demo you can also create your application as a Bilemo administrator by running the same command with the optional parameter admin:

php bin/console bilemo:partner:create {YourApplicationName} {YourPassword} {YourEmail} {YourRedirectURI} admin

Documentation

This API project is as documented as possible, so you can find:

  • a full documentation of API methods by adding /api/doc at the end of your API URI.
  • and some diagrams

Related projects

Two other projects were created to show how to use this API:

bilemo's People

Contributors

bhalexx avatar codacy-badger avatar

Watchers

Packo avatar  avatar

Forkers

cperrot11

bilemo's Issues

OS CRUD

Create API methods to manage OS:

  • list
  • add
  • edit
  • delete

Time needed: 1 hour

Missing tests

  • MobileController
  • UserController

Time needed: 1hour

Tests

Do some functional tests.


Time needed: 1 hour

Mobile CRUD

Create API methods to manage mobile phones:

  • list
  • add
  • edit
  • delete

Time needed: 2 hours

Manufacturer CRUD

Create API methods to manage manufacturers:

  • list
  • add
  • edit
  • delete

Time needed: 1 hour

Restrict API method access according to roles

API contains 3 different roles:

  • ROLE_BILEMO: BileMo administrators - allowed to manage applications (partners)
  • ROLE_APPLICATION: BileMo partners - only allowed to access to product catalog API methods if oAuth token is valid
  • ROLE_USER: clients registered on BileMo partners websites - not allowed to access any API method.

Time needed: 2 hours

Create UML diagrams

  • Classes diagram
  • Main functionalities sequence diagram

Time needed: 2 hours

Pagination

Paginate mobiles results


Time needed: 1 hour

User deletion

Create user deletion method.


Time needed: 30 minutes

Create serialization groups

Useless to load all entity properties on lists.
Exclude useless properties from Picture and Features entities.


Time needed: 30 minutes.

API documentation

Generate documentation for methods that are accessible by a BileMo partner.

NelmioApiDoc will be used, with Swagger to beautify documentation pages.


Time needed: 2 hours

Command CRUD

Create API methods to manage commands:

  • list
  • add
  • edit
  • delete

Time needed: 1 hour

Fixtures

Generate fixtures to load by a simple command line.


Time needed: 2 hours

Users CRUD

Create API methods to manage users:

  • list
  • add
  • edit
  • delete

FOSUserBundle will be used to manage users and their roles.


Time needed: 3 hours

Application CRUD

Create API methods to manage applications:

  • list
  • add
  • edit
  • delete

Time needed: 1 hour

OAuthentication

API methods to display and manage BileMo catalog are restricted to BileMo partners only.
Only BileMo partners are allowed to use BileMo products catalog API methods.

BileMo partners will have to give API a token got by oAuthentication.
Use of FOSOAuthServerBundle to manage OAuthentication.


Time needed: 4 hours

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.