openapi: '3.0.3'
info:
  title: MinoriClub API
  version: '1.0'
servers:
  - url: https://api.server.test/api/v1
paths:
  /register:
    post:
      summary: Sign up a user
      tags:
        - US-register
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                email:
                  type: string
                password:
                  type: string
      responses:
        '200':
          description: OK
        '400':
          description: Bad Request
        '409':
          description: Conflict
          content:
            application/json:
              schema:
                properties:
                  message:
                    type: string
                    example: 'Email already exists'
        '500':
          description: Internal Server Error
  /verified-email:
    post:
      summary: Confirm email
      tags:
        - US-register
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                email:
                  type: string
                pincode:
                  type: number
                  example: 123456
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                properties:
                  id:
                    type: string
                  access_token:
                    type: string
                  refresh_token:
                    type: string
        '400':
          description: Bad Request
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                properties:
                  message:
                    type: string
                    example: 'Pincode is incorrect'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                properties:
                  message:
                    type: string
                    example: 'Email not found'
        '500':
          description: Internal Server Error
  /resend-email:
    post:
      summary: Resend email
      tags:
        - US-register
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                email:
                  type: string
      responses:
        '200':
          description: OK
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                properties:
                  message:
                    type: string
                    example: 'Email not found'
        '500':
          description: Internal Server Error
  /login:
    post:
      summary: Sign in a user
      tags:
        - US-auth
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                email:
                  type: string
                password:
                  type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                properties:
                  id:
                    type: string
                  access_token:
                    type: string
                  refresh_token:
                    type: string
        '400':
          description: Bad Request
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                properties:
                  message:
                    type: string
                    example: 'Email or password is incorrect'
        '500':
          description: Internal Server Error
  /refresh-token:
    post:
      summary: Refresh token
      tags:
        - US-auth
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                id:
                  type: string
                refresh_token:
                  type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                properties:
                  access_token:
                    type: string
        '400':
          description: Bad Request
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                properties:
                  message:
                    type: string
                    example: 'Invalid token'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                properties:
                  message:
                    type: string
                    example: 'User not found'
        '500':
          description: Internal Server Error

  /logout/:
    post:
      summary: Sign out a user
      tags:
        - US-auth
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: OK
        '500':
          description: Internal Server Error'
      security:
        - BearerAuth: []

  /forgot-password:
    post:
      summary: Forgot password
      tags:
        - US-auth
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                email:
                  type: string
      responses:
        '200':
          description: OK
        '400':
          description: Bad Request
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                properties:
                  message:
                    type: string
                    example: 'Email not found'
        '500':
          description: Internal Server Error

  /reset-password:
    post:
      summary: Reset password
      tags:
        - US-auth
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                email:
                  type: string
                pincode:
                  type: number
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                properties:
                  id:
                    type: string
                  access_token:
                    type: string
                  refresh_token:
                    type: string
        '400':
          description: Bad Request
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                properties:
                  message:
                    type: string
                    example: 'Pincode is incorrect'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                properties:
                  message:
                    type: string
                    example: 'Email not found'
        '500':
          description: Internal Server Error

  /users/:
    get:
      summary: Get a user info
      tags:
        - US-user
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
        '401':
          description: Unauthorized
        '403':
          description: Forbidden
        '404':
          description: Not Found
        '500':
          description: Internal Server Error
      security:
        - BearerAuth: []

    put:
      summary: Update a user
      tags:
        - US-user
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/User'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
        '400':
          description: Bad Request
        '401':
          description: Unauthorized
        '403':
          description: Forbidden
        '404':
          description: Not Found
        '500':
          description: Internal Server Error
      security:
        - BearerAuth: []

  /users/change-password/:
    post:
      summary: Change password
      tags:
        - US-user
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                password:
                  type: string
      responses:
        '200':
          description: OK
        '400':
          description: Bad Request
        '401':
          description: Unauthorized
        '500':
          description: Internal Server Error
      security:
        - BearerAuth:: []

  /users/change-email/:
    post:
      summary: Change email
      tags:
        - US-user
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                email:
                  type: string
      responses:
        '200':
          description: OK
        '400':
          description: Bad Request
        '401':
          description: Unauthorized
        '409':
          description: Conflict
          content:
            application/json:
              schema:
                properties:
                  message:
                    type: string
                    example: 'Email already exists'
        '500':
          description: Internal Server Error
      security:
        - BearerAuth: []

  /users/confirm-password:
    post:
      summary: Confirm password
      tags:
        - US-user
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                password:
                  type: string
      responses:
        '200':
          description: OK
        '400':
          description: Bad Request
        '401':
          description: Unauthorized
        '500':
          description: Internal Server Error
      security:
        - BearerAuth: []

  /apply-users:
    get:
      summary: Get all apply users
      tags:
        - Ad-user
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/User'
        '401':
          description: Unauthorized
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                properties:
                  message:
                    type: string
                    example: 'Only admin can get the apply users'
        '500':
          description: Internal Server Error
      security:
        - BearerAuth: []

  /users/line-connection:
    put:
      summary: Integration to LINE account
      tags:
        - Ad-user
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                id:
                  type: string
                line_id:
                  type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'

  /users/role:
    put:
      summary: Update a user role
      tags:
        - Ad-user
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                id:
                  type: string
                role:
                  type: integer
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
        '400':
          description: Bad Request
        '401':
          description: Unauthorized
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                properties:
                  message:
                    type: string
                    example: 'Only admin can change the role'
        '404':
          description: Not Found
        '500':
          description: Internal Server Error
      security:
        - BearerAuth: []

components:
  schemas:
    User:
      type: object
      required:
        - id
        - email
        - password
        - role
        - created_at
        - updated_at
      properties:
        id:
          type: string
          format: uuid
        email:
          type: string
          format: email
        password:
          type: string
          format: password
        firstname:
          type: string
        lastname:
          type: string
        firstname_kana:
          type: string
        lastname_kana:
          type: string
        role:
          type: integer
        line_id:
          type: string
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time

    ParrentInfo:
      type: object
      required:
        - id
        - user_id
      properties:
        id:
          type: number
        user_id:
          type: string
        icon_image:
          type: string
        phone_number:
          type: string
        birthday:
          type: string
          format: date

    SitterInfo:
      type: object
      required:
        - id
        - user_id
      properties:
        id:
          type: number
        user_id:
          type: string
        icon_image:
          type: string
        thumbnail_image:
          type: string
        promotion_message:
          type: string
        licence:
          type: array
          items:
            type: string
        region:
          type: array
          items:
            type: string
        time_option:
          type: array
          items:
            type: string
        sick_child_option:
          type: array
          items:
            type: string
        sicked_child_option:
          type: array
          items:
            type: string
        teaching_option:
          type: array
          items:
            type: string
        other_option:
          type: array
          items:
            type: string

  securitySchemes:
    BearerAuth:
      description: 'JWT authorization'
      type: 'http'
      scheme: bearer
