Api >

Service Portal REST API

Admin with POST creates Customer Contract
Given I am authenticated as Admin
When I send /api/customers/K0002/contracts with application/json; charset=UTF-8 and body:
{
  "data": [{
    "name": "name",
    "value": "Contract"
  }, {
    "name": "salesForceId",
    "value": "800D0000003ARnKIAW"
  }, {
    "name": "subId",
    "value": 2
  }]
}
Then I should receive HTTP/1.1 201 Created with http://localhost:9998/api/customers/K0002/contracts/800D0000003ARnKIAW and following body:
{
  "href": "/api/customers/K0002/contracts/800D0000003ARnKIAW"
}
And authenticated call to /api/customers/K0002/contracts/800D0000003ARnKIAW returns HTTP/1.1 200 OK with following body:
{
  "data": [{
    "name": "name",
    "value": "Contract"
  }, {
    "name": "salesForceId",
    "value": "800D0000003ARnKIAW"
  }, {
    "name": "subId",
    "value": 2
  }]
}
POST returns 400 if Customer Contract with given salesForceId already exists
Given I am authenticated as Admin
and there is a Customer Contract with salesForceId 800D0000003ARnKIAW and name Contract and subId 2
When I send /api/customers/K0002/contracts with application/json; charset=UTF-8 and body:
{
  "data": [{
    "name": "name",
    "value": "New Contract"
  }, {
    "name": "salesForceId",
    "value": "800D0000003ARnKIAW"
  }, {
    "name": "subId",
    "value": 4
  }]
}
Then I should receive HTTP/1.1 400 Bad Request with following body:
{
  "described_by": "http://api.nfon.net/probs/duplicated-customer-contract",
  "title": "Customer contract exists",
  "detail": "Customer K0002 contract with salesForceId 800D0000003ARnKIAW already exists"
}
And authenticated call to /api/customers/K0002/contracts/800D0000003ARnKIAW returns HTTP/1.1 200 OK with following body:
{
  "href": "/api/customers/K0002/contracts/800D0000003ARnKIAW",
  "data": [{
    "name": "name",
    "value": "Contract"
  }, {
    "name": "salesForceId",
    "value": "800D0000003ARnKIAW"
  }, {
    "name": "subId",
    "value": 2
  }]
}
POST returns 400 if Customer Contract's salesForceId is not provided
Given I am authenticated as Admin
When I send /api/customers/K0002/contracts with application/json; charset=UTF-8 and body:
{
  "data": [{
    "name": "name",
    "value": "New Contract"
  }, {
    "name": "subId",
    "value": 4
  }]
}
Then I should receive HTTP/1.1 400 Bad Request with following body:
{
  "errors": [{
    "message": "may not be null",
    "path": "salesForceId"
  }]
}
POST returns 400 if Customer Contract's subId is not provided
Given I am authenticated as Admin
When I send /api/customers/K0002/contracts with application/json; charset=UTF-8 and body:
{
  "data": [{
    "name": "name",
    "value": "New Contract"
  }, {
    "name": "salesForceId",
    "value": "800D0000003ARnKIAW"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request with following body:
{
  "errors": [{
    "message": "Value must be provided",
    "path": "subId"
  }]
}
And authenticated call to /api/customers/K0002/contracts/800D0000003ARnKIAW returns HTTP/1.1 404 Not Found
POST returns 400 if Customer Contract's name is not provided
Given I am authenticated as Admin
When I send /api/customers/K0002/contracts with application/json; charset=UTF-8 and body:
{
  "data": [{
    "name": "salesForceId",
    "value": "800D0000003ARnKIAW"
  }, {
    "name": "subId",
    "value": 4
  }]
}
Then I should receive HTTP/1.1 400 Bad Request with following body:
{
  "errors": [{
    "message": "may not be null",
    "path": "name"
  }]
}
And authenticated call to /api/customers/K0002/contracts/800D0000003ARnKIAW returns HTTP/1.1 404 Not Found
POST returns 400 if Customer already has a Contract with given subId
Given I am authenticated as Admin
and there is a Customer Contract with salesForceId 800D0000003ARnKIAW and name Contract and subId 2
When I send /api/customers/K0002/contracts with application/json; charset=UTF-8 and body:
{
  "data": [{
    "name": "name",
    "value": "New Contract"
  }, {
    "name": "salesForceId",
    "value": "800D0000001INyrCNQ"
  }, {
    "name": "subId",
    "value": 2
  }]
}
Then I should receive HTTP/1.1 400 Bad Request with following body:
{
  "errors": [{
    "message": "subId must be unique for customer K0002",
    "path": "subId",
    "value": 2
  }]
}
And authenticated call to /api/customers/K0002/contracts/800D0000001INyrCNQ returns HTTP/1.1 404 Not Found
POST returns 403 for non-admin users
Given I am authenticated as K0002
When I send /api/customers/K0002/contracts with application/json; charset=UTF-8 and body:
{
  "data": [{
    "name": "name",
    "value": "Contract"
  }, {
    "name": "salesForceId",
    "value": "800D0000003ARnKIAW"
  }, {
    "name": "subId",
    "value": 4
  }]
}
Then I should receive HTTP/1.1 403 Forbidden and following body:
{
  "title": "Access forbidden",
  "detail": "Required role is missing",
  "described_by": "http://api.nfon.net/probs/invalid-authorization"
}
Cannot create data for missing Customer
Given I am authenticated as Admin
When I send /api/customers/K0404/contracts
with application/json; charset=UTF-8 and body:
{
  "data": [{
    "name": "name",
    "value": "Contract"
  }, {
    "name": "salesForceId",
    "value": "800D0000003ARnKIAW"
  }, {
    "name": "subId",
    "value": 4
  }]
}
Then I should receive HTTP/1.1 404 Not Found
with following body:
{
  "described_by": "http://api.nfon.net/probs/customer-not-found",
  "title": "Customer not found",
  "detail": "Customer with identifier K0404 has not been found"
}