{
  "swagger": "2.0",
  "info": {
    "description": "",
    "version": "1.0.0",
    "title": "Nexus card ordering API"
  },
  "host": "cards-api.nexusgroup.com",
  "basePath": "/",
  "tags": [
    {
      "name": "Card ordering",
      "description": ""
    }
  ],
  "schemes": [
    "https"
  ],
  "paths": {
    "/login": {
      "post": {
        "tags": [
          "Card ordering"
        ],
        "summary": "Log in and get bearer token",
        "description": "",
        "operationId": "loginUser",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "in": "body",
            "name": "loginBody",
            "description": "The user name and password for login",
            "required": true,
            "schema": {
              "$ref": "#/definitions/login"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Successful login",
            "schema": {
              "$ref": "#/definitions/loginRespons"
            }
          },
          "401": {
            "description": "Invalid username/password supplied",
            "schema": {
              "$ref": "#/definitions/loginFailed"
            }
          },
          "default": {
            "description": "Unexpected error",
            "schema": {
              "$ref": "#/definitions/defaultError"
            }
          }
        }
      }
    },
    "/layout": {
      "get": {
        "tags": [
          "Card ordering"
        ],
        "summary": "Get list of available layouts",
        "description": "",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "in": "header",
            "name": "X-Auth-Token",
            "type": "string",
            "required": true,
            "description": "Bearer token from method /login"
          }
        ],
        "responses": {
          "200": {
            "description": "List of layouts",
            "schema": {
              "$ref": "#/definitions/layouts"
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "404": {
            "description": "No layouts found"
          },
          "default": {
            "description": "Unexpected error",
            "schema": {
              "$ref": "#/definitions/defaultError"
            }
          }
        }
      }
    },
    "/layout/{id}": {
      "get": {
        "tags": [
          "Card ordering"
        ],
        "summary": "Get details for specific layout",
        "description": "",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "layoutId from method /layout",
            "required": true,
            "type": "integer",
            "format": "int64"
          },
          {
            "in": "header",
            "name": "X-Auth-Token",
            "type": "string",
            "required": true,
            "description": "Bearer token from method /login"
          }
        ],
        "responses": {
          "200": {
            "description": "Layout inputfields for use in POST /order",
            "schema": {
              "$ref": "#/definitions/layout"
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "404": {
            "description": "No layout found"
          }
        }
      }
    },
    "/accessories": {
      "get": {
        "tags": [
          "Card ordering"
        ],
        "summary": "Get list of available accessories",
        "description": "",
        "parameters": [
          {
            "in": "header",
            "name": "X-Auth-Token",
            "type": "string",
            "required": true,
            "description": "Bearer token from method /login"
          }
        ],
        "responses": {
          "200": {
            "description": "List if accessories that can be used in Post /order",
            "schema": {
              "$ref": "#/definitions/articles"
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "404": {
            "description": "No accessories avalible"
          },
          "default": {
            "description": "Unexpected error",
            "schema": {
              "$ref": "#/definitions/defaultError"
            }
          }
        }
      }
    },
    "/order/{id}": {
      "get": {
        "tags": [
          "Card ordering"
        ],
        "summary": "Get status for specific order",
        "description": "",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "orderId from method /order/list or requestId from method /order",
            "required": true,
            "type": "string"
          },
          {
            "in": "header",
            "name": "X-Auth-Token",
            "type": "string",
            "required": true,
            "description": "Bearer token from method /login"
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "schema": {
              "$ref": "#/definitions/order"
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "404": {
            "description": "No order found"
          }
        }
      }
    },
    "/order/list": {
      "get": {
        "tags": [
          "Card ordering"
        ],
        "summary": "Get list of orders",
        "description": "",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "description": "Page of orders to display. Orders are sorted ascending by creation time.",
            "required": false,
            "type": "integer"
          },
          {
            "name": "createdDate",
            "in": "query",
            "description": "Display orders created this date or later, for example: 2017-10-20",
            "required": false,
            "type": "string",
            "format": "date"
          },
          {
            "in": "header",
            "name": "X-Auth-Token",
            "type": "string",
            "required": true,
            "description": "Bearer token from method /login"
          }
        ],
        "responses": {
          "200": {
            "description": "List of orders",
            "schema": {
              "$ref": "#/definitions/orderList"
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "404": {
            "description": "No orders found"
          }
        }
      }
    },
    "/order": {
      "post": {
        "tags": [
          "Card ordering"
        ],
        "summary": "Place order including layout, input fields, and accessories.",
        "description": "",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "in": "header",
            "name": "X-Auth-Token",
            "type": "string",
            "required": true,
            "description": "Bearer token from method /login"
          },
          {
            "in": "body",
            "name": "CreateOrder",
            "description": "Order instructions",
            "required": true,
            "schema": {
              "$ref": "#/definitions/createOrder"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "Order respons",
            "schema": {
              "$ref": "#/definitions/orderCreated"
            }
          },
          "400": {
            "description": "Error create order",
            "schema": {
              "$ref": "#/definitions/defaultError"
            }
          },
          "401": {
            "description": "Unauthorized"
          }
        }
      }
    }
  },
  "definitions": {
    "login": {
      "type": "object",
      "properties": {
        "username": {
          "type": "string"
        },
        "password": {
          "type": "string"
        }
      }
    },
    "loginRespons": {
      "type": "object",
      "properties": {
        "result": {
          "type": "string",
          "example": "ok"
        },
        "token": {
          "type": "string"
        },
        "validUntil": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "loginFailed": {
      "type": "object",
      "properties": {
        "result": {
          "type": "string",
          "example": "Denied"
        }
      }
    },
    "layouts": {
      "type": "object",
      "properties": {
        "foundCount": {
          "description": "Number of layouts avalible",
          "type": "integer"
        },
        "layouts": {
          "description": "List of available layouts",
          "type": "array",
          "items": {
            "$ref": "#/definitions/layoutList"
          }
        }
      }
    },
    "layoutList": {
      "type": "object",
      "properties": {
        "layoutId": {
          "description": "Use in method /layout{id}",
          "type": "integer"
        },
        "layoutName": {
          "type": "string"
        },
        "description": {
          "type": "string"
        }
      }
    },
    "layout": {
      "type": "object",
      "properties": {
        "layoutId": {
          "description": "Layout id to use in POST /order",
          "type": "integer"
        },
        "layoutName": {
          "description": "Layout name",
          "type": "string"
        },
        "articlesIncluded": {
          "description": "Array of accessories that are automatically added to each unit ordered, through POST /order.",
          "type": "array",
          "items": {
            "$ref": "#/definitions/layoutArticles"
          }
        },
        "inputFields": {
          "description": "Array of fields to use in POST /order",
          "type": "array",
          "items": {
            "$ref": "#/definitions/layoutFields"
          }
        }
      }
    },
    "articles": {
      "type": "object",
      "properties": {
        "artId": {
          "type": "string",
          "description": "Article id to use in POST /order",
          "example": "CH3301-S"
        },
        "name": {
          "type": "string",
          "description": "Name of article",
          "example": "Card Holder EC Standard - Black"
        },
        "description": {
          "type": "string",
          "description": "Description of article",
          "example": "Card holder for one card with clip on back. The clip is easily removed and then holds two cards. One side is open for convenient card access"
        },
        "imageUrl": {
          "type": "string",
          "description": "URL to image of article",
          "example": "https://web.nexusonlineservices.com/Bilder/Artikel/1300.jpg"
        }
      }
    },
    "layoutArticles": {
      "type": "object",
      "properties": {
        "artId": {
          "type": "string",
          "description": "Article id automatically added to each unit ordered through Post /order",
          "example": "CH3301-S"
        },
        "name": {
          "type": "string",
          "description": "Name of article",
          "example": "Card Holder EC Standard - Black"
        },
        "description": {
          "type": "string",
          "description": "Description of article",
          "example": "Card holder for one card with clip on back. The clip is easily removed and then holds two cards. One side is open for convenient card access"
        },
        "imageUrl": {
          "type": "string",
          "description": "URL to image of article",
          "example": "https://web.nexusonlineservices.com/Bilder/Artikel/1300.jpg"
        }
      }
    },
    "layoutFields": {
      "type": "object",
      "properties": {
        "name": {
          "description": "Name of field to use in POST /order",
          "type": "string"
        },
        "label": {
          "description": "Readable label for field",
          "type": "string"
        },
        "type": {
          "description": "Type of data to insert in field",
          "type": "string"
        },
        "required": {
          "description": "Field is required or not",
          "type": "boolean"
        },
        "maxLength": {
          "description": "Max length of data to insert",
          "type": "integer"
        },
        "valueList": {
          "description": "Value for the field \"name\" If present, only values in keys: \"index\" can be used in POST /order",
          "type": "array",
          "items": {
            "$ref": "#/definitions/layoutFieldValuelist"
          }
        }
      }
    },
    "layoutFieldValuelist": {
      "type": "object",
      "properties": {
        "index": {
          "description": "Value to use in POST /order",
          "type": "string",
          "example": "Accepted value for \"name\""
        },
        "label": {
          "description": "Explanation of value",
          "type": "string",
          "example": "Explanation of index"
        }
      }
    },
    "order": {
      "type": "object",
      "properties": {
        "foundCount": {
          "description": "Number of orders found",
          "type": "integer"
        },
        "order": {
          "description": "Order",
          "type": "array",
          "items": {
            "$ref": "#/definitions/orders"
          }
        }
      }
    },
    "orderList": {
      "type": "object",
      "properties": {
        "foundCount": {
          "description": "Number of orders found",
          "type": "integer"
        },
        "displayCount": {
          "description": "Number of orders displayed",
          "type": "integer"
        },
        "page": {
          "description": "Page to display",
          "type": "integer"
        },
        "maxPage": {
          "description": "Max page",
          "type": "integer"
        },
        "orders": {
          "description": "List of orders",
          "type": "array",
          "items": {
            "$ref": "#/definitions/orders"
          }
        }
      }
    },
    "orders": {
      "type": "object",
      "properties": {
        "orderId": {
          "description": "id of the order",
          "type": "string"
        },
        "created": {
          "description": "Created timestamp",
          "type": "string",
          "format": "dateTime"
        },
        "orderStatus": {
          "description": "Status of order",
          "type": "string"
        },
        "orderStatusId": {
          "description": "Status id",
          "type": "string"
        },
        "layoutId": {
          "description": "id of the layout included in the order",
          "type": "integer"
        },
        "productionDate": {
          "description": "Timestamp for poduction",
          "type": "string",
          "format": "datetime"
        },
        "validThru": {
          "description": "Card or key fob valid until",
          "type": "string",
          "format": "datetime"
        },
        "cardNumber": {
          "description": "Cardnumber",
          "type": "string"
        },
        "personName": {
          "description": "Name of user",
          "type": "string"
        },
        "ssn": {
          "description": "Social security number of user",
          "type": "string"
        }
      }
    },
    "orderCreated": {
      "type": "object",
      "properties": {
        "message": {
          "description": "Message of create order",
          "type": "string"
        },
        "requestId": {
          "description": "temporary id until order is created",
          "type": "string"
        }
      }
    },
    "createOrder": {
      "type": "object",
      "properties": {
        "layoutId": {
          "description": "id of layout to include in order",
          "type": "integer"
        },
        "inputField": {
          "description": "inputFields specified in layout from Get /layout/{id}",
          "type": "string",
          "example": "input value"
        },
        "accessories": {
          "type": "array",
          "description": "Ad accessories to order. Possible accessories specified in GET /accessories",
          "items": {
            "$ref": "#/definitions/accessoriesOrder"
          }
        }
      }
    },
    "accessoriesOrder": {
      "type": "object",
      "properties": {
        "artId": {
          "type": "string",
          "description": "The artId to order , specified in GET /accessories",
          "example": "CH3301-S"
        },
        "amount": {
          "type": "integer",
          "description": "Number of items to order with artId"
        }
      }
    },
    "defaultError": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string"
        },
        "message": {
          "type": "string"
        }
      }
    }
  }
}