Sample-Module (v1)

http://github.com/org/folio/sample-module

Table of contents

Sample Module

CRUD API

/location

Collection of location items.

GET /location

Get list of locations

GET /location
Query Parameters
  • query: (string)

    A query expressed as a CQL string (see dev.folio.org/reference/glossary#cql) using valid searchable fields. The first example below shows the general form of a full CQL query, but those fields might not be relevant in this context.

    with valid searchable fields: for example code

    Example:

    (username=="ab*" or personal.firstName=="ab*" or personal.lastName=="ab*") and active=="true" sortby personal.lastName personal.firstName barcode
    
    ["code", "MEDGRANT", "="]
    
  • offset: (integer - default: 0 - minimum: 0 - maximum: 2147483647)

    Skip over a number of elements by specifying an offset value for the query

    Example:

    0
  • limit: (integer - default: 10 - minimum: 0 - maximum: 2147483647)

    Limit the number of elements returned in the response

    Example:

    10
  • lang: (string - default: en - pattern: [a-zA-Z]{2})

    Requested language. Optional. [lang=en]

Response 200

Returns a list of location items

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "description": "collection of location records",
  "type": "object",
  "properties": {
    "locations": {
      "description": "collection of location records",
      "type": "array",
      "id": "locations",
      "items": {
        "type": "object",
        "$ref": "location.json"
      }
    },
    "total_records": {
      "description": "The number of objects contained in this collection",
      "type": "integer"
    },
    "first": {
      "description": "The index of the first object contained in this collection",
      "type": "integer"
    },
    "last": {
      "description": "The index of the last object contained in this collection",
      "type": "integer"
    }
  },
  "additionalProperties": false
}

Example:

{
    "locations":
        [
          {
            "id": "a4e65e03-99a4-4b39-8e6a-ae666ac52bea",
            "location_id": "eb2d063a-5b4c-4cab-8db1-5fc5c5941df6",
            "quantity": 2,
            "quantity_electronic": 1,
            "quantity_physical": 1,
            "po_line_id": "8c778aee-97fa-4586-b131-3ea588a728e2"
          }
        ],
    "total_records": 1,
    "first": 1,
    "last": 1
}

Response 400

Bad request, e.g. malformed request body or query parameter. Details of the error (e.g. name of the parameter or line/character number with malformed data) provided in the response.

Body

Media type: text/plain

Type: any

Example:

unable to list location -- malformed parameter 'query', syntax error at column 6

Response 401

Not authorized to perform requested action

Body

Media type: text/plain

Type: any

Example:

unable to list location -- unauthorized

Response 500

Internal server error, e.g. due to misconfiguration

Body

Media type: text/plain

Type: any

Example:

internal server error, contact administrator

POST /location

Create a new location item.

POST /location
Query Parameters
  • lang: (string - default: en - pattern: [a-zA-Z]{2})

    Requested language. Optional. [lang=en]

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "description": "purchase order line location record",
  "type": "object",
  "properties": {
    "id": {
      "description": "UUID of this (orders) location record",
      "type": "string",
      "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
    },
    "location_id": {
      "description": "UUID of the (inventory) location record",
      "type": "string",
      "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
    },
    "po_line_id": {
      "description": "UUID of the purchase order line this location record is associated with",
      "type": "string",
      "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
    },
    "quantity": {
      "description": "combined/total quanitity of physical and electronic items",
      "type": "integer"
    },
    "quantity_electronic": {
      "description": "quantity of electronic items",
      "type": "integer"
    },
    "quantity_physical": {
      "description": "quantity of physical items",
      "type": "integer"
    }
  },
  "additionalProperties": false
}

Example:

{
  "location_id": "eb2d063a-5b4c-4cab-8db1-5fc5c5941df6",
  "quantity": 2,
  "quantity_electronic": 1,
  "quantity_physical": 1,
  "po_line_id": "8c778aee-97fa-4586-b131-3ea588a728e2"
}

Response 201

Returns a newly created item, with server-controlled fields like 'id' populated

Headers
  • Location: required (string)

    URI to the created location item

Body

Media type: application/json

Type: any

Example:

{
  "location_id": "eb2d063a-5b4c-4cab-8db1-5fc5c5941df6",
  "quantity": 2,
  "quantity_electronic": 1,
  "quantity_physical": 1,
  "po_line_id": "8c778aee-97fa-4586-b131-3ea588a728e2"
}

Response 400

Bad request, e.g. malformed request body or query parameter. Details of the error (e.g. name of the parameter or line/character number with malformed data) provided in the response.

Body

Media type: text/plain

Type: any

Example:

"unable to add location -- malformed JSON at 13:3"

Response 401

Not authorized to perform requested action

Body

Media type: text/plain

Type: any

Example:

unable to create location -- unauthorized

Response 500

Internal server error, e.g. due to misconfiguration

Body

Media type: text/plain

Type: any

Example:

Internal server error, contact administrator

GET /location/{id}

Retrieve location item with given {locationId}

GET /location/{id}
URI Parameters
  • id: required (string)
Query Parameters
  • lang: (string - default: en - pattern: [a-zA-Z]{2})

    Requested language. Optional. [lang=en]

Response 200

Returns item with a given ID

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "description": "purchase order line location record",
  "type": "object",
  "properties": {
    "id": {
      "description": "UUID of this (orders) location record",
      "type": "string",
      "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
    },
    "location_id": {
      "description": "UUID of the (inventory) location record",
      "type": "string",
      "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
    },
    "po_line_id": {
      "description": "UUID of the purchase order line this location record is associated with",
      "type": "string",
      "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
    },
    "quantity": {
      "description": "combined/total quanitity of physical and electronic items",
      "type": "integer"
    },
    "quantity_electronic": {
      "description": "quantity of electronic items",
      "type": "integer"
    },
    "quantity_physical": {
      "description": "quantity of physical items",
      "type": "integer"
    }
  },
  "additionalProperties": false
}

Example:

{
  "id": "a4e65e03-99a4-4b39-8e6a-ae666ac52bea",
  "location_id": "eb2d063a-5b4c-4cab-8db1-5fc5c5941df6",
  "quantity": 2,
  "quantity_electronic": 1,
  "quantity_physical": 1,
  "po_line_id": "8c778aee-97fa-4586-b131-3ea588a728e2"
}

Response 404

Item with a given ID not found

Body

Media type: text/plain

Type: any

Example:

"location not found"

Response 500

Internal server error, e.g. due to misconfiguration

Body

Media type: text/plain

Type: any

Example:

internal server error, contact administrator

DELETE /location/{id}

Delete location item with given {locationId}

DELETE /location/{id}
URI Parameters
  • id: required (string)
Query Parameters
  • lang: (string - default: en - pattern: [a-zA-Z]{2})

    Requested language. Optional. [lang=en]

Response 204

Item deleted successfully

Response 400

Bad request, e.g. malformed request body or query parameter. Details of the error (e.g. name of the parameter or line/character number with malformed data) provided in the response.

Body

Media type: text/plain

Type: any

Example:

"unable to delete location -- constraint violation"

Response 404

Item with a given ID not found

Body

Media type: text/plain

Type: any

Example:

"location not found"

Response 500

Internal server error, e.g. due to misconfiguration

Body

Media type: text/plain

Type: any

Example:

Internal server error, contact administrator

PUT /location/{id}

Update location item with given {locationId}

PUT /location/{id}
URI Parameters
  • id: required (string)
Query Parameters
  • lang: (string - default: en - pattern: [a-zA-Z]{2})

    Requested language. Optional. [lang=en]

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "description": "purchase order line location record",
  "type": "object",
  "properties": {
    "id": {
      "description": "UUID of this (orders) location record",
      "type": "string",
      "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
    },
    "location_id": {
      "description": "UUID of the (inventory) location record",
      "type": "string",
      "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
    },
    "po_line_id": {
      "description": "UUID of the purchase order line this location record is associated with",
      "type": "string",
      "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
    },
    "quantity": {
      "description": "combined/total quanitity of physical and electronic items",
      "type": "integer"
    },
    "quantity_electronic": {
      "description": "quantity of electronic items",
      "type": "integer"
    },
    "quantity_physical": {
      "description": "quantity of physical items",
      "type": "integer"
    }
  },
  "additionalProperties": false
}

Example:

{
  "id": "a4e65e03-99a4-4b39-8e6a-ae666ac52bea",
  "location_id": "eb2d063a-5b4c-4cab-8db1-5fc5c5941df6",
  "quantity": 2,
  "quantity_electronic": 1,
  "quantity_physical": 1,
  "po_line_id": "8c778aee-97fa-4586-b131-3ea588a728e2"
}

Response 204

Item successfully updated

Response 400

Bad request, e.g. malformed request body or query parameter. Details of the error (e.g. name of the parameter or line/character number with malformed data) provided in the response.

Body

Media type: text/plain

Type: any

Example:

"unable to update location -- malformed JSON at 13:4"

Response 404

Item with a given ID not found

Body

Media type: text/plain

Type: any

Example:

"location not found"

Response 500

Internal server error, e.g. due to misconfiguration

Body

Media type: text/plain

Type: any

Example:

internal server error, contact administrator