{
  "openapi": "3.1.0",
  "info": {
    "title": "JSDaj Audience Review",
    "version": "0.2.0"
  },
  "security": [
    {
      "bearerAuth": []
    },
    {}
  ],
  "paths": {
    "/v1/check": {
      "post": {
        "operationId": "review_audiences",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sources": {
                    "minItems": 1,
                    "maxItems": 8,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 100
                        },
                        "name": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 100
                        },
                        "csv": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 5242880
                        },
                        "emailColumn": {
                          "type": "string"
                        },
                        "statusColumn": {
                          "type": "string"
                        },
                        "declaredStatus": {
                          "type": "string",
                          "maxLength": 1000
                        }
                      },
                      "required": [
                        "id",
                        "name",
                        "csv",
                        "emailColumn"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "normalization": {
                    "default": "exact",
                    "type": "string",
                    "enum": [
                      "exact",
                      "trim-lowercase"
                    ]
                  },
                  "offset": {
                    "default": 0,
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 1000000
                  },
                  "limit": {
                    "default": 100,
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 1000
                  }
                },
                "required": [
                  "sources",
                  "normalization",
                  "offset",
                  "limit"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Bounded report page",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "apiVersion": {
                      "type": "string",
                      "const": "v1"
                    },
                    "normalization": {
                      "type": "string"
                    },
                    "records": {
                      "type": "number"
                    },
                    "uniqueMatchKeys": {
                      "type": "number"
                    },
                    "counts": {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {
                        "type": "number"
                      }
                    },
                    "page": {
                      "type": "object",
                      "properties": {
                        "offset": {
                          "type": "number"
                        },
                        "limit": {
                          "type": "number"
                        },
                        "total": {
                          "type": "number"
                        },
                        "returned": {
                          "type": "number"
                        },
                        "nextOffset": {
                          "type": [
                            "number",
                            "null"
                          ]
                        }
                      },
                      "required": [
                        "offset",
                        "limit",
                        "total",
                        "returned",
                        "nextOffset"
                      ],
                      "additionalProperties": false
                    },
                    "findings": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "sourceId": {
                            "type": "string"
                          },
                          "sourceName": {
                            "type": "string"
                          },
                          "record": {
                            "type": "number"
                          },
                          "email": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          },
                          "matchKey": {
                            "type": "string"
                          },
                          "code": {
                            "type": "string"
                          },
                          "related": {
                            "anyOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "sourceId": {
                                    "type": "string"
                                  },
                                  "sourceName": {
                                    "type": "string"
                                  },
                                  "record": {
                                    "type": "number"
                                  },
                                  "email": {
                                    "type": "string"
                                  },
                                  "status": {
                                    "type": "string"
                                  },
                                  "matchKey": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "sourceId",
                                  "sourceName",
                                  "record",
                                  "email",
                                  "status",
                                  "matchKey"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "sourceId",
                          "sourceName",
                          "record",
                          "email",
                          "status",
                          "matchKey",
                          "code",
                          "related"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "apiVersion",
                    "normalization",
                    "records",
                    "uniqueMatchKeys",
                    "counts",
                    "page",
                    "findings"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      }
    },
    "/v1/report.csv": {
      "post": {
        "operationId": "export_review_csv",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sources": {
                    "minItems": 1,
                    "maxItems": 8,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 100
                        },
                        "name": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 100
                        },
                        "csv": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 5242880
                        },
                        "emailColumn": {
                          "type": "string"
                        },
                        "statusColumn": {
                          "type": "string"
                        },
                        "declaredStatus": {
                          "type": "string",
                          "maxLength": 1000
                        }
                      },
                      "required": [
                        "id",
                        "name",
                        "csv",
                        "emailColumn"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "normalization": {
                    "default": "exact",
                    "type": "string",
                    "enum": [
                      "exact",
                      "trim-lowercase"
                    ]
                  },
                  "offset": {
                    "default": 0,
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 1000000
                  },
                  "limit": {
                    "default": 100,
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 1000
                  }
                },
                "required": [
                  "sources",
                  "normalization",
                  "offset",
                  "limit"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Bounded report page",
            "content": {
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer"
      }
    }
  }
}
