registration:
  post:
    tags:
      - Auth
    summary: 'Registration'
    operationId: registration
    requestBody:
      content:
        application/json:
          schema:
            type: object
            properties:
              first_name:
                type: string
                example: "Rules: ['required', 'min:2']"
                required: true
              last_name:
                type: string
                example: "Rules: ['required', 'min:2']"
                required: true
              email:
                type: string
                example: "Rules: ['required', 'email', 'unique']"
                required: true
              password:
                type: string
                example: "Rules: ['required', 'min:8', 'Password must contain at least one capital letter.','Password must contain at least one digit.']"
                required: true
    responses:
      '200':
        description: ""
        content:
          application/json:
            examples:
              success:
                value:
                  "success": true
                  "data": {
                      "type": "Bearer",
                      "token": "1|ITR9vcbjsuSZXeuYSKjwkK9warTkjsRYpm5fWl8ebd15e2d5",
                      "user": {
                        "first_name": "John",
                        "last_name": "Doe",
                        "email": "john.doe@gmail.com",
                        "id": 2
                      }
                    }


      '422':
        description: Validation Error
        content:
          application/json:
            examples:
              error:
                value:
                  errors: {
                      "first_name": [
                          "The first_name field is required.",
                          "The first_name field must be at least 2 characters.",
                        ],
                      "last_name": [
                          "The last_name field is required.",
                          "The last_name field must be at least 2 characters.",
                        ],
                      "email": [
                          "The email field is required.",
                          "The email field must be a valid email address.",
                          "The email has already been taken."
                        ],
                      "password": [
                          "The password field is required.",
                          "The password field must be at least 8 characters.",
                          "Password must contain at least one capital letter.",
                          "Password must contain at least one digit."
                        ]
                    }
      '500':
        description: Server error
        content:
          application/json:
            examples:
              error:
                value:
                  "success": false
                  "errors": ["Server error"]

login:
  post:
    tags:
      - Auth
    summary: 'Login'
    operationId: login
    requestBody:
      content:
        application/json:
          schema:
            type: object
            properties:
              email:
                type: string
                example: "Rules: ['required', 'email', 'exists','verified']"
                required: true
              password:
                type: string
                example: "Rules: ['required','min:8']"
                required: true
    responses:
      '200':
        description: ""
        content:
          application/json:
            examples:
              success:
                value:
                  "success": true
                  "data": {
                    "token": {
                      "type": "Bearer",
                      "token": "1|EePbg0nQYYJuVIp3YdyRjCoQUnaICR9arRtazwwF2d15b68a"
                    },
                      "user": {
                        "id": 1,
                        "email": "john.doe@email.com",
                        "username": "John Doe",
                        "avatar": "avatar:link",
                        "email_verified_at": "2024-10-22T09:43:07.000000Z",
                        "stripe_id": null,
                        "pm_type": null,
                        "pm_last_four": null,
                        "trial_ends_at": null,
                        "role": "super_admin"
                      }
                    }


      '422':
        description: Validation Error
        content:
          application/json:
            examples:
              error:
                value:
                  errors: {
                      "email": [
                          "The email field is required.",
                          "The email field must be a valid email address.",
                          "The selected email is invalid.",
                          "The user email is not verified."
                        ],
                      "password": [
                          "The token field is required.",
                          "The password field must be at least 8 characters.",
                          "The email or password is incorrect."
                        ]
                    }
      '500':
        description: Server error
        content:
          application/json:
            examples:
              error:
                value:
                  "success": false
                  "errors": ["Server error"]

login_via_provider:
  get:
    tags:
      - Auth
    summary: 'Login via provider'
    description: 'Frontend url should be `/login/google/callback`'
    operationId: loginViaProvider
    parameters:
        - in: path
          name: provider
          required: true
          schema:
            type: string
            enum: [google]
          description: Authentication provider
    responses:
      '200':
        description: ""
        content:
          application/json:
            examples:
              success:
                value:
                  "success": true
                  "data": "https://accounts.google.com/o/oauth2/auth?client_id=258925246374-o6bhma7h0dk4hhvisas1ggaodq9h17b7.apps.googleusercontent.com&scope=openid+profile+email&response_type=code"

      '422':
        description: Validation Error
        content:
          application/json:
            examples:
              error:
                value:
                  errors: {
                      "provider": [
                          "The provider field is required.",
                          "The selected provider is invalid."
                        ],
                    }
      '500':
        description: Server error
        content:
          application/json:
            examples:
              error:
                value:
                  "success": false
                  "errors": ["Server error"]

login_via_provider_callback:
  post:
    tags:
      - Auth
    summary: 'Login via provider callback'
    operationId: loginViaProviderCallback
    requestBody:
      content:
        application/json:
          schema:
            type: object
            properties:
              code:
                type: string
                example: "Rules: ['required']"
                required: true
    parameters:
        - in: path
          name: provider
          required: true
          schema:
            type: string
            enum: [google]
          description: Authentication provider
    responses:
      '200':
        description: ""
        content:
          application/json:
            examples:
              success:
                value:
                  "success": true
                  "data": {
                      "token": "Bearer 1|ILtUL3ylaGdudDZj64cBKQkq2zdmSV4PKKGTPHdb0ba17438",
                      "user": {
                          "id": 1,
                          "name": "Joh Doe",
                          "email": "john.doe@email.com",
                          "email_verified_at": "2024-07-03T17:06:58.000000Z",
                          "company_name": null,
                          "role": null,
                          "industry": null,
                          "created_at": "2024-07-03T16:01:16.000000Z",
                          "updated_at": "2024-07-03T17:06:58.000000Z"
                      }
                    }

      '422':
        description: Validation Error
        content:
          application/json:
            examples:
              error:
                value:
                  errors: {
                      "provider": [
                          "The provider field is required.",
                          "The selected provider is invalid."
                      ],
                       "code": [
                          "The code field is required.",
                      ],
                    }
      '500':
        description: Server error
        content:
          application/json:
            examples:
              error:
                value:
                  "success": false
                  "errors": ["Server error"]

change-password:
  post:
    tags:
      - Auth
    summary: 'Change password'
    operationId: changePassword
    requestBody:
      content:
        application/json:
          schema:
            type: object
            properties:
              email:
                type: string
                example: "Rules: ['required', 'email', 'exists']"
                required: true
              password:
                type: string
                example: "Rules: ['required', 'min:8']"
                required: true
    responses:
      '200':
        description: ""
        content:
          application/json:
            examples:
              success:
                value:
                  "success": true
                  "data": true


      '422':
        description: Validation Error
        content:
          application/json:
            examples:
              error:
                value:
                  errors: {
                      "email": [
                          "The email field is required.",
                          "The email field must be a valid email address.",
                          "The selected email is invalid."
                      ],
                      "password": [
                          "The password field is required.",
                          "The password field must be at least 8 characters.",
                      ]
                    }
      '500':
        description: Server error
        content:
          application/json:
            examples:
              error:
                value:
                  "success": false
                  "errors": ["Server error"]

logout:
  post:
    tags:
      - Auth
    summary: 'Logout'
    operationId: logout
    responses:
      '200':
        description: ""
        content:
          application/json:
            examples:
              success:
                value:
                  "success": true
                  "data": true
      '401':
        description: ""
        content:
          application/json:
            examples:
              success:
                value:
                  "message": "Unauthenticated."
      '500':
        description: Server error
        content:
          application/json:
            examples:
              error:
                value:
                  "success": false
                  "errors": ["Server error"]
