A pact between GDS API Adapters and Collections Organisation API

Requests from GDS API Adapters to Collections Organisation API

Interactions

Given no organisation exists, upon receiving a request for a non-existant organisation from GDS API Adapters, with

{
  "method": "get",
  "path": "/api/organisations/department-for-making-life-better",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/71.2.0 ()"
  }
}

Collections Organisation API will respond with:

{
  "status": 404,
  "body": "404 error"
}

Given the organisation hmrc exists, upon receiving a request for hm-revenue-customs from GDS API Adapters, with

{
  "method": "get",
  "path": "/api/organisations/hm-revenue-customs",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/71.2.0 ()"
  }
}

Collections Organisation API will respond with:

{
  "status": 200,
  "body": {
    "id": "http://localhost:3002/api/organisations/hm-revenue-customs",
    "title": "Test Department",
    "updated_at": "2019-05-15T12:12:17.000+01:00",
    "web_url": "www.gov.uk/government/organisations/hm-revenue-customs",
    "details": {
      "slug": "hm-revenue-customs",
      "content_id": "b854f170-53c8-4098-bf77-e8ef42f93107"
    },
    "analytics_identifier": "OT1276",
    "child_organisations": [

    ],
    "superseded_organisations": [

    ]
  }
}

Given there is a list of organisations, upon receiving a request for the organisation list from GDS API Adapters, with

{
  "method": "get",
  "path": "/api/organisations",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/71.2.0 ()"
  }
}

Collections Organisation API will respond with:

{
  "status": 200,
  "headers": {
    "Content-Type": "application/json; charset=utf-8"
  },
  "body": {
    "results": [
      {
        "id": "www.gov.uk/api/organisations/test-department",
        "title": "Test Department",
        "updated_at": "2019-05-15T12:12:17.000+01:00",
        "web_url": "www.gov.uk/government/organisations/test-department",
        "details": {
          "slug": "test-department",
          "content_id": "b854f170-53c8-4098-bf77-e8ef42f93107"
        },
        "analytics_identifier": "OT1276",
        "child_organisations": [

        ],
        "superseded_organisations": [

        ]
      },
      {
        "id": "www.gov.uk/api/organisations/test-department",
        "title": "Test Department",
        "updated_at": "2019-05-15T12:12:17.000+01:00",
        "web_url": "www.gov.uk/government/organisations/test-department",
        "details": {
          "slug": "test-department",
          "content_id": "b854f170-53c8-4098-bf77-e8ef42f93107"
        },
        "analytics_identifier": "OT1276",
        "child_organisations": [

        ],
        "superseded_organisations": [

        ]
      }
    ]
  }
}

Given the organisation list is paginated, beginning at page 2, upon receiving a request with page 2 params from GDS API Adapters, with

{
  "method": "get",
  "path": "/api/organisations",
  "query": "page=2",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/71.2.0 ()"
  }
}

Collections Organisation API will respond with:

{
  "status": 200,
  "headers": {
    "link": "<http://localhost:3002/api/organisations?page=1>; rel=\"previous\", <http://localhost:3002/api/organisations?page=2>; rel=\"self\""
  },
  "body": {
    "results": [
      {
      },
      {
      },
      {
      },
      {
      },
      {
      },
      {
      },
      {
      },
      {
      },
      {
      },
      {
      },
      {
      },
      {
      },
      {
      },
      {
      },
      {
      },
      {
      },
      {
      },
      {
      },
      {
      },
      {
      }
    ],
    "page_size": 20,
    "pages": 2
  }
}

Given the organisation list is paginated, beginning at page 1, upon receiving a request without a query param from GDS API Adapters, with

{
  "method": "get",
  "path": "/api/organisations",
  "query": "",
  "headers": {
    "Accept": "application/json",
    "User-Agent": "gds-api-adapters/71.2.0 ()"
  }
}

Collections Organisation API will respond with:

{
  "status": 200,
  "headers": {
    "link": "<http://localhost:3002/api/organisations?page=2>; rel=\"next\", <http://localhost:3002/api/organisations?page=1>; rel=\"self\""
  },
  "body": {
    "results": [
      {
      },
      {
      },
      {
      },
      {
      },
      {
      },
      {
      },
      {
      },
      {
      },
      {
      },
      {
      },
      {
      },
      {
      },
      {
      },
      {
      },
      {
      },
      {
      },
      {
      },
      {
      },
      {
      },
      {
      }
    ],
    "page_size": 20,
    "pages": 2
  }
}