Api >

Service Portal REST API

Admin can create site
Given I am authenticated as Admin
And there is an Account with SalesForceID 123accountID
When I send /api/accounts/123accountID/sites as application/json; charset=UTF-8
with following body:
{
  "data": [{
    "name": "salesForceId",
    "value": "SF123ID"
  }, {
    "name": "name",
    "value": "New Site Name"
  }, {
    "name": "street",
    "value": "Palm Coast"
  }, {
    "name": "zip",
    "value": "32164"
  }, {
    "name": "city",
    "value": "Miami"
  }, {
    "name": "country",
    "value": "US"
  }]
}
Then I should receive HTTP/1.1 201 Created With header http://localhost:9998/api/accounts/123accountID/sites/SF123ID
And when I send as Admin /api/accounts/123accountID/sites/SF123ID
I should receive HTTP/1.1 200 OK with body:
{
  "data": [{
    "name": "name",
    "value": "New Site Name"
  }, {
    "name": "street",
    "value": "Palm Coast"
  }, {
    "name": "zip",
    "value": "32164"
  }, {
    "name": "city",
    "value": "Miami"
  }, {
    "name": "country",
    "value": "US"
  }]
}

When country code is 'DE' than azc and ndc are required
Given I am authenticated as Admin
And there is an Account with SalesForceID 123accountID
When I send /api/accounts/123accountID/sites as application/json; charset=UTF-8
with following body:
{
  "data": [{
    "name": "salesForceId",
    "value": "SF123ID"
  }, {
    "name": "name",
    "value": "New Site Name"
  }, {
    "name": "street",
    "value": "Palm Coast"
  }, {
    "name": "zip",
    "value": "32164"
  }, {
    "name": "city",
    "value": "Miami"
  }, {
    "name": "country",
    "value": "DE"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request With following body
{
  "errors": [{
    "message": "AZC and NDC cann\u0027t be empty for country [de]"
  }]
}
And when I send /api/accounts/123accountID/sites/SF123ID
I should receive HTTP/1.1 404 Not Found
Customer can't create site
Given I am authenticated as customer K0002
When I send /api/accounts/123accountID/sites as application/json; charset=UTF-8
with following body:
{
  "data": [{
    "name": "salesForceId",
    "value": "SF123ID"
  }, {
    "name": "name",
    "value": "New Site Name"
  }, {
    "name": "street",
    "value": "Palm Coast"
  }, {
    "name": "zip",
    "value": "32164"
  }, {
    "name": "city",
    "value": "Miami"
  }, {
    "name": "country",
    "value": "US"
  }]
}
Then I should receive HTTP/1.1 403 Forbidden With following body
{
  "title": "Access forbidden",
  "detail": "Required role is missing"
}

System Integrator cannot create Site
Given I am authenticated as System Integrator S0002
When I send /api/accounts/123accountID/sites as application/json; charset=UTF-8
with following body:
{
  "data": [{
    "name": "salesForceId",
    "value": "SF123ID"
  }]
}
Then I should receive HTTP/1.1 403 Forbidden With following body
{
  "title": "Access forbidden",
  "detail": "Required role is missing"
}
Operator cannot create Site
Given I am authenticated as Operator C0002
When I send /api/accounts/123accountID/sites as application/json; charset=UTF-8
with following body:
{
  "data": [{
    "name": "salesForceId",
    "value": "SF123ID"
  }]
}
Then I should receive HTTP/1.1 403 Forbidden With following body
{
  "title": "Access forbidden",
  "detail": "Required role is missing"
}