openapi: 3.0.3
info:
  title: MottaSport Order API
  version: "1.0.0"
  description: >
    Website sahibi bayiler ve hazir website paketleri icin katalog, teklif,
    siparis ve siparis durum API yuzeyi. Harici entegrasyonlarda API anahtari
    frontend icine yazilmaz; server-side proxy X-Motta-Key header'i kullanir.
servers:
  - url: https://api.mottasport.com
    description: Production API
  - url: http://127.0.0.1:8010
    description: Local preview
components:
  securitySchemes:
    MottaIntegrationKey:
      type: apiKey
      in: header
      name: X-Motta-Key
  schemas:
    ApiEnvelope:
      type: object
      properties:
        ok:
          type: boolean
        data:
          type: object
        error:
          nullable: true
          type: object
    OrderPayload:
      type: object
      required:
        - customer_name
        - email
        - phone
        - shipping_address
        - delivery_date
        - items
      properties:
        customer_name:
          type: string
        email:
          type: string
          format: email
        phone:
          type: string
        shipping_address:
          type: string
        delivery_date:
          type: string
          format: date
        sport:
          type: string
        model_name:
          type: string
        product_code:
          type: string
        totalQuantity:
          type: integer
          minimum: 1
        items:
          type: array
          items:
            type: object
            required:
              - productType
              - quantity
            properties:
              productType:
                type: string
              quantity:
                type: integer
                minimum: 1
              fabricKey:
                type: string
              prints:
                type: array
                items:
                  type: object
paths:
  /api/v1/integrations:
    get:
      summary: Entegrasyon kanallarini ve public widget asset adreslerini getirir.
      responses:
        "200":
          description: Integration manifest response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiEnvelope"
  /api/v1/tenants/{tenantSlug}/manifest/website:
    get:
      summary: Website manifestini getirir.
      security:
        - MottaIntegrationKey: []
      parameters:
        - name: tenantSlug
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Manifest response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiEnvelope"
  /api/v1/tenants/{tenantSlug}/catalog:
    get:
      summary: Bayi katalog verisini filtreli getirir.
      security:
        - MottaIntegrationKey: []
      parameters:
        - name: tenantSlug
          in: path
          required: true
          schema:
            type: string
        - name: page
          in: query
          schema:
            type: integer
            default: 1
        - name: limit
          in: query
          schema:
            type: integer
            default: 12
        - name: sport
          in: query
          schema:
            type: string
        - name: productType
          in: query
          schema:
            type: string
        - name: tag
          in: query
          schema:
            type: string
      responses:
        "200":
          description: Catalog response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiEnvelope"
  /api/v1/tenants/{tenantSlug}/order-form:
    get:
      summary: Siparis form semasini getirir.
      security:
        - MottaIntegrationKey: []
      parameters:
        - name: tenantSlug
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Form schema response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiEnvelope"
  /api/v1/tenants/{tenantSlug}/quote:
    post:
      summary: Tahmini teklif olusturur.
      security:
        - MottaIntegrationKey: []
      parameters:
        - name: tenantSlug
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/OrderPayload"
      responses:
        "200":
          description: Quote response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiEnvelope"
  /api/v1/tenants/{tenantSlug}/orders:
    post:
      summary: Siparis talebi olusturur.
      security:
        - MottaIntegrationKey: []
      parameters:
        - name: tenantSlug
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/OrderPayload"
      responses:
        "201":
          description: Order created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiEnvelope"
  /api/v1/tenants/{tenantSlug}/orders/{publicNo}:
    get:
      summary: Public siparis durumunu getirir.
      security:
        - MottaIntegrationKey: []
      parameters:
        - name: tenantSlug
          in: path
          required: true
          schema:
            type: string
        - name: publicNo
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Order status response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiEnvelope"
