Claim (v1)

https://github.com/folio-org/mod-orders

Table of contents

Pieces Business Logic API

API for claiming pieces

Claim pieces

Claim pieces. The endpoint is used to:

POST /pieces/claim

Claim pieces

POST /pieces/claim
Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "description": "A collection of claiming pieces",
  "type": "object",
  "properties": {
    "claimingPieceIds": {
      "description": "List of claiming pieces",
      "id": "claimingPieceIds",
      "type": "array",
      "items": {
        "description": "The id of the piece",
        "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}$"
      }
    },
    "claimingInterval": {
      "description": "Time interval (in days) for processing claims related to this piece",
      "type": "integer"
    },
    "internalNote": {
      "description": "Internal note for Send Claim action",
      "type": "string"
    },
    "externalNote": {
      "description": "External note for Send Claim action to share with Vendor",
      "type": "string"
    }
  },
  "additionalProperties": false,
  "required": [
    "claimingPieceIds",
    "claimingInterval"
  ]
}

Example:

{
  "claimingPieceIds": [
    "123e4567-e89b-12d3-a456-426614174000",
    "123e4567-e89b-12d3-a456-426614174001"
  ],
  "claimingInterval": 1,
  "internalNote": "internal",
  "externalNote": "external"
}

Response 200

Returns processing result of the claim

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "description": "A collection of claiming results",
  "type": "object",
  "properties": {
    "claimingPieceResults": {
      "description": "List of claiming results",
      "id": "claimingPieceResults",
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "pieceId": {
            "description": "The id of the piece",
            "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}$"
          },
          "status": {
            "description": "Resulting status of the processed piece record",
            "type": "string",
            "enum": [
              "success",
              "failure"
            ]
          },
          "error": {
            "description": "Error details in case claiming process for the piece record has failed",
            "type": "object",
            "readonly": true,
            "$schema": "http://json-schema.org/draft-04/schema#",
            "id": "error.schema",
            "properties": {
              "message": {
                "type": "string",
                "description": "Error message text"
              },
              "type": {
                "type": "string",
                "description": "Error message type"
              },
              "code": {
                "type": "string",
                "description": "Error message code"
              },
              "parameters": {
                "description": "Error message parameters",
                "$schema": "http://json-schema.org/draft-04/schema#",
                "id": "parameters.schema",
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "key": {
                      "type": "string"
                    },
                    "value": {
                      "type": "string"
                    }
                  }
                }
              }
            },
            "required": [
              "message"
            ]
          }
        },
        "required": [
          "pieceId"
        ],
        "additionalProperties": false
      }
    }
  },
  "additionalProperties": false,
  "required": [
    "claimingPieceResults"
  ]
}

Example:

{
  "claimingPieceResults": [
    {
      "pieceId": "123e4567-e89b-12d3-a456-426614174000",
      "status": "success"
    },
    {
      "pieceId": "123e4567-e89b-12d3-a456-426614174001",
      "status": "failure",
      "error": {
        "code": "CLAIM_ERROR",
        "message": "Failed to claim piece"
      }
    }
  ]
}

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: application/json

Type: any

Example:

{
  "errors": [
    {
      "message": "may not be null",
      "type": "1",
      "code": "-1",
      "parameters": [
        {
          "key": "moduleTo",
          "value": "null"
        }
      ]
    }
  ]
}

Media type: text/plain

Type: any

Example:

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

Response 422

Validation errors

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "id": "errors.schema",
  "description": "A set of errors",
  "type": "object",
  "properties": {
    "errors": {
      "description": "List of errors",
      "id": "errors",
      "type": "array",
      "items": {
        "type": "object",
        "$schema": "http://json-schema.org/draft-04/schema#",
        "id": "error.schema",
        "description": "An error",
        "properties": {
          "message": {
            "type": "string",
            "description": "Error message text"
          },
          "type": {
            "type": "string",
            "description": "Error message type"
          },
          "code": {
            "type": "string",
            "description": "Error message code"
          },
          "parameters": {
            "description": "Error message parameters",
            "$schema": "http://json-schema.org/draft-04/schema#",
            "id": "parameters.schema",
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "key": {
                  "type": "string"
                },
                "value": {
                  "type": "string"
                }
              }
            }
          }
        },
        "required": [
          "message"
        ]
      }
    },
    "total_records": {
      "description": "Total number of errors",
      "type": "integer"
    }
  }
}

Example:

{
  "errors": [
    {
      "message": "may not be null",
      "type": "1",
      "code": "-1",
      "parameters": [
        {
          "key": "moduleTo",
          "value": "null"
        }
      ]
    }
  ]
}

Response 500

Internal server error, e.g. due to misconfiguration

Body

Media type: application/json

Type: any

Example:

{
  "errors": [
    {
      "message": "may not be null",
      "type": "1",
      "code": "-1",
      "parameters": [
        {
          "key": "moduleTo",
          "value": "null"
        }
      ]
    }
  ]
}

Media type: text/plain

Type: any

Example:

internal server error, contact administrator