{
  "openapi": "3.1.0",
  "info": {
    "title": "SAM API",
    "description": "API for third-party applications to interact with SAM",
    "contact": {
      "name": "",
      "url": "https://www.interiware.com",
      "email": "support@interiware.com"
    },
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://{api-host}/api",
      "description": "Adresse de l'API communiquée par Interiware avec vos identifiants",
      "variables": {
        "api-host": {
          "default": "api-host",
          "description": "Nom d'hôte de l'API SAM ULTIMATE, communiqué par Interiware"
        }
      }
    }
  ],
  "security": [
    {
      "keycloak_client_credentials": []
    }
  ],
  "tags": [
    {
      "name": "Candidate API",
      "description": "API for importing candidates"
    }
  ],
  "paths": {
    "/external/candidate/v1": {
      "post": {
        "tags": [
          "Candidate API"
        ],
        "operationId": "createCandidate",
        "parameters": [
          {
            "name": "X-SUBTENANT-ID",
            "in": "header",
            "description": "Sub-tenant identifier",
            "required": true
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Candidate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "*/*": {
                "schema": {
                  "$ref": "#/components/schemas/Candidate"
                }
              }
            }
          }
        }
      }
    },
    "/external/candidate/v1/{id}/documents": {
      "post": {
        "tags": [
          "Candidate API"
        ],
        "summary": "Attach a document to a candidate",
        "description": "A document of category CV is analysed like one uploaded in SAM, when CV analysis is enabled",
        "operationId": "addDocument",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "ID of the candidate",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "category",
            "in": "query",
            "description": "Code of a category from /document-categories",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-SUBTENANT-ID",
            "in": "header",
            "description": "Sub-tenant identifier",
            "required": true
          }
        ],
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "description": "File to upload"
                  }
                },
                "required": [
                  "file"
                ]
              },
              "encoding": {
                "file": {
                  "contentType": "multipart/form-data"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "*/*": {
                "schema": {
                  "$ref": "#/components/schemas/Document"
                }
              }
            }
          }
        }
      }
    },
    "/external/candidate/v1/ping": {
      "get": {
        "tags": [
          "Candidate API"
        ],
        "operationId": "ping",
        "parameters": [
          {
            "name": "X-SUBTENANT-ID",
            "in": "header",
            "description": "Sub-tenant identifier",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "*/*": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/external/candidate/v1/occupations": {
      "get": {
        "tags": [
          "Candidate API"
        ],
        "operationId": "getOccupations",
        "parameters": [
          {
            "name": "X-SUBTENANT-ID",
            "in": "header",
            "description": "Sub-tenant identifier",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "*/*": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Occupation"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/external/candidate/v1/document-categories": {
      "get": {
        "tags": [
          "Candidate API"
        ],
        "summary": "Document categories",
        "description": "The categories a candidate's document can be filed under",
        "operationId": "getDocumentCategories",
        "parameters": [
          {
            "name": "X-SUBTENANT-ID",
            "in": "header",
            "description": "Sub-tenant identifier",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "*/*": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/DocumentCategory"
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Address": {
        "type": "object",
        "properties": {
          "line1": {
            "type": "string",
            "maxLength": 50,
            "minLength": 0
          },
          "line2": {
            "type": "string",
            "maxLength": 50,
            "minLength": 0
          },
          "line3": {
            "type": "string",
            "maxLength": 50,
            "minLength": 0
          },
          "postalCode": {
            "type": "string",
            "maxLength": 8,
            "minLength": 0
          },
          "city": {
            "type": "string",
            "maxLength": 30,
            "minLength": 0
          },
          "country": {
            "type": "string",
            "maxLength": 3,
            "minLength": 0
          }
        }
      },
      "Document": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "lastModifiedBy": {
            "type": "string"
          },
          "dateTrack": {
            "type": "string",
            "format": "date-time"
          },
          "deleted": {
            "type": "boolean"
          },
          "entityType": {
            "type": "string",
            "enum": [
              "EMPLOYEE",
              "MISSION",
              "SALARIED_EMPLOYEE",
              "CLIENT",
              "DEBTOR",
              "BOOKING",
              "PERMANENT_ASSIGNMENT",
              "TEMPORARY_ASSIGNMENT",
              "CCT",
              "BANK_TRANSFER_ORDER",
              "WORK_REPORT"
            ]
          },
          "entityId": {
            "type": "string"
          },
          "categoryCode": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "fileName": {
            "type": "string"
          },
          "contentType": {
            "type": "string"
          },
          "documentId": {
            "type": "string"
          }
        }
      },
      "Candidate": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "agenceId": {
            "type": "string"
          },
          "advisorId": {
            "type": "string"
          },
          "gender": {
            "type": "string",
            "enum": [
              "FEMALE",
              "MALE"
            ]
          },
          "firstName": {
            "type": "string",
            "maxLength": 60,
            "minLength": 0
          },
          "lastName": {
            "type": "string",
            "maxLength": 60,
            "minLength": 0
          },
          "address": {
            "$ref": "#/components/schemas/Address"
          },
          "phone": {
            "type": "string",
            "maxLength": 20,
            "minLength": 0
          },
          "mobile": {
            "type": "string",
            "maxLength": 20,
            "minLength": 0
          },
          "email": {
            "type": "string",
            "maxLength": 50,
            "minLength": 0,
            "pattern": "^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$|^\\s*$"
          },
          "avsNumber": {
            "type": "string",
            "maxLength": 16,
            "minLength": 0
          },
          "nationality": {
            "type": "string",
            "maxLength": 3,
            "minLength": 0
          },
          "birthDate": {
            "type": "string",
            "format": "date"
          },
          "birthPlace": {
            "type": "string",
            "maxLength": 30,
            "minLength": 0
          },
          "workPermitType": {
            "type": "string",
            "enum": [
              "SHORT_TERM_L",
              "ANNUAL_B",
              "SETTLED_C",
              "CROSS_BORDER_G",
              "ASYLUM_SEEKER_N",
              "NEED_FOR_PROTECTION_S",
              "NOTIFICATION_PROCEDURE_FOR_SHORTTERM_WORK_90_DAYS",
              "NOTIFICATION_PROCEDURE_FOR_SHORTTERM_WORK_120_DAYS",
              "PROVISIONALLY_ADMITTED_FOREIGNERS_F",
              "RESIDENT_FOREIGN_NATIONAL_WITH_GAINFUL_EMPLOYMENT_CI",
              "OTHERS_NOT_SWISS"
            ]
          },
          "partnerNationality": {
            "type": "string",
            "maxLength": 3,
            "minLength": 0
          },
          "partnerWorksInCH": {
            "type": "boolean"
          },
          "numberOfChildren": {
            "type": "integer",
            "format": "int32"
          },
          "primaryMotherTongue": {
            "type": "string",
            "description": "Primary mother tongue, must exist in the 'LANGUE' lookup"
          },
          "secondaryMotherTongue": {
            "type": "string",
            "description": "Secondary mother tongue, must exist in the 'LANGUE' lookup"
          },
          "ownsCar": {
            "type": "boolean"
          },
          "ownsMotorbike": {
            "type": "boolean"
          },
          "ownsBicycle": {
            "type": "boolean"
          },
          "hasCarLicense": {
            "type": "boolean"
          },
          "hasMotorbikeLicense": {
            "type": "boolean"
          },
          "hasHeavyVehicleLicense": {
            "type": "boolean"
          },
          "hasTrailerLicense": {
            "type": "boolean"
          },
          "hasConstructionMachineLicense": {
            "type": "boolean"
          },
          "comment": {
            "type": "string"
          },
          "evaluationComment": {
            "type": "string"
          },
          "webimpnote": {
            "type": "string"
          },
          "occupationIds": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "minItems": 1
          }
        },
        "required": [
          "firstName",
          "gender",
          "lastName",
          "occupationIds"
        ]
      },
      "Occupation": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "nameFr": {
            "type": "string"
          },
          "nameDe": {
            "type": "string"
          },
          "active": {
            "type": "boolean"
          },
          "suvaMapped": {
            "type": "boolean"
          }
        }
      },
      "DocumentCategory": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "parentType": {
            "type": "string",
            "enum": [
              "EMPLOYEE",
              "MISSION",
              "SALARIED_EMPLOYEE",
              "CLIENT",
              "DEBTOR",
              "BOOKING",
              "PERMANENT_ASSIGNMENT",
              "TEMPORARY_ASSIGNMENT",
              "CCT",
              "BANK_TRANSFER_ORDER",
              "WORK_REPORT"
            ]
          },
          "description": {
            "type": "string"
          }
        }
      }
    },
    "securitySchemes": {
      "keycloak_client_credentials": {
        "type": "oauth2",
        "flows": {
          "clientCredentials": {
            "tokenUrl": "/api/external/docs/token"
          }
        }
      }
    }
  }
}