openapi: 3.0.3

info:
  title: API for account data backup
  description: Title
  version: 1.0.0

servers:
  - url: 'https'

paths:
  /api/{accountId}/allData:
    get:
      summary: Get all account data
      parameters:
        - in: path
          name: accountId
          description: Account's UUID
          schema:
            type: string
            format: uuid
          example: 18d5acd0-a116-4b87-ab4f-0cc956c26e25
          required: true

      responses:
        200:
          description: Successful operation
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AllAccountData"

components:
  schemas:
    # ----- Account -----

    AllAccountData:
      description: All account data
      type: object
      properties:
        id:
          $ref: "#/components/schemas/Id"

        owner:
          $ref: "#/components/schemas/AccountOwner"

        teams:
          description: Teams
          type: array
          items:
            $ref: "#/components/schemas/AccountTeam"

        communities:
          description: Communities
          type: array
          items:
            $ref: "#/components/schemas/AccountCommunity"

        projects:
          description: Projects
          type: array
          items:
            $ref: "#/components/schemas/Project"

      required:
        - id
        - owner
        - teams
        - communities
        - projects

    AccountOwner:
      description: Account owner data
      type: object
      properties:
        id:
          $ref: "#/components/schemas/Id"

        email:
          description: E-mail
          type: string
          format: email
          example: example@example.com

        phone:
          description: Phone
          type: string
          example: 18007778855

        person:
          $ref: "#/components/schemas/AccountPerson"

        data:
          $ref: "#/components/schemas/PersonData"

      required:
        - id
        - email
        - person
        - data

    AccountTeam:
      allOf:
        - $ref: "#/components/schemas/Team"
        - description: Account's Team
          type: object
          properties:
            community:
              $ref: "#/components/schemas/TeamCommunity"

            tariff:
              $ref: "#/components/schemas/TeamTariff"

    TeamCommunity:
      description: Team community
      type: object
      properties:
        id:
          $ref: "#/components/schemas/Id"

        title:
          description: Community title
          type: string
          example: The pirates

      required:
        - id
        - title

    # ----- Person -----

    AccountPerson:
      description: Account person data
      type: object
      properties:
        id:
          $ref: "#/components/schemas/Id"

        name:
          description: Full name
          type: string
          example: Sarah Connor

        firstname:
          description: First name
          type: string
          example: Connor

        lastname:
          description: Last name
          type: string
          example: Sarah

        nickname:
          description: Nickname
          type: string
          example: Sarah J. Connor

        sex:
          description: Sex
          type: string
          enum:
            - male
            - female
            - other
          example: other

        birthday:
          description: Birthday in the YYYY-MM-DD format
          type: string
          format: date
          example: 2022-05-31

        status:
          description: Status
          type: string
          enum:
            - active
            - banned
            - removed
          example: active

      required:
        - id
        - name
        - sex
        - status

    PersonData:
      description: Person data
      type: object
      properties:
        contacts:
          description: Person's contacts
          type: array
          items:
            $ref: "#/components/schemas/PersonContact"

        specializations:
          description: Specializations
          type: array
          items:
            $ref: "#/components/schemas/PersonSpecialization"

        baseSkills:
          description: Base skills
          type: array
          items:
            $ref: "#/components/schemas/PersonBaseSkill"

        businessScopes:
          description: Business scopes
          type: array
          items:
            $ref: "#/components/schemas/PersonBusinessScope"

        businessSubscopes:
          description: Business sub scopes
          type: array
          items:
            $ref: "#/components/schemas/PersonBusinessSubscope"

        communities:
          description: Communities with this person
          type: array
          items:
            $ref: "#/components/schemas/PersonCommunity"

        teams:
          description: Teams with this person
          type: array
          items:
            $ref: "#/components/schemas/PersonTeam"

        friendTeams:
          description: Person's friend teams
          type: array
          items:
            $ref: "#/components/schemas/PersonFriendTeam"

        friendPersons:
          description: Person's friend persons
          type: array
          items:
            $ref: "#/components/schemas/PersonFriendPerson"

        favoriteTeams:
          description: Person's favorite teams
          type: array
          items:
            $ref: "#/components/schemas/PersonFavoriteTeam"

        favoritePersons:
          description: Person's favorite persons
          type: array
          items:
            $ref: "#/components/schemas/PersonFavoritePerson"

        certificates:
          description: Person's certificates
          type: array
          items:
            $ref: "#/components/schemas/PersonCertificate"

        skills:
          description: Person's skills
          type: array
          items:
            $ref: "#/components/schemas/PersonSkill"

        projects:
          description: Person's projects
          type: array
          items:
            allOf:
              - $ref: "#/components/schemas/Id"
              - description: Project Id

        jobs:
          description: Person's jobs
          type: array
          items:
            $ref: "#/components/schemas/PersonJob"

        educations:
          description: Person's educations
          type: array
          items:
            $ref: "#/components/schemas/PersonEducation"

        courses:
          description: Person's courses
          type: array
          items:
            $ref: "#/components/schemas/PersonCourse"

        currentLocation:
          allOf:
            - $ref: "#/components/schemas/PersonLocation"
            - description: Person's current location

        locations:
          description: Person's locations
          type: array
          items:
            $ref: "#/components/schemas/PersonLocation"

        languages:
          description: Person's languages
          type: array
          items:
            $ref: "#/components/schemas/PersonLanguage"

      required:
        - contacts
        - communities
        - teams
        - friendPersons
        - friendTeams
        - favoritePersons
        - favoriteTeams
        - skills

    PersonContact:
      $ref: "#/components/schemas/Contact"

    PersonSpecialization:
      description: Contact info
      type: object
      properties:
        id:
          $ref: "#/components/schemas/Id"

        title:
          description: Symfony 6 Developer
          type: string
          example: Facebook

        desireLevel:
          description: Person's desires to the work by specialization
          type: string
          enum:
            - high
            - medium
            - low
          example: high

        responsibilityLevel:
          description: Responsibility level
          type: string
          enum:
            - intern  # Cannot complete tasks
            - junior  # Needs guidance to works on tasks
            - middle  # Works on tasks independently
            - senior  # Makes decisions and calculates it deadlines and payback
            - leader  # Leadership to a team
          example: senior

      required:
        - id
        - title
        - wishLevel
        - responsibilityLevel

    PersonBaseSkill:
      description: Base skill
      type: object
      properties:
        id:
          $ref: "#/components/schemas/Id"

        title:
          description: Title
          type: string
          example: Symfony

        monthCount:
          description: Months of experience
          type: integer
          example: 14

      required:
        - id
        - title
        - monthCount

    PersonBusinessScope:
      description: Business scope
      type: object
      properties:
        id:
          $ref: "#/components/schemas/Id"

        title:
          description: Title
          type: string
          example: Logistics

        monthCount:
          description: Months of experience
          type: integer
          example: 14

      required:
        - id
        - title
        - monthCount

    PersonBusinessSubscope:
      description: Subscope of a business scope
      type: object
      properties:
        id:
          $ref: "#/components/schemas/Id"

        title:
          description: Title
          type: string
          example: Warehouses in logistics

        monthCount:
          description: Months of experience
          type: integer
          example: 14

      required:
        - id
        - title
        - monthCount

    PersonCommunity:
      description: Community with this person
      type: object
      properties:
        id:
          $ref: "#/components/schemas/Id"

        title:
          description: Community title
          type: string
          example: Open source

        status:
          $ref: "#/components/schemas/MemberStatus"

      required:
        - id
        - title
        - status

    PersonTeam:
      description: Team with this person
      type: object
      properties:
        id:
          $ref: "#/components/schemas/Id"

        title:
          description: Team title
          type: string
          example: The pirates

        status:
          $ref: "#/components/schemas/MemberStatus"

      required:
        - id
        - title
        - status

    PersonFriendTeam:
      description: Person's friend team
      type: object
      properties:
        id:
          $ref: "#/components/schemas/Id"

        title:
          description: Team title
          type: string
          example: The pirates

        status:
          description: >
            The link status:
            `active` - active relation,
            `suspended` - suspended because it relation exceeds tariff limit,
            `delinked_by_person` - relation ripped by the person,
            `delinked_by_team` - relation ripped by the team
          type: string
          enum:
            - active
            - suspended
            - delinked_by_person
            - delinked_by_team
          example: active

      required:
        - id
        - title
        - status

    PersonFriendPerson:
      description: Person's friend person
      type: object
      properties:
        id:
          $ref: "#/components/schemas/Id"

        name:
          description: Friend name
          type: string
          example: Sarah Connor

        status:
          description: >
            The link status:
            `active` - active relation,
            `delinked_by_person` - relation ripped by the person,
            `delinked_by_friend` - relation ripped by the friend
          type: string
          enum:
            - active
            - delinked_by_person
            - delinked_by_friend
          example: active

      required:
        - id
        - name
        - status

    PersonFavoriteTeam:
      description: Person's favorite team
      type: object
      properties:
        id:
          $ref: "#/components/schemas/Id"

        title:
          description: Team title
          type: string
          example: The pirates

      required:
        - id
        - title

    PersonFavoritePerson:
      description: Person's favorite person
      type: object
      properties:
        id:
          $ref: "#/components/schemas/Id"

        name:
          description: Friend name
          type: string
          example: Sarah Connor

      required:
        - id
        - name

    PersonCertificate:
      description: Person's certificate
      type: object
      properties:
        id:
          $ref: "#/components/schemas/Id"

        title:
          description: Title
          type: string
          example: Symfony 6 Certified Developer

        issuer:
          description: Issuer
          type: string
          example: SensioLabs

        url:
          description: Url
          type: string
          example: https://certification.php-fpm.com/exams/php-fpm.html

        date:
          description: Date
          type: string
          example: "2022-04-30"

        issuedAt:
          description: Date
          type: string
          example: "2022-04-30"

        expirationDate:
          description: Date
          type: string
          example: "2022-04-30"

      required:
        - id
        - title
        - issuer
        - issuedAt

    PersonSkill:
      description: Person's skill
      type: object
      properties:
        id:
          $ref: "#/components/schemas/Id"

        title:
          description: Skill title
          type: string
          example: Spring Java

        currentLevel:
          allOf:
            - $ref: "#/components/schemas/SkillLevel"
            - description: Current skill level

        maxLevel:
          allOf:
            - $ref: "#/components/schemas/SkillLevel"
            - description: Max historical skill level

        targetLevel:
          allOf:
            - $ref: "#/components/schemas/SkillLevel"
            - description: Target skill level

        fromYear:
          description: First year for practice with this skill
          type: integer
          example: 2018

        toYear:
          description: Last year for practice with this skill
          type: integer
          example: 2021

        comments:
          description: Comments about skill's details
          type: string
          example: Many works with Oracle and XML

      required:
        - id
        - title
        - currentLevel
        - maxLevel
        - targetLevel

    PersonJob:
      description: Person's job
      type: object
      properties:
        id:
          $ref: "#/components/schemas/Id"

        companyName:
          description: Company name
          type: string
          example: New Crypto Technology, Ltd

        title:
          description: Job title
          type: string
          example: Senior Symfony Developer

        employmentType:
          description: Employment type
          type: string
          enum:
            - full
            - partial
            - entrepreneur
            - freelance
            - contract
            - internship
            - education
          example: full

        workplaceType:
          description: Workplace type
          type: string
          enum:
            - office
            - hybrid
            - remote
          example: remote

        location:
          description: Where job place was located
          type: string
          example: San Jose, Silicon Valley, CA

        startDate:
          description: Year and month when the job being started
          type: string
          example: 2020-09

        endDate:
          description: Year and month when the job being ended
          type: string
          example: 2024-01

        description:
          description: Job and worker's role description
          type: string
          example: Main backend developer

      required:
        - id
        - companyName
        - jobTitle
        - employmentType
        - workplaceType
        - startDate

    PersonEducation:
      description: Person's education
      type: object
      properties:
        id:
          $ref: "#/components/schemas/Id"

        organization:
          description: Organization name
          type: string
          example: Stanford University

        level:
          description: Education level or degree
          type: string
          example: Magister

        specialization:
          description: Specialization
          type: string
          example: Systems engineering

        startYear:
          description: Start year of study
          type: integer
          example: 2014

        endYear:
          description: Year of completion of studies
          type: integer
          example: 2018

      required:
        - id
        - organization
        - startYear

    PersonCourse:
      description: Person's education
      type: object
      properties:
        id:
          $ref: "#/components/schemas/Id"

        title:
          description: Course title
          type: string
          example: Introduction to Go Programming Language

        organization:
          description: Organization name
          type: string
          example: Go Coders Education

        author:
          description: Course's author
          type: string
          example: Alisa Wonderman

        specialization:
          description: Specialization
          type: string
          example: Software engineering

        url:
          description: Url to course's description page
          type: string
          example: https://example.com/courses/go

        year:
          description: Year of studies
          type: integer
          example: 2021

      required:
        - id
        - title
        - specialization
        - year

    PersonLocation:
      type: object
      properties:
        id:
          $ref: "#/components/schemas/Id"

        address:
          description: Address
          type: string
          example: San Jose, Silicon Valley, CA

      required:
        - id
        - address

    PersonLanguage:
      description: Language levels by CEFR
      type: object
      properties:
        id:
          $ref: "#/components/schemas/Id"

        name:
          description: Language name
          type: string
          example: English

        writingLevel:
          description: Level of writing proficiency
          type: string
          enum:
            - A0  # Does not write
            - A1
            - A2
            - B1
            - B2
            - C1
            - C2
          example: C1

        readingLevel:
          description: Level of reading proficiency
          type: string
          enum:
            - A0  # Does not read
            - A1
            - A2
            - B1
            - B2
            - C1
            - C2
          example: C1

        listeningLevel:
          description: Level of listening proficiency
          type: string
          enum:
            - A0  # Does not listen
            - A1
            - A2
            - B1
            - B2
            - C1
            - C2
          example: C1

        speakingLevel:
          description: Level of speaking proficiency
          type: string
          enum:
            - A0  # Does not speak
            - A1
            - A2
            - B1
            - B2
            - C1
            - C2
          example: C1

      required:
        - id
        - name
        - writingLevel
        - readingLevel
        - listeningLevel
        - speakingLevel

    # ----- Team -----

    Team:
      type: object
      properties:
        id:
          $ref: "#/components/schemas/Id"

        title:
          description: Team title
          type: string
          example: The pirates

        description:
          description: Description
          type: string
          example: The best spring cloud team

        contacts:
          description: Contacts
          type: array
          items:
            $ref: "#/components/schemas/TeamContact"

        members:
          description: Members
          type: array
          items:
            $ref: "#/components/schemas/TeamMember"

        experts:
          description: Experts
          type: array
          items:
            $ref: "#/components/schemas/TeamExpert"

        friendPersons:
          description: Friend persons
          type: array
          items:
            $ref: "#/components/schemas/TeamFriendPerson"

        friendTeams:
          description: Friend teams
          type: array
          items:
            $ref: "#/components/schemas/TeamFriendTeam"

        favoritePersons:
          description: Favorite persons
          type: array
          items:
            $ref: "#/components/schemas/TeamFavoritePerson"

        favoriteTeams:
          description: Favorite teams
          type: array
          items:
            $ref: "#/components/schemas/TeamFavoriteTeam"

        teamSkills:
          description: Team skills
          type: array
          items:
            $ref: "#/components/schemas/TeamSkill"

        memberSkills:
          description: Member skills
          type: array
          items:
            $ref: "#/components/schemas/TeamMemberSkill"

        projects:
          description: Projects
          type: array
          items:
            $ref: "#/components/schemas/Project"

        tariff:
          $ref: "#/components/schemas/TeamTariff"

        isExpired:
          description: Is expired
          type: boolean
          example: false

        status:
          description: >
            Team status:
            `active` - active,
            `expired` - tariff expired,
            `suspended` - suspended because it team exceeds community tariff limit,
            `banned` - banned,
            `disbanded` - disbanded by team leader or community owner
          type: string
          enum:
            - active
            - expired
            - suspended
            - banned
            - disbanded
          example: active

      required:
        - id
        - title
        - contacts
        - members
        - experts
        - friendPersons
        - friendTeams
        - favoriteTeams
        - favoritePersons
        - teamSkills
        - memberSkills
        - isExpired
        - status

    TeamContact:
      $ref: "#/components/schemas/Contact"

    TeamMember:
      description: Team member
      type: object
      properties:
        id:
          $ref: "#/components/schemas/Id"

        name:
          description: Name
          type: string
          example: Sarah Connor

        comments:
          description: Comments
          type: string
          example: Leader in management

        isLeader:
          description: Is team leader
          type: boolean
          example: true

        status:
          $ref: "#/components/schemas/MemberStatus"

      required:
        - id
        - name
        - isLeader
        - status

    TeamExpert:
      description: Team expert
      type: object
      properties:
        id:
          $ref: "#/components/schemas/Id"

        name:
          description: Name
          type: string
          example: Sarah Connor

        comments:
          description: Comments
          type: string
          example: Leader in management

        status:
          $ref: "#/components/schemas/MemberStatus"

      required:
        - id
        - name
        - status

    TeamFriendPerson:
      description: Team`s friend person
      type: object
      properties:
        id:
          $ref: "#/components/schemas/Id"

        name:
          description: Name
          type: string
          example: Sarah Connor

      required:
        - id
        - name

    TeamFriendTeam:
      description: Team`s friend team
      type: object
      properties:
        id:
          $ref: "#/components/schemas/Id"

        title:
          description: Team title
          type: string
          example: The pirates

      required:
        - id
        - title

    TeamFavoritePerson:
      description: Team`s favorite person
      type: object
      properties:
        id:
          $ref: "#/components/schemas/Id"

        name:
          description: Name
          type: string
          example: Sarah Connor

      required:
        - id
        - name

    TeamFavoriteTeam:
      description: Team`s favorite team
      type: object
      properties:
        id:
          $ref: "#/components/schemas/Id"

        title:
          description: Team title
          type: string
          example: The pirates

      required:
        - id
        - title

    TeamSkill:
      description: Team skill
      type: object
      properties:
        id:
          $ref: "#/components/schemas/Id"

        title:
          description: Title
          type: string
          example: Team building

        level:
          description: Skill's level
          type: string
          enum:
            - lowest
            - low
            - medium
            - high
            - highest
          example: medium

        comments:
          description: Comments
          type: string
          example: Powerfull team building

      required:
        - id
        - title
        - level

    TeamMemberSkill:
      allOf:
        - description: Team member skill
        - $ref: "#/components/schemas/TeamSkill"

    TeamTariff:
      description: Tariff details for non community team
      type: object
      properties:
        type:
          description: Tariff type code
          type: string
          enum:
            - free
            - trial
            - standard
            - premium
          example: trial

        userLimit:
          description: User limit
          type: integer
          example: 15

        startedAt:
          description: Tariff started date and time
          type: string
          format: date-time
          example: "2021-01-30T08:30:00Z"

        expiredAt:
          description: Tariff expired date and time
          type: string
          format: date-time
          example: "2021-01-30T08:30:00Z"

        lastPaidAt:
          description: Last paid date and time
          type: string
          format: date-time
          example: "2021-01-30T08:30:00Z"

        isExpired:
          description: Is expired
          type: boolean
          example: false

      required:
        - type
        - userLimit
        - startedAt
        - isExpired

    # ----- Community -----

    AccountCommunity:
      description: Community
      type: object
      properties:
        id:
          $ref: "#/components/schemas/Id"

        title:
          description: Title
          type: string
          example: The pirates, Ltd

        type:
          description: Type
          type: string
          enum:
            - corporation
            - company
            - community
          example: company

        description:
          description: Description
          type: string
          example: The best outstaffing company

        linkedPersons:
          description: Linked persons
          type: array
          items:
            $ref: "#/components/schemas/CommunityLinkedPerson"

        teams:
          description: Teams
          type: array
          items:
            $ref: "#/components/schemas/CommunityTeam"

        projects:
          description: Projects
          type: array
          items:
            $ref: "#/components/schemas/Project"

        tariff:
          $ref: "#/components/schemas/CommunityTariff"

        isExpired:
          description: Is expired
          type: boolean
          example: false

        status:
          description: >
            Community status:
            `active` - active,
            `expired` - tariff expired,
            `banned` - banned,
            `disbanded` - disbanded by community owner
          type: string
          enum:
            - active
            - expired
            - banned
            - disbanded
          example: active

      required:
        - id
        - title
        - linkedPersons
        - teams
        - projects
        - tariff
        - isExpired
        - status

    CommunityLinkedPerson:
      description: Community member
      type: object
      properties:
        id:
          $ref: "#/components/schemas/Id"

        name:
          description: Name
          type: string
          example: Sarah Connor

        type:
          description: Type
          type: string
          enum:
            - member
            - expert
            - outsider
          example: member

        comments:
          description: Comments
          type: string
          example: Leader in management

        isOwner:
          description: Is community's account owner
          type: boolean
          example: true

        status:
          $ref: "#/components/schemas/MemberStatus"

      required:
        - id
        - name
        - type
        - isOwner
        - status

    CommunityTeam:
      $ref: "#/components/schemas/Team"

    CommunityTariff:
      description: Community tariff details
      type: object
      properties:
        type:
          description: Tariff type code
          type: string
          enum:
            - trial
            - standard
            - premium
          example: trial

        userLimit:
          description: User limit
          type: integer
          example: 15

        startedAt:
          description: Tariff started date and time
          type: string
          format: date-time
          example: "2021-01-30T08:30:00Z"

        expiredAt:
          description: Tariff expired date and time
          type: string
          format: date-time
          example: "2021-01-30T08:30:00Z"

        lastPaidAt:
          description: Last paid date and time
          type: string
          format: date-time
          example: "2021-01-30T08:30:00Z"

        isExpired:
          description: Is expired
          type: boolean
          example: false

      required:
        - type
        - userLimit
        - startedAt
        - isExpired

    # ----- Project -----

    Project:
      description: Project
      type: object
      properties:
        id:
          $ref: "#/components/schemas/Id"

        title:
          description: Project title
          type: string
          example: Spring Java

        members:
          description: Project members, if it is the team or the community related project
          type: array
          items:
            $ref: "#/components/schemas/ProjectMember"

        memberCount:
          description: Project member count
          type: integer
          example: 10

        startDate:
          description: Year and month when the project being started
          type: string
          example: 2023-09

        endDate:
          description: Year and month when the project being ended
          type: string
          example: 2024-01

        location:
          description: Where project team was located
          type: string
          example: Silicon Valley, CA

        description:
          description: Project summary
          type: string
          example: Large and long-term project for a market leader

      required:
        - id
        - title
        - members
        - memberCount
        - startDate

    ProjectMember:
      description: Person's project
      type: object
      properties:
        id:
          $ref: "#/components/schemas/Id"

        personId:
          allOf:
            - $ref: "#/components/schemas/Id"
            - description: Person Id

        roles:
          description: List of member's roles in the project
          type: array
          items:
            type: string
            example: backend

        startDate:
          description: Year and month when the member joined the project
          type: string
          example: 2023-09

        endDate:
          description: Year and month when the member completed work on the project
          type: string
          example: 2024-01

        description:
          description: Description member's role in the project
          type: string
          example: Main backend developer

      required:
        - id
        - personId
        - roles
        - startDate

    # ----- Common Fields -----

    Id:
      description: Entity Id
      type: string
      format: uuid
      example: 18d5acd0-a116-4b87-ab4f-0cc956c26e25

    SkillLevel:
      description: Skill's level. Skill level may be "not" if the person does not yet have the skill, but he wants to acquire this skill
      type: string
      enum:
        - not
        - lowest
        - low
        - medium
        - high
        - highest
      example: medium

    MemberStatus:
      description: >
        Member status:
        `active` - active,
        `suspended` - suspended because it member exceeds tariff limit,
        `behinded` - go away,
        `excluded` - excluded,
        `disbanded` - team or community was disbanded
      type: string
      enum:
        - active
        - suspended
        - behinded
        - excluded
        - disbanded
      example: active

    Contact:
      description: Contact info
      type: object
      properties:
        id:
          $ref: "#/components/schemas/Id"

        title:
          description: Title, accepted for types "web" and "link"
          type: string
          example: Facebook

        type:
          description: Type of contact
          type: string
          enum:
            - web
            - messenger
            - email
            - phone
          example: web

        link:
          description: Url for contact with type "web"
          type: string
          example: https://facebook.com/personAccount

        account:
          description: Account name for contact with type "messenger"
          type: string
          example: https://facebook.com/personAccount

        email:
          description: Email for contact with type "email"
          type: string
          example: example@email.com

        phone:
          description: Phone for contact with type "phone"
          type: string
          example: 18007778855

      required:
        - id
        - type
