x-hideTryItPanel: true
openapi: 3.0.3
info:
  title: Mythical Platform API WebHooks
  version: 1.0.0
  description: >-
    The Mythical Platform API provides third-party notifications.
    Webhooks are HTTP callbacks that allows to receive real-time notifications.
    The Mythical Platform API will send a POST request to the specified URL.
    The request will contain a JSON payload with the details of the event that
    triggered the webhook. The payload will include information such as the
    event type, the affected item, and any relevant metadata. The webhook
    allows to receive updates about specific events, such as item state changes,
    item metadata updates, and item type state changes. This enables to
    integrate the Mythical Platform API with other systems and services, and to
    automate workflows based on the events that occur within the platform.
tags:
  - name: WebHook
    description: >-
      HTTP callbacks endpoints.
components:
  schemas:
    WebhookRequest:
      description: >-
        Defines the structure of a webhook request sent by the Mythical Platform API.
      required:
        - notificationId
        - notificationType
        - notificationPayload
      properties:
        notificationId:
          type: string
          format: uuid
        notificationType:
          $ref: '#/components/schemas/NotificationType'
        notificationPayload:
          type: string
          description: >-
            JSON-encoded data in specific struct according to the notification type.
    NotificationType:
      type: string
      enum:
        - ItemUpdateError
        - ItemStateUpdated
        - ItemMetadataUpdated
        - ItemTypeStateUpdated
        - PurchaseCompleted
        - SellCompleted
        - QuickTradeCreated
        - QuickTradeReserved
        - QuickTradeCompleted
    ItemUpdateError:
      $ref: './platform_api_gateway_openapi.yaml/#/components/schemas/Item'
    ItemStateUpdated:
      $ref: './platform_api_gateway_openapi.yaml/#/components/schemas/Item'
    ItemMetadataUpdated:
      $ref: './platform_api_gateway_openapi.yaml/#/components/schemas/Item'
    ItemTypeStateUpdated:
      $ref: './platform_api_gateway_openapi.yaml/#/components/schemas/ItemType'
    PurchaseCompleted:
      properties:
        OperationID:
          type: string
        TitleID:
          type: string
        Status:
          $ref: '#/components/schemas/OperationStatus'
    SellCompleted:
      properties:
        OperationID:
          type: string
        TitleID:
          type: string
        Status:
          $ref: '#/components/schemas/OperationStatus'
    QuickTradeCreated:
      properties:
        OperationID:
          type: string
        Result:
          $ref: '#/components/schemas/CreatedTrade'
        TitleID:
          type: string
        Status:
          $ref: '#/components/schemas/OperationStatus'
    QuickTradeReserved:
      properties:
        OperationID:
          type: string
        Result:
          $ref: '#/components/schemas/ReservedTrade'
        TitleID:
          type: string
        Status:
          $ref: '#/components/schemas/OperationStatus'
    QuickTradeCompleted:
      properties:
        OperationID:
          type: string
        TitleID:
          type: string
        Status:
          $ref: '#/components/schemas/OperationStatus'
    OperationStatus:
      type: string
      enum:
        - Running
        - Completed
        - Failed
        - Rolledback
    Money:
      properties:
        MYTH:
          type: string
        USD:
          type: string
    CreatedTradeMatch:
      properties:
        ItemID:
          type: string
        OK:
          type: boolean
    ReservedTradeMatch:
      properties:
        ItemID:
          type: string
        OK:
          type: boolean
    CreatedTradeListing:
      properties:
        ListingID:
          type: string
        OK:
          type: boolean
    ReservedTradeListing:
      properties:
        ListingID:
          type: string
        OK:
          type: boolean
    CreatedTrade:
      properties:
        Expenses:
          $ref: '#/components/schemas/Money'
        Earnings:
          $ref: '#/components/schemas/Money'
        Fee:
          $ref: '#/components/schemas/Money'
        Total:
          $ref: '#/components/schemas/Money'
        ExpiresAt:
          type: integer
          format: int64
          description: Unix timestamp
        Give:
          type: array
          items:
            $ref: '#/components/schemas/CreatedTradeMatch'
        Receive:
          type: array
          items:
            $ref: '#/components/schemas/CreatedTradeListing'
    ReservedTrade:
      properties:
        Give:
          type: array
          items:
            $ref: '#/components/schemas/ReservedTradeMatch'
        Receive:
          type: array
          items:
            $ref: '#/components/schemas/ReservedTradeListing'
paths:
  /RegisteredWebhookURL:
    post:
      tags:
        - WebHook
      responses:
        '201':
          description: Success
