Coder Social home page Coder Social logo

employee-rest-api's Introduction

employee-rest-api

In order to run the program, you can either, run the jar file that is in the root of the project like this:

java -jar employee-rest-api-0.0.1-SNAPSHOT.jar

Or also you can execute the maven command: mvn clean install.

This will generate a docker image in you machine, so then you can run a container like this: docker run -p 8080:8080 employee-rest-api

Also if you want you can open the project in one IDE and run it from there.

In order to test the api, you have to do requests through localhost in port 8080 adding the specific url.

http://localhost:8080/

Is preferred to test the api with a tool like postman.

By default, the project already adds some employees to testing, so from the begginig you can perform request like get all employees.

I added some extras functionalities that I will mark with *ADDED note.

Get all employees

GET Method

URI : "/public/employees" example: http://localhost:8080/public/employees answer: list of json objects that represent employees stored in the DB

Get employees by an ID

GET Method

URI: "/public/employee/{id}" example: http://localhost:8080/public/employee/9999

Get employee id searching by full name (firstName, middleInitial and lastName)

POST Method

*ADDED by me

URI: /public/getEmployeeId example: http://localhost:8080/public/getEmployeeId body request example : { "firstName": "Victoria", "middleInitial": "Sandra", "lastName": "Arias" } answer: long number representing id of employee with that name

Create/Save new employee

Needs Json representation of employee object

POST Method

URI: /public/saveEmployee" example: http://localhost:8080/public/saveEmployee body request example : { "firstName": "Antonio", "middleInitial": "Carlos", "lastName": "Lopez", "dateOfBirth": "27/01/2020", "dateOfEmployment": "27/01/2020", "status": "Active" } answer: status code 201 Created

Update employee by id

Post Method

Basic Authentication needed user:admin password:password Needs Json reprentation that MUST have the employee id and all the other fields you want to update It will only update the fields that you put in the json body

URI: /private/updateEmployeeById example: http://localhost:8080/private/updateEmployeeById body request example: { "id": 9995, "firstName": "Valentina", "middleInitial": "Luciana", "lastName": "Flores" } Another example: { "id": 9995, "firstName": "Jane", }

Delete employee by id

DELETE Method

Basic Authentication needed user:admin password:password

URI: /private/deleteEmployee/{id} example: http://localhost:8080/private/deleteEmployee/9995 answer: status code 200 OK

employee-rest-api's People

Contributors

axelrobles avatar

Watchers

James Cloos 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.