Targets

Get all targets

Team admin only

GET /targets

Response
Status code 200

{
  "data": [
    {
      "type": "sold_products",
      "active": true,
      "user_count": 1,
      "target_sum": 4,
      "updated_at": "2017-09-21 13:59:40"
    },
    {
      "type": "test_drives",
      "active": false,
      "user_count": 0,
      "target_sum": 0,
      "updated_at": null
    },
    {
      "type": "offers",
      "active": false,
      "user_count": 0,
      "target_sum": 0,
      "updated_at": null
    },
    {
      "type": "accepted_leads",
      "active": false,
      "user_count": 0,
      "target_sum": 0,
      "updated_at": null
    },
    {
      "type": "b2b_accounts",
      "active": true,
      "user_count": 3,
      "target_sum": 120,
      "updated_at": "2017-09-22 06:43:02"
    },
    {
      "type": "b2c_contacts",
      "active": false,
      "user_count": 0,
      "target_sum": 0,
      "updated_at": null
    }
  ]
}

Get a target

Team admin only

GET /targets/:target_type

Response
Status code 200

{
  "type": "sold_products",
  "active": true,
  "user_count": 1,
  "target_sum": 4,
  "users": [
    {
      "id": 1,
      "active": true,
      "targets": [
        {
          "target": 0,
          "value": 0,
          "reached": false,
          "month": "jan"
        },
        {
          "target": 0,
          "value": 0,
          "reached": false,
          "month": "feb"
        },
        {
          "target": 0,
          "value": 0,
          "reached": false,
          "month": "mar"
        },
        {
          "target": 0,
          "value": 0,
          "reached": false,
          "month": "apr"
        },
        {
          "target": 0,
          "value": 0,
          "reached": false,
          "month": "may"
        },
        {
          "target": 0,
          "value": 0,
          "reached": false,
          "month": "jun"
        },
        {
          "target": 0,
          "value": 0,
          "reached": false,
          "month": "jul"
        },
        {
          "target": 0,
          "value": 0,
          "reached": false,
          "month": "aug"
        },
        {
          "target": 1,
          "value": 0,
          "reached": false,
          "month": "sep"
        },
        {
          "target": 1,
          "value": 0,
          "reached": false,
          "month": "oct"
        },
        {
          "target": 1,
          "value": 0,
          "reached": false,
          "month": "nov"
        },
        {
          "target": 1,
          "value": 0,
          "reached": false,
          "month": "dec"
        }
      ]
    }
  ],
  "updated_at": "2017-09-21 13:59:40"
}

Update a target

Team admin only

PUT /targets/:target_type

Parameters

  • active boolean
  • Required
  • users array
  • users.*.id integer
    • Required
  • users.*.active boolean
    • Required
  • users.*.targets array
    • Required
    • Must have 12 entries. Index 0 is Januar. Index 11 is December
    • users.*.targets.* integer
    • Required
    • Values will be ignored for months in the past

Payload

{
  "active": true,
  "users": [
    {
      "id": 1,
      "active": true,
      "targets": [
        1,
        2,
        3,
        400,
        5,
        6,
        7,
        8,
        103,
        1,
        1,
        1
      ]
    },
    {
      "id": 2,
      "active": true,
      "targets": [
        3,
        2,
        3,
        400,
        5,
        6,
        7,
        8,
        0,
        1,
        1,
        1
      ]
    },
    {
      "id": 6,
      "active": true,
      "targets": [
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        1,
        1,
        1,
        1
      ]
    }
  ]
}

Response
Status code 200

{
  "type": "sold_products",
  "active": true,
  "user_count": 3,
  "target_sum": 113,
  "users": [
    {
      "id": 1,
      "active": true,
      "targets": [
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        103,
        1,
        1,
        1
      ]
    },
    {
      "id": 2,
      "active": true,
      "targets": [
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        1,
        1,
        1
      ]
    },
    {
      "id": 6,
      "active": true,
      "targets": [
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        1,
        1,
        1,
        1
      ]
    }
  ],
  "updated_at": "2017-09-21 13:59:40"
}

Get targets for a user

Only accessible when the requesting user id equals :user_id

GET /companies/:company_id/users/:user_id/targets

Response
Status code 200

{
  "data": [
    {
      "type": "b2b_accounts",
      "active": false,
      "user": {
        "id": 1,
        "active": true,
        "targets": [
          {
            "target": 0,
            "value": 0,
            "reached": false,
            "month": "jan"
          },
          {
            "target": 0,
            "value": 0,
            "reached": false,
            "month": "feb"
          },
          {
            "target": 0,
            "value": 0,
            "reached": false,
            "month": "mar"
          },
          {
            "target": 0,
            "value": 0,
            "reached": false,
            "month": "apr"
          },
          {
            "target": 0,
            "value": 0,
            "reached": false,
            "month": "may"
          },
          {
            "target": 0,
            "value": 0,
            "reached": false,
            "month": "jun"
          },
          {
            "target": 0,
            "value": 0,
            "reached": false,
            "month": "jul"
          },
          {
            "target": 0,
            "value": 0,
            "reached": false,
            "month": "aug"
          },
          {
            "target": 0,
            "value": 0,
            "reached": false,
            "month": "sep"
          },
          {
            "target": 1,
            "value": 0,
            "reached": false,
            "month": "oct"
          },
          {
            "target": 1,
            "value": 0,
            "reached": false,
            "month": "nov"
          },
          {
            "target": 1,
            "value": 0,
            "reached": false,
            "month": "dec"
          }
        ]
      },
      "updated_at": "2017-10-20 05:49:26"
    }
  ]
}

Get targets for a team

Admin, Group admin and team admin with access to the team only

GET /teams/:team_id/targets

Response
Status code 200

{
  "data": [
    {
      "type": "sold_products",
      "active": false,
      "user_count": 0,
      "target_sum": 0,
      "updated_at": null
    },
    {
      "type": "test_drives",
      "active": false,
      "user_count": 0,
      "target_sum": 0,
      "updated_at": null
    },
    {
      "type": "offers",
      "active": false,
      "user_count": 0,
      "target_sum": 0,
      "updated_at": null
    },
    {
      "type": "accepted_leads",
      "active": false,
      "user_count": 0,
      "target_sum": 0,
      "updated_at": null
    },
    {
      "type": "b2b_accounts",
      "active": false,
      "user_count": 1,
      "target_sum": 3,
      "updated_at": "2017-10-20 05:49:26"
    },
    {
      "type": "b2c_contacts",
      "active": false,
      "user_count": 0,
      "target_sum": 0,
      "updated_at": null
    }
  ]
}