Git Product home page Git Product logo

blackcompany-task's Introduction

< Black Company > - PHP Developer recruitment task

API Reference

POST /api/v1/users

Request

{
	"first_name": "Hans",
	"surname": "Kloss",
	"country_code": "DE",
	"identification_number": "12631904566"
}

Response

{
	"id": "9c5ad870-9e43-4c49-a974-77165529ccb9",
	"first_name": "Hans",
	"surname": "Kloss",
	"country_code": "DE",
	"identification_number": "12631904566"
}

Error

{
	"code": 422,
	"message": "Validation Failed",
	"errors": {
		"identification_number": "Identification number is invalid"
	}
}

GET /api/v1/users

Response

[
	{
		"id": "9c5ad870-9e43-4c49-a974-77165529ccb9",
		"first_name": "Hans",
		"surname": "Kloss",
		"country_code": "DE",
		"identification_number": "12631904566"
	},
	...
]

Original Task Description

Your task is very simple:

  1. Prepare new endpoint „/api/v1/users” in REST API, which creates the user in the database.
  2. Prepare display all users (provided by endpoint) as a list "/users"

Information about task

The user has following data:

  1. firstname
  2. surname
  3. country code (only PL or DE) in ISO 3166-1 alfa-2 standard - more info here: https://pl.wikipedia.org/wiki/ISO_3166-1_alfa-2
  4. identification number
    1. for PL will be a PESEL (11 digits) -> description of validation  https://pl.wikipedia.org/wiki/PESEL
    2. for DE will be a die Identifikationsnummer (11 digits) -> description of validation https://de.wikipedia.org/wiki/Steuerliche_Identifikationsnummer#Aufbau_der_Identifikationsnummer

Requirements

  1. All data (firstname, surname, country code, identification number) for user are required.
  2. We serve only users from Poland and Germany. If user comes from another country, we should receive an error from the response API.
  3. The endpoint „/api/v1/users” before writing new user to the database should check the identification number if it's correct, i.e. it has the correct check digit and control sum.
  4. If the identification number or country code is incorrect then response should return code 422 and contains an error messages. Example:
{
    "code": 422,
    "message": "Validation Failed";
    "errors": {
        „identificationNumber": "Invalid value for identificationNumber.",
        „country": "Invalid value for country."
    }
}
  1. If any field is empty in request then response should return code 422 and contains an error messages. Example:
{
    "code": 422,
    "message": "Validation Failed";
    "errors": {
        "firstName": "This value should not be blank.",
        "country": "This value should not be blank." 
    }
}
  1. If the creation of a user in the database succeeds, then response should return code 201 and the unique ID of the new user that will be assigned in the application. Example:
{
  "userId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" 
}

Rules

We would like to get a working code.

You're welcome to improve our code

If something is not specified or explained please do it according to your own idea! :)

You should send us a GitHub/BitBucket link to repository (remember to keep commits clean) or zip file with the whole project.

Good luck!

Installation

  1. Run make install
  2. Add following lines to /etc/hosts (For MacOS with docker-machine if using different system change IP):
192.168.99.100 backed-recruitment-task.local

Usage

  1. make start
  2. Website is accessible through backed-recruitment-task.local
  3. To down make down

blackcompany-task's People

Contributors

kazik871 avatar piotrmacha avatar

Watchers

 avatar  avatar

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.