---
openapi: 3.1.1
info:
  title: Finance Service API
  description: Orchestrates order processing and financial transactions for BookWorm
  contact:
    name: Nhan Nguyen
    url: https://github.com/foxminchan
    email: nguyenxuannhan407@gmail.com
  license:
    name: MIT
    url: https://opensource.org/licenses/MIT
  version: "1.0"
externalDocs:
  description: Documentation
  url: https://github.com/foxminchan/BookWorm
servers:
  - url: "{protocol}://{environment}.finance.bookworm.com"
    description: Before deploying to production, ensure the environment is set correctly
    variables:
      protocol:
        enum:
          - https
          - http
        default: https
      environment:
        enum:
          - dev
          - stg
          - qa
        default: dev
  - url: "{protocol}://finance.bookworm.com"
    description: Production
    variables:
      protocol:
        enum:
          - https
        default: https
security:
  - OAuth:
      - finance
paths:
  "/api/v1/order-state-machine":
    get:
      deprecated: true
      tags:
        - OrderState
      summary: Get Order State Machine
      description: Get the order state machine definition
      x-eventcatalog-message-type: query
      operationId: GetOrderStateEndpoint
      security:
        - OAuth:
            - finance
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: string
                description: The order state machine definition
                example: |-
                  digraph {
                    graph [layout=dot rankdir=LR]
                    node [shape=circle]

                    Initial [shape=diamond]
                    Placed [shape=circle]
                    Completed [shape=circle]
                    Cancelled [shape=circle]
                    Failed [shape=circle]

                    Initial -> Placed [label="OrderPlaced"]
                    Placed -> Failed [label="BasketDeletedFailed"]
                    Placed -> Completed [label="OrderCompleted"]
                    Placed -> Cancelled [label="OrderCancelled"]
                  }
        "401":
          description: Unauthorized - Access token is missing or invalid.
        "403":
          description: Forbidden - The permission requirements are not met.
components:
  securitySchemes:
    OAuth:
      type: oauth2
      description: OAuth2 security scheme for the BookWorm API
      flows:
        authorizationCode:
          authorizationUrl: "https://auth.bookworm.com/realms/bookworm/protocol/openid-connect/auth"
          tokenUrl: "https://auth.bookworm.com/realms/bookworm/protocol/openid-connect/token"
          scopes:
            finance: "Finance API"
          x-usePkce: "SHA-256"
          x-scalar-client-id: "finance"
          x-scalar-security-body:
            audience: "account"
tags:
  - name: OrderState
    description: Operations related to order state management
