object SurveySection
{
  "type": "object",
  "title": "Section",
  "required": [
    "questions",
    "title"
  ],
  "properties": {
    "id": {
      "type": "string",
      "title": "Id",
      "format": "uuid",
      "description": "Auto generated by the system."
    },
    "title": {
      "type": "string",
      "title": "Title",
      "example": "Root vegetables",
      "description": "The section title."
    },
    "questions": {
      "type": "array",
      "items": {
        "$ref": "#/components/schemas/SurveyQuestion"
      },
      "title": "Questions",
      "maxItems": 5,
      "description": "An array of questions a section within a Survey."
    }
  },
  "description": "Responsible for providing a section to the survey.\n\nThis is more of a long term thing, but helps if we add now."
}
object SurveySummary
{
  "type": "object",
  "title": "Summary",
  "example": {
    "questions": [
      {
        "answers": [
          {
            "count": 4,
            "answer": "Yes",
            "answer_id": "4c69011b-9b6b-46c6-8ba2-da80761131dc"
          },
          {
            "count": 6,
            "answer": "No",
            "answer_id": "f3c8d38f-842c-49d9-a0bb-e17b7803b240"
          }
        ],
        "question": "Do you feel that this will all be alright on the night?",
        "question_id": "02dee012-25e4-449e-8f2f-a552b9007d92",
        "total_answers": 10
      }
    ],
    "survey_id": "63346b3a4fd1fe7b39f192e9"
  },
  "required": [
    "survey_id"
  ],
  "properties": {
    "questions": {
      "type": "array",
      "items": {
        "$ref": "#/components/schemas/SurveySummaryQuestion"
      },
      "title": "Questions",
      "description": "A list of questions for the given survey."
    },
    "survey_id": {
      "type": "string",
      "title": "Survey Id",
      "description": "The survey ID."
    }
  },
  "description": "Responsible for providing a base for all the aggregated answers for a survey."
}
object SurveySummaryAnswer
{
  "type": "object",
  "title": "SummaryAnswer",
  "required": [
    "answer"
  ],
  "properties": {
    "count": {
      "type": "integer",
      "title": "Count",
      "default": 0,
      "description": "The count of how many times this answer was used in a response."
    },
    "answer": {
      "type": "string",
      "title": "Answer",
      "description": "The answer selected."
    },
    "answer_id": {
      "type": "string",
      "title": "Answer Id",
      "format": "uuid",
      "description": "The answer ID."
    }
  },
  "description": "Responsible for housing the aggregation for a specific answer."
}
object SurveySummaryQuestion
{
  "type": "object",
  "title": "SummaryQuestion",
  "required": [
    "question"
  ],
  "properties": {
    "answers": {
      "type": "array",
      "items": {
        "$ref": "#/components/schemas/SurveySummaryAnswer"
      },
      "title": "Answers",
      "description": "A list of aggregated answer information."
    },
    "question": {
      "type": "string",
      "title": "Question",
      "description": "The title of the question."
    },
    "question_id": {
      "type": "string",
      "title": "Question Id",
      "format": "uuid",
      "description": "The question ID."
    },
    "total_answers": {
      "type": "integer",
      "title": "Total Answers",
      "default": 0,
      "description": "The total number of answered responses for a given question."
    }
  },
  "description": "Responsible for housing the questions we want to aggregate for the summary."
}
object SurveysDeleteAllResponsesResponse
{
  "type": "object",
  "example": {},
  "properties": {}
}
object SurveysDeleteResponseResponse
{
  "type": "object",
  "example": {},
  "properties": {}
}
object SurveysDeleteSingleSurveyResponse
{
  "type": "object",
  "example": {},
  "properties": {}
}
object SurveysGetAllResponsesResponse
{
  "type": "object",
  "example": {
    "results": [
      {
        "id": "63063d07691a81e96a6e8494X",
        "sections": [
          {
            "questions": [
              {
                "answers": [
                  {
                    "value": "Yes",
                    "answer_id": "c72d8cf9-5429-40ae-ac74-10041ed68824"
                  }
                ],
                "question_id": "3797222e-f731-4bea-838b-f668682d902d",
                "question_title": "Do you like ice cream?"
              }
            ],
            "section_id": "75ac961f-d94a-4490-af8f-935ca088315f"
          }
        ],
        "date_created": "2022-08-24T15:00:23.325000",
        "date_modified": "2022-08-24T15:00:23.325000",
        "submission_id": "63063cfc71fd74aad90886c4",
        "participant_id": "5c83c95d4c266300156edc01"
      },
      {
        "id": "63063d03691a81e96a6e8493X",
        "sections": [
          {
            "questions": [
              {
                "answers": [
                  {
                    "value": "No",
                    "answer_id": "a2de5745-b0b4-421b-98ec-23935c78be13"
                  }
                ],
                "question_id": "3797222e-f731-4bea-838b-f668682d902d",
                "question_title": "Do you like ice cream?"
              }
            ],
            "section_id": "75ac961f-d94a-4490-af8f-935ca088315f"
          }
        ],
        "date_created": "2022-08-24T15:00:19.478000",
        "date_modified": "2022-08-24T15:00:19.478000",
        "submission_id": "5e0f36b63ccda26295505f0d",
        "participant_id": "5c83c95d4c266300156edc01"
      }
    ]
  },
  "properties": {
    "results": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "63063d07691a81e96a6e8494"
          },
          "sections": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "questions": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "answers": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "value": {
                              "type": "string",
                              "example": "Yes"
                            },
                            "answer_id": {
                              "type": "string",
                              "example": "c72d8cf9-5429-40ae-ac74-10041ed68824"
                            }
                          }
                        }
                      },
                      "question_id": {
                        "type": "string",
                        "example": "3797222e-f731-4bea-838b-f668682d902d"
                      },
                      "question_title": {
                        "type": "string",
                        "example": "Do you like ice cream?"
                      }
                    }
                  }
                },
                "section_id": {
                  "type": "string",
                  "example": "75ac961f-d94a-4490-af8f-935ca088315f"
                }
              }
            }
          },
          "date_created": {
            "type": "string",
            "example": "2022-08-24T15:00:23.325000"
          },
          "date_modified": {
            "type": "string",
            "example": "2022-08-24T15:00:23.325000"
          },
          "submission_id": {
            "type": "string",
            "example": "63063cfc71fd74aad90886c4"
          },
          "participant_id": {
            "type": "string",
            "example": "5c83c95d4c266300156edc01"
          }
        }
      }
    }
  }
}
object UpdateFilterSet
{
  "type": "object",
  "example": [
    {
      "name": "Left-handed 30-somethings",
      "filters": [
        {
          "id": "handedness",
          "selected_values": [
            "1"
          ]
        },
        {
          "id": "age",
          "selected_range": {
            "lower": 30,
            "upper": 39
          }
        }
      ]
    }
  ],
  "properties": {
    "name": {
      "type": "string",
      "description": "Name of the filter set."
    },
    "filters": {
      "type": "array",
      "items": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/SelectFilter"
          },
          {
            "$ref": "#/components/schemas/RangeFilter"
          }
        ]
      },
      "description": "List of all filters contained in the filter set."
    }
  }
}
object User
{
  "type": "object",
  "required": [
    "email",
    "id"
  ],
  "properties": {
    "id": {
      "type": "string"
    },
    "email": {
      "type": "string"
    }
  },
  "additionalProperties": true
}
object Workspace
{
  "type": "object",
  "example": {
    "id": "62fce6fff0a78eb4f3ebc09cX",
    "owner": "60a42f4c693c29420793cb73",
    "title": "My workspace",
    "users": [
      {
        "id": "60a42f4c693c29420793cb73X",
        "name": "Joe Soap",
        "email": "joe.soap@gmail.com",
        "roles": [
          "WORKSPACE_ADMIN"
        ]
      }
    ],
    "wallet": "61a65c06b084910b3f0c00d6",
    "projects": [
      {
        "id": "60a42f4c693c29420793cb73X"
      }
    ],
    "description": "This workspace does..."
  },
  "required": [
    "id",
    "title"
  ],
  "properties": {
    "id": {
      "type": "string",
      "description": "Workspace id. It is created by Prolific."
    },
    "owner": {
      "type": "string",
      "description": "Workspace id. It is created by Prolific."
    },
    "title": {
      "type": "string",
      "description": "Name of workspace"
    },
    "users": {
      "type": "array",
      "items": {
        "$ref": "#/components/schemas/WorkspaceUser"
      },
      "description": "Data for a user related to a workspace"
    },
    "wallet": {
      "type": "string",
      "description": "Wallet tied to workspace"
    },
    "projects": {
      "type": "array",
      "items": {
        "$ref": "#/components/schemas/ProjectShort"
      },
      "description": "Data for a project related to a workspace"
    },
    "description": {
      "type": "string",
      "description": "What is this workspace used for"
    },
    "naivety_distribution_rate": {
      "type": "number",
      "maximum": 1,
      "minimum": 0,
      "nullable": true,
      "description": "The rate at which the studies within this workspace are distributed."
    }
  },
  "additionalProperties": true
}
object WorkspaceBalance
{
  "type": "object",
  "example": {
    "currency_code": "GBP",
    "total_balance": 630,
    "available_balance": 210,
    "balance_breakdown": {
      "vat": 30,
      "fees": 150,
      "rewards": 450
    },
    "available_balance_breakdown": {
      "vat": 10,
      "fees": 50,
      "rewards": 150
    }
  },
  "properties": {
    "currency_code": {
      "type": "string",
      "description": "The currency used for all financial transactions within the workspace."
    },
    "total_balance": {
      "type": "integer",
      "description": "The total balance of the workspace, including funds which have already been assigned to active studies.\n\nAll monetary values are shown in the sub-currency of your workspace currency (e.g. pence, cents)."
    },
    "available_balance": {
      "type": "integer",
      "description": "The remaining balance of your workspace which is available to spend, after removing funds assigned to already active studies, etc."
    },
    "balance_breakdown": {
      "type": "object",
      "description": "A breakdown of the total balance of the workspace into:\n- Funds available to pay to participants\n- Funds pre-paid to Prolific for our services\n- Funds for any VAT applied to our service fees"
    },
    "available_balance_breakdown": {
      "type": "object",
      "description": "A breakdown of the available balance of the workspace into:\n- Funds available to pay to participants\n- Funds pre-paid to Prolific for our services\n- Funds for any VAT applied to our service fees"
    }
  }
}
object WorkspaceShort
{
  "type": "object",
  "example": {
    "id": "62fce6fff0a78eb4f3ebc09cX",
    "owner": "60a42f4c693c29420793cb73",
    "title": "My workspace",
    "users": [
      {
        "id": "60a42f4c693c29420793cb73X",
        "name": "Joe Soap",
        "email": "joe.soap@gmail.com",
        "roles": [
          "WORKSPACE_ADMIN"
        ]
      }
    ],
    "description": "This workspace does...",
    "naivety_distribution_rate": 0.5
  },
  "required": [
    "id",
    "title"
  ],
  "properties": {
    "id": {
      "type": "string",
      "description": "Workspace id. It is created by Prolific."
    },
    "owner": {
      "type": "string",
      "description": "User id of the creator of the workspace. It is created by Prolific."
    },
    "title": {
      "type": "string",
      "description": "Name of workspace"
    },
    "users": {
      "type": "array",
      "items": {
        "$ref": "#/components/schemas/WorkspaceUser"
      },
      "description": "Data for all users who have access to this workspace"
    },
    "description": {
      "type": "string",
      "description": "What is this workspace used for"
    },
    "naivety_distribution_rate": {
      "type": "number",
      "maximum": 1,
      "minimum": 0,
      "nullable": true,
      "description": "The rate at which the studies within this project are distributed."
    }
  },
  "additionalProperties": true
}
object WorkspaceUser
{
  "type": "object",
  "required": [
    "id"
  ],
  "properties": {
    "id": {
      "type": "string",
      "description": "Id of user"
    },
    "name": {
      "type": "string",
      "description": "Name of user"
    },
    "email": {
      "type": "string",
      "description": "email of user"
    },
    "roles": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "User roles in workspace"
    }
  }
}
object WorkspacesListResponse
{
  "type": "object",
  "required": [
    "results"
  ],
  "properties": {
    "results": {
      "type": "array",
      "items": {
        "$ref": "#/components/schemas/WorkspaceShort"
      },
      "description": "List of all workspaces for user"
    }
  },
  "additionalProperties": true
}