(Quick Reference)

10 Objectives - Reference Documentation

Version: 2.1

10 Objectives

10.1 List

Service: List objectives

Description: This web service return the list of objectives in JSON format.

URL:

https://BASE_URL/api/VERSION/objectives

Method: GET

Parameters:

Pagination parameters:

NameDescriptionTypeRequiredPossible values
offsetTells where to start returning records from the entire set of results.IntegerNo 
maxLimits the number of resources requested to return.IntegerNo 
sortOrders the results by the specified field.StringNo 
orderOrders ascending or descendingIntegerNoasc, desc

Filters parameters:

NameDescriptionTypeRequiredExample values
dateCreated_gtFilters by the resource's creation date time and operator greater thanDateno2016-08-15T14:52:48Z
dateCreated_gteFilters by the resource's creation date time and operator greater than or equalDateno 
dateCreated_ltFilters by the resource's creation date time and operator less thanDateno 
dateCreated_lteFilters by the resource's creation date time and operator less than or equalDateno 
lastUpdated_gtFilters by the resource's last-modified date time and operator greater thanDateno 
lastUpdated_gteFilters by the resource's last-modified date time and operator greater than or equalDateno 
lastUpdated_ltFilters by the resource's last-modified date time and operator less thanDateno 
lastUpdated_lteFilters by the resource's last-modified date time and operator less than or equalDateno 
typeFilters by the type of objectiveIntegerno2,3,4
Dates should be formatted as the ISO-8601 format (YYYY-MM-DDTHH:MM:SSZ)

Success Output

Success case: response.status=200

{
  "paging": {
    "total": 4,
    "max": 5,
    "offset": 0,
    "previous": null,
    "next": null
  },
  "data": [
    {
      "id": 2,
      "employeeReference": "emp-04",
      "employee": {
        "id": 4,
        "reference": "emp-04",
        "href": "/api/v1.0/users/4"
      },
      "itemReference": "bracelet-GRP09062",
      "item": {
        "id": 497,
        "reference": "bracelet-GRP09062",
        "name": "Knot Band Bracelet",
        "href": "/api/v1.0/items/497"
      },
      "year": 2016,
      "type": "4",
      "januaryValue": 40,
      "februaryValue": 40,
      "marchValue": 40,
      "aprilValue": 45,
      "mayValue": 45,
      "juneValue": 45,
      "julyValue": 50,
      "augustValue": 50,
      "septemberValue": 50,
      "octoberValue": 50,
      "novemberValue": 50,
      "decemberValue": 55,
      "organization": "entity1",
      "dateCreated": "2016-02-01T13:39:01Z",
      "lastUpdated": "2016-02-01T13:39:01Z"
    },…
  ]
}

Failure Output

Failure case:response.status = 400
{
   "error": "invalid_param",
   "error_description": "The parameters [dateCreated_gta] you provided are not valid for this request."
}

Failure case:response.status = 500
{
   "error": "server_error",
   "error_description": "Oops! Something went wrong..."
}

10.2 Show

Service: Show an objective

Description: Returns the requested objective in json format when successful. Returns a json response, describing the failure condition when unsuccessful.

URL:

https://BASE_URL/api/VERSION/objectives/{id}

Method: GET

Parameters:

NameDescriptionTypeRequiredExample values
idThe numerical ID of the desired objectiveLongYes777

Success Output

Success case: response.status=200
{
  "id": 2,
  "employeeReference": "emp-04",
  "employee": {
    "id": 4,
    "reference": "emp-04",
    "href": "/api/v1.0/users/4"
  },
  "itemReference": "bracelet-GRP09062",
  "item": {
    "id": 497,
    "reference": "bracelet-GRP09062",
    "name": "Knot Band Bracelet",
    "href": "/api/v1.0/items/497"
  },
  "year": 2016,
  "type": "4",
  "januaryValue": 40,
  "februaryValue": 40,
  "marchValue": 40,
  "aprilValue": 45,
  "mayValue": 45,
  "juneValue": 45,
  "julyValue": 50,
  "augustValue": 50,
  "septemberValue": 50,
  "octoberValue": 50,
  "novemberValue": 50,
  "decemberValue": 55,
  "organization": "entity1",
  "dateCreated": "2016-02-01T13:39:01Z",
  "lastUpdated": "2016-02-01T13:39:01Z"
}

Failure Output

Failure case:response.status = 404
{
  "error": "not_found",
  "error_description": "The objective with the id 1000 doesn't exist."
}

Failure case:response.status = 400
{
    "error": "invalid_param_type",
    "error_description": "The type of parameter id you provided is not valid for this request."
}

10.3 Create

Service: Create an objective

Description: Returns the created objective in json format when successful. Returns a json response, describing the failure condition when unsuccessful.

URL:

https://BASE_URL/api/VERSION/objectives

Method: POST

Request content type: application/json

Parameters:

NameDescriptionTypeRequiredExample values
typeType can have only these values 2 if appointments number, 3 if turnover, 4 if item quantityIntegeryes2,3,4
yearA year from 2000 to 2099Integeryes2016
itemIdThe ID of item. Required if objective type is equal to 4(item quantity)Long/String- 
userIdThe ID of userLong/Stringyes 
januaryValue Integer/Doubleno 
februaryValue Integer/Doubleno 
marchValue Integer/Doubleno 
aprilValue Integer/Doubleno 
mayValue Integer/Doubleno 
juneValue Integer/Doubleno 
julyValue Integer/Doubleno 
augustValue Integer/Doubleno 
septemberValue Integer/Doubleno 
octoberValue Integer/Doubleno 
novemberValue Integer/Doubleno 
decemberValue Integer/Doubleno 
useExternalIdBy default, it is set to false. set it to true if you want to use external ids.Booleannotrue , false

If objective type is equal to 4 (item quantity ) or 2 ( appointments number) month value should be an integer
If objective type is equal to 3 (turnover ) month value should be a double

Success Output

Success case: response.status=201
An item must not be goody or asset

{
  "id": 15,
  "employeeReference": "emp-04",
  "employee": {
    "id": 4,
    "reference": "emp-04",
    "href": "/api/v1.0/users/4"
  },
  "itemReference": null,
  "item": null,
  "year": 2017,
  "type": "3",
  "januaryValue": 550.9,
  "februaryValue": 500,
  "marchValue": 100,
  "aprilValue": 110,
  "mayValue": 110,
  "juneValue": 100,
  "julyValue": 700,
  "augustValue": 800,
  "septemberValue": 1000,
  "octoberValue": 600,
  "novemberValue": 300,
  "decemberValue": 300,
  "organization": "entity1",
  "dateCreated": "2016-08-25T13:31:14Z",
  "lastUpdated": "2016-08-25T13:31:14Z"
}

Failure Output

Failure case:response.status = 400
{
  "error": "already_existing",
  "error_description": "Objective is already existing."
}
{
  "error": "invalid_param_type",
  "error_description": "An invalid value was specified for parameter: year (must be a year from 2000 to 2099)"
}
{
  "error": "invalid_param_type",
  "error_description": "An invalid value was specified for parameter: year (must be a year greater than or equal to 2017)"
}
{
  "error": "missing_param",
  "error_description": "userId parameter is missing"
}
{
  "error": "missing_param",
  "error_description": "itemId parameter is missing"
}
{
  "error": "invalid_param",
  "error_description": "Item must not be goody or asset"
}
{
  "error": "invalid_param_type",
  "error_description": "An invalid value was specified for parameter: januaryValue (must be positive)"
}

Failure case:response.status = 404
{
  "error": "not_found",
  "error_description": "The item with the id 4564 doesn't exist."
}
{
  "error": "not_found",
  "error_description": "The user with the id 4000 doesn't exist."
}

Failure case:response.status = 500
{
    "error": "server_error",
    "error_description": "Oops! Something went wrong..."
}

10.4 Update

Service: Update an objective

Description: Returns the updated objective in json format when successful. Returns a json response, describing the failure condition when unsuccessful.

URL:

https://BASE_URL/api/VERSION/objectives/{id}

Method: PUT

Request content type: application/json

Parameters:

NameDescriptionTypeRequiredExample values
idThe numerical ID of the desired objectiveLongyes123
typeType can have only these values 2 if appointments number, 3 if turnover, 4 if item quantityIntegeryes2,3,4
yearA year from 2000 to 2099Integeryes2016
itemIdThe ID of item. Required if objective type is equal to 4(item quantity)Long/String- 
userIdThe ID of userLong/Stringyes 
januaryValue Integer/Doubleno 
februaryValue Integer/Doubleno 
marchValue Integer/Doubleno 
aprilValue Integer/Doubleno 
mayValue Integer/Doubleno 
juneValue Integer/Doubleno 
julyValue Integer/Doubleno 
augustValue Integer/Doubleno 
septemberValue Integer/Doubleno 
octoberValue Integer/Doubleno 
novemberValue Integer/Doubleno 
decemberValue Integer/Doubleno 
useExternalIdBy default, it is set to false. set it to true if you want to use external ids.Booleannotrue , false

Every item must have only one default unit

Success Output

Success case: response.status=200

{
  "id": 15,
  "employeeReference": "emp-04",
  "employee": {
    "id": 4,
    "reference": "emp-04",
    "href": "/api/v1.0/users/4"
  },
  "itemReference": null,
  "item": null,
  "year": 2017,
  "type": "3",
  "januaryValue": 550.9,
  "februaryValue": 500,
  "marchValue": 100,
  "aprilValue": 110,
  "mayValue": 110,
  "juneValue": 100,
  "julyValue": 700,
  "augustValue": 800,
  "septemberValue": 1000,
  "octoberValue": 600,
  "novemberValue": 300,
  "decemberValue": 0,
  "organization": "entity1",
  "dateCreated": "2016-08-25T13:31:14Z",
  "lastUpdated": "2016-08-25T13:47:20Z"
}

Failure Output

Failure case:response.status = 400
{
  "error": "already_existing",
  "error_description": "Objective is already existing."
}
{
  "error": "invalid_param_type",
  "error_description": "An invalid value was specified for parameter: year (must be a year from 2000 to 2099)"
}
{
  "error": "missing_param",
  "error_description": "userId parameter is missing"
}
{
  "error": "missing_param",
  "error_description": "itemId parameter is missing"
}
{
  "error": "invalid_param_type",
  "error_description": "An invalid value was specified for parameter: februaryValue (must be positive)"
}

Failure case:response.status = 404
{
  "error": "not_found",
  "error_description": "The objective with the id 96 doesn't exist."
}

Failure case:response.status = 500
{
    "error": "server_error",
    "error_description": "Oops! Something went wrong..."
}

10.5 Delete

Service: Delete an objective

Description: Returns a json response.

URL:

https://BASE_URL/api/VERSION/objectives/{id}

Method: DELETE

Parameters:

NameDescriptionTypeRequiredExample values
idThe numerical ID of the desired objectiveLongyes123

Success Output

Success case: response.status=200

{
  "success": "true",
  "success_description": "Instance deleted successfully"
}

Failure Output

Failure case:response.status = 400

{
  "error": "delete_failed",
  "error_description": "Failed to delete instance."
}

Failure case:response.status = 404

{
  "error": "not_found",
  "error_description": "The objective with the id 70 doesn't exist."
}