# Events Requirements
## Model
We need to have an `Event` model like this:
```
title : string!
start : Date!
end : Dat!
scope : "Personal" | "Organization"
relatedTeams : [Team!]
organizationId : ID!
... other fields
```
Each event is related to a single `organization` and may be restricted to few teams, or global to all arganization.
If the `relatedTeams` array is filled, it means that the event is restricted to defined teams, otherwise, the event is accessible by all teams.
---
## Create / Update Event
### Input
An event object will be passed.
### Output
The created event
---
## Query events
By using this query we can get all events related to a single organization
### Input
1. userIds : [ID!] **Optional**
> When `userIds` is set, it means that we want to fetch, all `Personal` events that the creator id is in given array.
2. organizationId : ID! **Required**
> Determines which organization, should the query fetches the events from.
3. teamIds : [ID!] **Optional**
> Determines to fetch events *eighter* doesn't have `relatedTeams` *or* their `relatedTeams` includes at least one of mentioned teamIds.
4. containOrgEvents : boolean! **Required**
> Determines that if this query must fetch `Organization` scope events too or not.
5. start : Date **Optional**
6. end : Date **Optional**
### Output
corresponding requested events
---
## Get Events By Team
Perhaps, it would be better to rename this API to *timeline* for clarity. Right?
Fetches all users of given teams along side their events.
### Input
1. organizationId : ID! **Required**
> From which organization, the timeline data must be provided.
2. teamIds : [ID!]! **Required**
> Determines from which teams, the timeline data should be gathered. This statement has two meanings:
> 1. Which users should be fetched and disticted.
> 2. Which events of their **`Personal`** events should be fetched. Please take a look at *input* section of *Query events* API definition, to figure out how to match the `teamIds`.
3. start : Date **Optional**
4. end : Date **Optional**
### Output
Corresponding `TeamEvent[]`.
---
## Get EventsCongestions
Provides event congestions for given teams and users, based on `Personal` events.
### Input
1. organizationId : ID! **Required**
> Determines, using which organization's events the output must be provided.
2. userIds : [ID!] **Optional**
> Determines for whom this congestion data should be provided.
3. teamIds : [ID!] **Optional**
> Instead of sending user ids, the client can request teams. This way, the API fills and disticts the `userIds` array.
4. start : Date! **Required**
5. end : Date! **Required**
### Output
Corresponding `EventsCongestion` data.