---
openapi: 3.0.3
info:
  title: Wallet API
  description: This API allows CRUD operations on Wallet.
  contact:
    name: '@TRatolojanahary'
    email: tratolojanahary@projetlineaire.com
  version: "0.1"
security:
- SecurityScheme: []
tags:
- name: Wallet
  description: Anybody interested in Wallet.
- name: Version
- name: session
  description: "API resource for session: user authentification, read and update user\
    \ profile."
- name: Program
- name: user-management
  description: API resource for managing user.
- name: Internal-API
- name: GanttOnlineError
paths:
  /broadcast:
    get:
      tags:
      - Notifier Ressource
      summary: Broadcast notifier for live update.
      description: "Return in live, type, id, hashcode and if possible url access\
        \ for all updated objects in database. Trying with google chrome."
      responses:
        "200":
          description: Successful operation.
          content:
            text/event-stream:
              schema:
                example: classname:id:hashcode:url
  /broadcast-delay:
    get:
      tags:
      - Notifier Ressource
      summary: Broadcast notifier for delay update.
      description: "Return in  2 seconds, type, id, hashcode and if possible url access\
        \ for all updated objects in database. Trying with google chrome."
      responses:
        "200":
          description: Successful operation.
          content:
            text/event-stream:
              schema:
                example: classname:id:hashcode:url
  /errors:
    get:
      tags:
      - GanttOnlineError
      summary: Display all error type
      description: All error type listed.
      responses:
        "200":
          description: OK
  /program:
    get:
      tags:
      - Program
      summary: Get Programs.
      description: Get all programs.
      responses:
        "200":
          description: Successful operation.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/ProgramResponseDTO'
    post:
      tags:
      - Program
      summary: Create a new program.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ProgramRequestDTO'
      responses:
        "201":
          description: Program successfully created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProgramResponseDTO'
        "422":
          description: Required field empty.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GanttOnlineError'
  /program/authorized:
    get:
      tags:
      - Program
      summary: Get current (connected) user Programs.
      description: Get all programs that the connected user has access.
      responses:
        "200":
          description: Successful operation.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/ProgramResponseDTO'
  /program/{programId}:
    get:
      tags:
      - Program
      summary: Get Program.
      description: Get the logo of a program in base 64 format.
      parameters:
      - name: programId
        in: path
        required: true
        schema:
          format: int64
          type: integer
      responses:
        "200":
          description: Successful operation.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProgramResponseDTO'
    delete:
      tags:
      - Program
      summary: Delete Program.
      description: Delete a program.
      parameters:
      - name: programId
        in: path
        required: true
        schema:
          format: int64
          type: integer
      responses:
        "200":
          description: Program successfully deleted.
  /program/{programId}/info:
    put:
      tags:
      - Program
      summary: Update Program.
      description: Update the information of a program.
      parameters:
      - name: programId
        in: path
        required: true
        schema:
          format: int64
          type: integer
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ProgramInfoRequestDTO'
      responses:
        "200":
          description: Program information successfully updated.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProgramResponseDTO'
        "422":
          description: Required field empty.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GanttOnlineError'
  /program/{programId}/logo:
    get:
      tags:
      - Program
      summary: Get Logo
      description: Get the logo of a program in base 64 format
      parameters:
      - name: programId
        in: path
        required: true
        schema:
          format: int64
          type: integer
      responses:
        "200":
          description: Successful operation.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProgramLogoResponseDTO'
    put:
      tags:
      - Program
      summary: Update Program.
      description: Update the logo of a program.
      parameters:
      - name: programId
        in: path
        required: true
        schema:
          format: int64
          type: integer
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ProgramLogoRequestDTO'
      responses:
        "200":
          description: Program logo successfully updated.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProgramResponseDTO'
    delete:
      tags:
      - Program
      summary: Remove the logo of a program.
      description: Remove the logo of a program.
      parameters:
      - name: programId
        in: path
        required: true
        schema:
          format: int64
          type: integer
      responses:
        "200":
          description: Program logo successfully removed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProgramResponseDTO'
  /program/{programId}/members:
    get:
      tags:
      - Program
      summary: Get program members.
      description: Get all the user member of the specified program.
      parameters:
      - name: programId
        in: path
        required: true
        schema:
          format: int64
          type: integer
      responses:
        "200":
          description: Successful operation.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/UserInfoTO'
  /program/{programId}/subscribe-user:
    put:
      tags:
      - Program
      summary: Subscribe user to a Program.
      description: "Subscribe user to a Program. \n The user must be initialized manually\
        \ in the User service of the program, by calling the route 'http(s)://USER_PROGRAM_SERVICE_URL/users/user/init-user'"
      parameters:
      - name: programId
        in: path
        required: true
        schema:
          format: int64
          type: integer
      requestBody:
        description: ID of the user to be subscribed
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SubscribeUserRequestDTO'
      responses:
        "200":
          description: User subscribed to Program successfully.
  /program/{programId}/unsubscribe-user:
    put:
      tags:
      - Program
      summary: Unsubscribe user from a Program.
      parameters:
      - name: programId
        in: path
        required: true
        schema:
          format: int64
          type: integer
      requestBody:
        description: ID of the user to be unsubscribed
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SubscribeUserRequestDTO'
      responses:
        "200":
          description: User unsubscribed from Program successfully.
  /sessions:
    post:
      tags:
      - session
      summary: Login
      description: Login endpoint for getting Access Token
      requestBody:
        description: Contains the email and the password of the user to authenticate
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LoginRequestDTO'
      responses:
        "200":
          description: User successfully logged in
          content:
            application/json:
              schema:
                type: object
                example:
                  access_token: 3eUJGNU01WkQzMk01UXJnIn0
                  expires_in: 3600.0
                  refresh_expires_in: 1800.0
                  refresh_token: eyJhbGciOiJIUzI1NiIsInR5
                  token_type: Bearer
                  not-before-policy: 0.0
                  session_state: d627b527-342d-4dfe-8348-a42809c2cdef
                  scope: email profile
        "401":
          description: "Failed to log the user in, Invalid Password or Email"
          content:
            application/json:
              schema:
                type: object
                example:
                - message:
                    chars: string
                    string: string
                    valueType: STRING
    delete:
      tags:
      - session
      summary: Log the user out
      description: Invalidate the session of the user
      responses:
        "200":
          description: Session invalidated successfully
        "422":
          description: Invalid refresh_token
          content:
            application/json:
              schema:
                type: object
                example:
                - message:
                    chars: string
                    string: string
                    valueType: STRING
  /sessions/password:
    put:
      tags:
      - session
      summary: Update user password
      description: "Update the user password when he is logged in, can only be used\
        \ with user's access_token"
      requestBody:
        description: "Contains the current password, the new and the confirmation"
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdatePasswordRequestDTO'
      responses:
        "200":
          description: Password updated successfully
        "422":
          description: Invalid password
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  timestamp:
                    format: int64
                    type: integer
                  code:
                    format: int32
                    type: integer
                  type:
                    type: string
                  info:
                    type: string
                  value:
                    type: string
  /sessions/password/forgotten:
    post:
      tags:
      - session
      summary: Send link to reset user's password
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PasswordResetRequestDTO'
      responses:
        "200":
          description: Reset link sent successfully
        "404":
          description: No user found with the specified mail
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GanttOnlineError'
  /sessions/profile:
    get:
      tags:
      - session
      responses:
        "200":
          description: OK
    put:
      tags:
      - session
      summary: Update user profile
      requestBody:
        description: New profile values.
        content:
          application/json:
            schema:
              type: object
              properties:
                firstName:
                  type: string
                lastName:
                  type: string
                phoneNumber:
                  type: string
                company:
                  type: string
                notes:
                  type: string
                readOnly:
                  type: boolean
                enable:
                  type: boolean
      responses:
        "201":
          description: Successful operation.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserInfoResponseDTO'
        "422":
          description: Invalid values
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GanttOnlineError'
        "401":
          description: Unauthorized access.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GanttOnlineError'
  /sessions/refresh:
    post:
      tags:
      - session
      summary: Refresh Token
      description: "Access Token may expire, refresh access token with this endpoint"
      requestBody:
        description: Contains the refresh_token to get the fresh new access_token
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RefreshTokenRequestDTO'
      responses:
        "200":
          description: User successfully refreshed in
          content:
            application/json:
              schema:
                type: object
                example:
                  access_token: 3eUJGNU01WkQzMk01UXJnIn0
                  expires_in: 3600.0
                  refresh_expires_in: 1800.0
                  refresh_token: eyJhbGciOiJIUzI1NiIsInR5
                  token_type: Bearer
                  not-before-policy: 0.0
                  session_state: d627b527-342d-4dfe-8348-a42809c2cdef
                  scope: email profile
        "422":
          description: Invalid Refresh Token
          content:
            application/json:
              schema:
                type: object
                example:
                - message:
                    chars: string
                    string: string
                    valueType: STRING
  /sessions/user-groups:
    get:
      tags:
      - session
      responses:
        "200":
          description: OK
  /user:
    post:
      tags:
      - user-management
      summary: Create and save a new user
      requestBody:
        description: New user values.
        content:
          application/json:
            schema:
              type: object
              properties:
                firstName:
                  type: string
                lastName:
                  type: string
                email:
                  type: string
                phoneNumber:
                  type: string
                company:
                  type: string
                notes:
                  type: string
                password:
                  type: string
                enable:
                  type: boolean
                readOnly:
                  type: boolean
      responses:
        "201":
          description: Successful operation.
          headers:
            location:
              description: url for access to folder
              style: simple
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserInfoResponseDTO'
        "422":
          description: 'Invalid name | Folder already exist | Folder too deep '
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GanttOnlineError'
        "401":
          description: Unauthorized access.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GanttOnlineError'
  /user/all:
    get:
      tags:
      - Internal-API
      summary: Get all users from Keycloak
      responses:
        "200":
          description: OK
  /user/available-groups:
    get:
      tags:
      - user-management
      responses:
        "200":
          description: OK
  /user/is-pl-admin:
    get:
      tags:
      - user-management
      summary: User admin.
      description: Check if current user is a PL admin.
      responses:
        "200":
          description: Successful operation.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserPLAdminResponseDTO'
  /user/{userId}:
    get:
      tags:
      - user-management
      summary: Get a user by his id
      description: Return a user.
      parameters:
      - name: userId
        in: path
        required: true
        schema:
          type: string
      responses:
        "200":
          description: Successful operation.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserInfoTO'
        "404":
          description: Id not found. The entity doesn't exist.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GanttOnlineError'
        "401":
          description: Unauthorized access.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GanttOnlineError'
    put:
      tags:
      - user-management
      summary: Modify an user
      parameters:
      - name: userId
        in: path
        required: true
        schema:
          type: string
      requestBody:
        description: New user values.
        content:
          application/json:
            schema:
              type: object
              properties:
                firstName:
                  type: string
                lastName:
                  type: string
                phoneNumber:
                  type: string
                company:
                  type: string
                notes:
                  type: string
                readOnly:
                  type: boolean
                enable:
                  type: boolean
      responses:
        "201":
          description: Successful operation.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserInfoResponseDTO'
        "422":
          description: Invalid values
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GanttOnlineError'
        "401":
          description: Unauthorized access.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GanttOnlineError'
  /version:
    get:
      tags:
      - Version
      summary: Get micro service version
      description: Get version number of micro service.
      responses:
        "200":
          description: OK
          content:
            text/plain:
              schema:
                type: number
components:
  schemas:
    GanttOnlineError:
      type: object
      properties:
        success:
          type: boolean
        timestamp:
          format: int64
          type: integer
        code:
          format: int32
          type: integer
        type:
          type: string
        info:
          type: string
        value:
          type: string
    LoginRequestDTO:
      type: object
      properties:
        email:
          type: string
        password:
          type: string
    PasswordResetRequestDTO:
      type: object
      properties:
        email:
          type: string
    ProgramInfoRequestDTO:
      type: object
      properties:
        name:
          type: string
        company:
          type: string
        description:
          type: string
        domainArea:
          type: string
        url:
          type: string
    ProgramLogoRequestDTO:
      type: object
      properties:
        logo:
          type: string
    ProgramLogoResponseDTO:
      type: object
      properties:
        logo:
          type: string
    ProgramRequestDTO:
      type: object
      properties:
        name:
          type: string
        company:
          type: string
        description:
          type: string
        domainArea:
          type: string
        url:
          type: string
        logo:
          type: string
    ProgramResponseDTO:
      type: object
      properties:
        id:
          format: int64
          type: integer
        name:
          type: string
        company:
          type: string
        description:
          type: string
        domainArea:
          type: string
        url:
          type: string
    RefreshTokenRequestDTO:
      type: object
      properties:
        refreshToken:
          type: string
    SubscribeUserRequestDTO:
      type: object
      properties:
        userId:
          type: string
    UpdatePasswordRequestDTO:
      type: object
      properties:
        oldPassword:
          type: string
        newPassword1:
          type: string
        newPassword2:
          type: string
    UserInfoResponseDTO:
      type: object
      properties:
        company:
          type: string
        email:
          type: string
        enable:
          type: boolean
        firstName:
          type: string
        lastName:
          type: string
        notes:
          type: string
        phoneNumber:
          type: string
        readOnly:
          type: boolean
        userId:
          type: string
    UserInfoTO:
      type: object
      properties:
        userId:
          type: string
        firstName:
          type: string
        lastName:
          type: string
        email:
          type: string
        phoneNumber:
          type: string
        company:
          type: string
        notes:
          type: string
        readOnly:
          type: boolean
        enable:
          type: boolean
        password:
          type: string
    UserPLAdminResponseDTO:
      type: object
      properties:
        isPLAdmin:
          type: boolean
        pLAdmin:
          type: boolean
  securitySchemes:
    SecurityScheme:
      type: openIdConnect
      description: Authentication
      openIdConnectUrl: https://keycloak.ganttmanager.fr/realms/GanttOnline/.well-known/openid-configuration
