Skip to content

Instantly share code, notes, and snippets.

@niyigb
Last active December 9, 2022 13:51
Show Gist options
  • Save niyigb/b8d372692a442bd10c2f to your computer and use it in GitHub Desktop.
Save niyigb/b8d372692a442bd10c2f to your computer and use it in GitHub Desktop.
Assessment Task - Software Engineering Associate

Assessment Task - Software Engineering Associate

Task

  1. Implement a RESTful JSON HTTP API gateway that allows programmatic CRUD operations on user records.
  2. All requests should be authenticated using HTTP Basic Authentication i.e. RFC2617
  3. Host the API gateway on a publicly accessible server.

Note: If you need a server to host your application and would like us to provide one for you, kindly contact our R&D Team on rd@pmglobaltechnology.com

Specification

API Endpoint: “http://{HOSTNAME}:{PORT}/users” e.g. http://test.com/users

Authentication

  • Username: test
  • Password: pass1234

1. Create a User

Request

Endpoint : "/users" e.g. http://test.com/users

Method: POST

Data:

{
	"firstname": "chibunna",
	"lastname": "oduonye",
	"gender": "M",
	"date_of_birth": "2015-04-08"
}

Response

Code: 200

Data:

{
	"id": "1",
	"firstname": "chibunna",
	"lastname": "oduonye",
	"gender": "M",
	"date_of_birth": "2015-04-08",
	"date_created": "2014-07-17T03:03:34",
	"date_updated": "2014-07-17T03:03:34"
}

2. Select All Users

Request

Endpoint : "/users" e.g. http://test.com/users?filter_field=firstname&filter_value=chibunna

Method: GET

Parameters (Optional):

  1. sort_field - this can be any field in the JSON e.g. "firstname",
  2. sort_order_mode - this can be either "asc" or "desc"
  3. filter_field - this can be any field in the JSON e.g. "firstname",
  4. filter_value - the criteria upon which the response data will be filtered
  5. page : The current page. Default is 1
  6. page_size: The number of records per page. Default is 25

Response

Code: 200

Data:

[
		{
		"id": "1",
			"firstname": "chibunna",
			"lastname": "oduonye",
			"gender": "M",
			"date_of_birth": "1990-04-08",
			"date_created": "2014-07-17T03:03:34",
			"date_updated": "2014-07-17T03:03:34"
		},
		{
		"id": "2",
			"firstname": "Godwin",
			"lastname": "Orubebe",
			"gender": "M",
			"date_of_birth": "1965-04-08",
			"date_created": "2014-07-17T04:12:25",
			"date_updated": "2014-07-17T04:12:25"
		}

]

3. Select User By ID

Request

Endpoint : "/users/{id}" e.g. http://test.com/users/1

Method: GET

Response:

Code: 200

Data:

  {
	"id": "1",
       	"firstname": "chibunna",
	"lastname": "oduonye",
	"gender": "M",
	"date_of_birth": "2015-04-08",
	"date_created": "2014-07-17T03:03:34",
"date_updated": "2014-07-17T03:03:34"
}

4. Edit User

Request

Method: PUT

Endpoint: "users/{id}" e.g. http://test.com/users/1

Payload:

{
	"id": "2"
	"firstname": "Godwin",
	"lastname": "Jega",
	"gender": "M",
	"date_of_birth": "2015-04-08"
}

Response

Code: 200

Data:

{
	"id": "2"
	"firstname": "Godwin",
	"lastname": "Jega",
	"gender": "M",
	"date_of_birth": "2015-04-08",
	"date_created": "2014-07-17T04:12:25",
	"date_updated": "2014-07-17T18:44:19"
}

5. Delete User

Request

Method: DELETE

Endpoint: "users/{id}" e.g http://test.com/1

Response

Code: 200

Data:

Completion

Assessment Criteria

MilestoneMarks
1Ability to create new users15
2Ability to update users15
3Ability to delete users15
4Ability to fetch a single user15
5Ability to search for users by at least one criteria10
6Ability to sort users by at least one criteria10
7Authenticates the test user’s credentials10
8Handle error conditions with the correct HTTP status codes e.g. 404, 403, 401, 400 etc10
TOTAL100

How to submit your work

Send an email to rd@pmglobaltechnology.com that contains

  1. The URL to your work
  2. Include any special instructions on how to test it

The closing date for all submissions is April 30, 2015

Updated closing date July 30, 2019

@christianezeani
Copy link

After going through the Pre-Assessment Task, I need some clarifications with the following:

Response code/Data: The response code does not state the status of the request. When there is an error with the request, I guess there should be an error code and an error message, for example:

Error
{
    "error": 1,
    "message": "Invalid parameters supplied!"
}

Successful
{
    "error": 0,
    "message": "Request Successful!"
}

Successful with Data
{
    "error": 0,
    "message": "Request Successful!",
    "data": {
        "firstname": "Chibunna",
        "lastname": "Oduonye",
        "gender": "M",
        "date_of_birth": "2015-04-08"
    }
}

The question is should I include error code and message with the response or I should stick to the format earlier prescribed. Adding error code and message would also be of great help with the integration of the api.

@niyigb
Copy link
Author

niyigb commented Apr 12, 2015

@christianezeani

The response codes should be HTTP response codes because they are sufficient to explain the state of the request. The data that represents the entity should represent only the entity and not any application process logic such as success codes.

For example, if a request is processed successfully, the HTTP spec recommends that you return a 200 error code.

Alternatively, if a request cannot be processed because the resource does not exist, you should return a 404. If the data submitted is badly formatted or wrong, it should return a 400 error.

For more info on the common error codes, see http://micheltriana.com/2013/09/27/http-status-codes-in-rest-web-api/

@tantita
Copy link

tantita commented Apr 15, 2015

@TechScorpion
Submitted to your email

@frankie-ug
Copy link

Is this still open?

@juliettegodyere
Copy link

Hello, this job application deadline on jobberman is May 16, 2016. But here in your website it is April 30, 2015. My question is that:"Should i still go on with the task?"

@joelezeu
Copy link

joelezeu commented Sep 7, 2016

I sent a mail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment