Nested Objects


Two examples of nested objets in the above example are the working_pattern and the holiday_allowance. In the breatheHR API, where an objects attribute is also another attribute available within the system, it appears as a nested object in API responses. In the listing 1 above, the working_pattern attribute is an object with a small set of its own attributes, including an id.

Where an objects attribute is also another attribute available within the system, it appears as a nested object in API responses. In the following example, the working_pattern attribute is an object with a small set of its own attributes, including an id.

{
  "employees": [
    {
      "length_of_service_in_months": 3,
      "age": null,
      "full_or_part_time": null,
      "notice_period": null,
      "working_pattern":{
        "id": 1,
        "name": "Default working week M-F 8hrs",
        "total_hours": "40.0",
        "default": true
      }
    }
  ]
}

We can make another request to the working patterns resource, which will give us the full details of all working patterns, including this one:

$ curl https://api.breathehr.com/v1/working_patterns \
-H 'X-API-KEY: prod-1OcTwKW8ln5ARz04IjsrJEQTZgP3Ir1sWfyuOLdqC1Y'
{
  "working_patterns": [
    {
      "default": true,
      "id": 1,
      "name": "Default working week M-F 8hrs",
      "total_hours": "40.0",
      "mon": true,
      "tue": true,
      "wed": true,
      "thu": true,
      "fri": true,
      "sat": false,
      "sun": false,
      "mon_hr": "8.0",
      "tue_hr": "8.0",
      "wed_hr": "8.0",
      "thu_hr": "8.0",
      "fri_hr": "8.0",
      "sat_hr": "0.0",
      "sun_hr": "0.0",
      "created_at": "2012-09-11T13:38:26Z",
      "updated_at": "2013-12-09T16:19:20Z"
    },
  ]
}