Sample-Module (v1)

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

Table of contents

Sample Module

CRUD API

/renewal

Collection of renewal items.

GET /renewal

Get list of renewals

GET /renewal
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 renewal items

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "description": "collection of renewal records",
  "type": "object",
  "properties": {
    "renewals": {
      "description": "collection of renewal records",
      "type": "array",
      "id": "renewals",
      "items": {
        "type": "object",
        "$ref": "renewal.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,
  "required": [
    "renewals",
    "total_records"
  ]
}

Example:

{
  "renewals":
    [
      {
        "id": "8e414baa-8cf2-4916-a90f-d1da4009e06e",
        "interval": 182,
        "cycle": "6 Months",
        "manual_renewal": true,
        "review_period": 30,
        "renewal_date": "2019-04-09T00:00:00.000Z",
        "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 renewal -- 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 renewal -- 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 /renewal

Create a new renewal item.

POST /renewal
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 renewal details",
  "type": "object",
  "properties": {
    "id": {
      "description": "UUID of this renewal 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}$"
    },
    "cycle": {
      "description": "length of the renewal cycle",
      "type": "string",
      "enum": [
        "Two Years",
        "One Year",
        "3 Months",
        "6 Months",
        "1 Month",
        "Manual"
      ]
    },
    "interval": {
      "description": "renewal interval (in days?)",
      "type": "integer"
    },
    "manual_renewal": {
      "description": "whether or not this is a manual renewal",
      "type": "boolean"
    },
    "review_period": {
      "description": "time prior to renewal where changes can be made to subscription",
      "type": "integer"
    },
    "renewal_date": {
      "description": "date renewal was confirmed by vendor or sent to vendor",
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "po_line_id": {
      "description": "UUID of the purchase order line this 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}$"
    }
  },
  "additionalProperties": false,
  "required": [
    "interval"
  ]
}

Example:

{
  "interval": 182,
  "cycle": "6 Months",
  "manual_renewal": true,
  "review_period": 30,
  "renewal_date": "2019-04-09T00:00:00.000Z",
  "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 renewal item

Body

Media type: application/json

Type: any

Example:

{
  "interval": 182,
  "cycle": "6 Months",
  "manual_renewal": true,
  "review_period": 30,
  "renewal_date": "2019-04-09T00:00:00.000Z",
  "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 renewal -- malformed JSON at 13:3"

Response 401

Not authorized to perform requested action

Body

Media type: text/plain

Type: any

Example:

unable to create renewal -- 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 /renewal/{id}

Retrieve renewal item with given {renewalId}

GET /renewal/{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 renewal details",
  "type": "object",
  "properties": {
    "id": {
      "description": "UUID of this renewal 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}$"
    },
    "cycle": {
      "description": "length of the renewal cycle",
      "type": "string",
      "enum": [
        "Two Years",
        "One Year",
        "3 Months",
        "6 Months",
        "1 Month",
        "Manual"
      ]
    },
    "interval": {
      "description": "renewal interval (in days?)",
      "type": "integer"
    },
    "manual_renewal": {
      "description": "whether or not this is a manual renewal",
      "type": "boolean"
    },
    "review_period": {
      "description": "time prior to renewal where changes can be made to subscription",
      "type": "integer"
    },
    "renewal_date": {
      "description": "date renewal was confirmed by vendor or sent to vendor",
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "po_line_id": {
      "description": "UUID of the purchase order line this 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}$"
    }
  },
  "additionalProperties": false,
  "required": [
    "interval"
  ]
}

Example:

{
  "id": "8e414baa-8cf2-4916-a90f-d1da4009e06e",
  "interval": 182,
  "cycle": "6 Months",
  "manual_renewal": true,
  "review_period": 30,
  "renewal_date": "2019-04-09T00:00:00.000Z",
  "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:

"renewal 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 /renewal/{id}

Delete renewal item with given {renewalId}

DELETE /renewal/{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 renewal -- constraint violation"

Response 404

Item with a given ID not found

Body

Media type: text/plain

Type: any

Example:

"renewal 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 /renewal/{id}

Update renewal item with given {renewalId}

PUT /renewal/{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 renewal details",
  "type": "object",
  "properties": {
    "id": {
      "description": "UUID of this renewal 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}$"
    },
    "cycle": {
      "description": "length of the renewal cycle",
      "type": "string",
      "enum": [
        "Two Years",
        "One Year",
        "3 Months",
        "6 Months",
        "1 Month",
        "Manual"
      ]
    },
    "interval": {
      "description": "renewal interval (in days?)",
      "type": "integer"
    },
    "manual_renewal": {
      "description": "whether or not this is a manual renewal",
      "type": "boolean"
    },
    "review_period": {
      "description": "time prior to renewal where changes can be made to subscription",
      "type": "integer"
    },
    "renewal_date": {
      "description": "date renewal was confirmed by vendor or sent to vendor",
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "po_line_id": {
      "description": "UUID of the purchase order line this 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}$"
    }
  },
  "additionalProperties": false,
  "required": [
    "interval"
  ]
}

Example:

{
  "id": "8e414baa-8cf2-4916-a90f-d1da4009e06e",
  "interval": 182,
  "cycle": "6 Months",
  "manual_renewal": true,
  "review_period": 30,
  "renewal_date": "2019-04-09T00:00:00.000Z",
  "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 renewal -- malformed JSON at 13:4"

Response 404

Item with a given ID not found

Body

Media type: text/plain

Type: any

Example:

"renewal 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