No description, website, or topics provided.
Java HTML JavaScript
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
frontend
sql
src
.gitignore
Procfile
README.md
pom.xml

README.md

Status ##Overview
Simple RESTFul application with AngularJS client. Allows to store information about companies.

###Company Represents entity Company with attributes.

ATTRIBUTES

  • id - unique ID generated by the server for the company
  • name - full name of company
  • address - address of company, should include street name and building number
  • city - company's location city
  • country - company's location country
  • email - company's contact email
  • phoneNumber - company's contact phone number
  • beneficials - arrays of beneficials of current company, could be empty

###Beneficial Represents entity Beneficial with attributes.

ATTRIBUTES

  • id - unique ID generated by the server for the beneficial
  • companyId - unique ID of beneficial's company
  • name - full name of beneficial

#####Create a company Request to create new company: POST /companies

BODY ARGUMENTS

name required
address required
city required
country required
beneficials required
email optional
phoneNumber optional

Creating of beneficial will be performed automatically in case beneficials will be not empty. For a beneficial object, only one field are required name.

Request Example

$ curl http://app-domain.com/rest/companies \
-H "Content-Type: application/json;charset=UTF-8" \
-d '{
    "name": "company1",
    "address": "Nikolskaya str., 14",
    "city": "Moscow",
    "country": "Russia",
    "beneficials":[
        {
            "name": "Surname Name"
        }
    ],
    "email": "test@company1.com",
    "phoneNumber": "+7 495 111 11 11"
}'

Response Example

HTTP/1.1 200 Created
Content-Type:application/json;charset=UTF-8
{
    "id": 2453
    "name": "company1",
    "address": "Nikolskaya str., 14",
    "city": "Moscow",
    "country": "Russia",
    "beneficials":[
        {
            "companyId": 2453,
            "id": 
            "name": "Surname Name"
        }
    ],
    "email": "test@company1.com",
    "phoneNumber": "+7 495 111 11 11"
}

Returned error codes
400 - in case company could not be created due to missed obligatory fields.

Error response example

HTTP/1.1 400 Bad Request
Content-Type:application/json;charset=UTF-8
{
    "error":"Field 'Address' in company can not be empty"
}

#####Retrieve a company Request to get details of an existing company: GET /companies/{company_id}

URL ARGUMENTS
company_id required

Request Example

$ curl http://app-domain.com/rest/companies/15 \
-H "Content-Type: application/json;charset=UTF-8" \

Response Example

HTTP/1.1 200 Created
Content-Type:application/json;charset=UTF-8
{
    "id": "15", 
    "name": "company1",
    "address": "Nikolskaya str., 14",
    "city": "Moscow",
    "country": "Russia",
    "beneficials":[
        {
            "name": "Surname Name"
        }
    ],
    "email": "test@company1.com",
    "phoneNumber": "+7 495 111 11 11"
}

Returned error codes
404 - in case company could not be found.

Error response example

HTTP/1.1 404 Not Found
Content-Type: text/plain
{
     "error":"No company with id: 6591"
}

#####Retrieve all companies Request to get details of all existing companies: GET /companies

Request Example

$ curl http://app-domain.com/rest/companies \
-H "Content-Type: application/json;charset=UTF-8" \

Response Example

HTTP/1.1 200 OK
Content-Type:application/json;charset=UTF-8
[
	{
		"address":"Nikolskaya str., 14",
		"beneficials":[
			{
				"companyId":6481,
				"id":1541,
				"name":"Surname Name"
			}
		],
		"city":"Moscow",
		"country":"Russia",
		"email":"some@company1.com",
		"id":6481,
		"name":"company1",
		"phoneNumber":"+7 495 111 11 11"
	},
	{
		"address":"Lenina str., 1",
		"beneficials":[
			{
				"companyId":6491,
				"id":1551,
				"name":"SomeOther Name"
			}
		],
		"city":"Moscow",
		"country":"Russia",
		"email":"some@company2.com",
		"id":6491,
		"name":"company2",
		"phoneNumber":"+7 495 222 22 22"
	}
]

#####Update a company Request to update details of an existing company: PUT /companies/{company_id}

URL ARGUMENTS
company_id required

BODY ARGUMENTS

name required
address required
city required
country required
beneficials required
email optional
phoneNumber optional

Request Example

$ curl http://app-domain.com/rest/companies/15 \
-H "Content-Type: application/json;charset=UTF-8" \
-X PUT \
-d '{
		"address":"Nikolskaya str., 14",
		"beneficials":[
			{
				"companyId":6481,
				"id":1541,
				"name":"Surname Name"
			}
		],
		"city":"Moscow",
		"country":"Russia",
		"email":"some@company1.com",
		"id":6481,
		"name":"New Company Name",
		"phoneNumber":"+7 495 111 11 11"
	}'

Response Example

HTTP/1.1 200 OK
Content-Type:application/json;charset=UTF-8
{
	"address":"Nikolskaya str., 14",
	"beneficials":[
		{
			"companyId":6481,
			"id":1541,
			"name":"Surname Name"
		}
	],
	"city":"Moscow",
	"country":"Russia",
	"email":"some@company1.com",
	"id":6481,
	"name":"New Company Name",
	"phoneNumber":"+7 495 111 11 11"
}

Returned error codes
404 - in case company could not be found 400 - in case some fields are not filled

Error response example

HTTP/1.1 404 Not Found
Content-Type: text/plain
{
     "error":"No company with id: 6481"
}

#####Add a beneficial Request to create new company: POST /companies/{company_id}/beneficials

URL ARGUMENTS
company_id required

BODY ARGUMENTS

name required

Request Example

$ curl http://app-domain.com/rest/companies/6481/beneficials \
-H "Content-Type: application/json;charset=UTF-8" \
-d '{
        "name":"Jack Sparrow"
    }'

Response Example

HTTP/1.1 200 OK
Content-Type:text/plain;charset=UTF-8

Returned error codes
404 - in case company could not be found
400 - in case some fields are not filled

Error response example

HTTP/1.1 404 Not Found
Content-Type: text/plain
{
     "error":"No company with id: 6481"
}