{
  "openapi": "3.0.3",
  "info": {
    "title": "IVMEGO Add-on API",
    "version": "addon-v1",
    "description": "Bayi eklentileri için stok kartı, ürün fiyatı ve depo bakiyesi sorguları. Mevcut ERP erişim belirteci ile ilgili şirket ve işlem yetkileri gerekir. Bu belge bir test sunucusu tanımlamaz."
  },
  "security": [
    {
      "Bearer": []
    }
  ],
  "paths": {
    "/api/catalog/products/{productId}": {
      "get": {
        "tags": [
          "Stok kartları"
        ],
        "summary": "Stok kartını getir",
        "operationId": "getStockCard",
        "parameters": [
          {
            "name": "productId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "X-Ivmego-Company",
            "in": "header",
            "description": "Şirket kapsamlı işlemlerde zorunlu olan aktif şirket kimliği. Bu başlık erişim yetkisi sağlamaz.",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProductResponse"
                },
                "examples": {
                  "stockCard": {
                    "summary": "Örnek stok kartı",
                    "value": {
                      "id": "00000000-0000-4000-8000-000000000001",
                      "sku": "DEMO-001",
                      "name": "Demo ürün",
                      "isActive": true,
                      "categoryId": null,
                      "unitOfMeasureId": null,
                      "vatRateDefinitionId": null,
                      "barcodes": [],
                      "primaryBarcode": null,
                      "barcodeDetails": [],
                      "unitConversions": [],
                      "profile": {
                        "productType": 1,
                        "secondaryName": null,
                        "brand": null,
                        "description": null,
                        "currencyCode": "TRY",
                        "purchaseVatRateDefinitionId": null,
                        "lotTrackingEnabled": false,
                        "stockTrackingEnabled": true,
                        "serialTrackingEnabled": false,
                        "serialNumberStart": null,
                        "warrantyDuration": null,
                        "warrantyUnit": null,
                        "posDepartmentCode": null,
                        "posSortOrder": null,
                        "isWebEnabled": false,
                        "originCountryCode": null,
                        "specificGravity": null,
                        "gtin": null,
                        "departmentDefinitionId": null,
                        "posShortcutName": null,
                        "customsTariffCode": null,
                        "procurementLeadTimeDuration": null,
                        "procurementLeadTimeUnit": null,
                        "shelfLifeDuration": null,
                        "shelfLifeUnit": null,
                        "shelfLocation": null,
                        "shelfLocationTrackingEnabled": false,
                        "unavailableBranchIds": null,
                        "expirationDateTrackingEnabled": false,
                        "productionDateTrackingEnabled": false,
                        "lotIssueMethod": 1,
                        "allowNegativeLotStock": false,
                        "expirationWarningDays": 30,
                        "specificUnitOfMeasureId": null,
                        "serialEntryMethod": 1,
                        "automaticSerialPrefix": null,
                        "isFavorite": false
                      },
                      "specialCodes": {},
                      "warehouseSettings": [],
                      "note": null,
                      "audit": {
                        "createdByUserId": null,
                        "createdAtUtc": null,
                        "updatedByUserId": null,
                        "updatedAtUtc": null
                      },
                      "productMaster": null,
                      "isVariantEnabled": false,
                      "changeVersion": "0000000000000001"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Geçerli erişim belirteci gerekli."
          },
          "403": {
            "description": "İşlem veya veri kapsamı için yetki yok."
          },
          "404": {
            "description": "Stok kartı bulunamadı."
          }
        }
      }
    },
    "/api/catalog/pricing/product-prices/resolve": {
      "get": {
        "tags": [
          "Fiyatlar"
        ],
        "summary": "Belirtilen fiyat listesinde geçerli ürün fiyatını sorgula",
        "operationId": "resolveProductPrice",
        "parameters": [
          {
            "name": "priceListId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "productId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "effectiveOn",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "effectiveAtTime",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "time"
            }
          },
          {
            "name": "businessPartnerId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "X-Ivmego-Company",
            "in": "header",
            "description": "Şirket kapsamlı işlemlerde zorunlu olan aktif şirket kimliği. Bu başlık erişim yetkisi sağlamaz.",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/ProductPriceResponse"
                    },
                    {
                      "$ref": "#/components/schemas/PartnerContractPrice"
                    }
                  ]
                },
                "examples": {
                  "priceList": {
                    "summary": "Fiyat listesi kaydı",
                    "value": {
                      "id": "00000000-0000-4000-8000-000000000002",
                      "priceListId": "00000000-0000-4000-8000-000000000003",
                      "productId": "00000000-0000-4000-8000-000000000001",
                      "amount": 125.5,
                      "effectiveFrom": "2026-11-01",
                      "effectiveFromTime": "00:00:00",
                      "effectiveTo": null,
                      "isDeleted": false,
                      "changeVersion": "AAAAAAAAAAI=",
                      "changedByUserName": null
                    }
                  },
                  "partnerContract": {
                    "summary": "Cari sözleşmesi fiyatı",
                    "value": {
                      "amount": 119.5,
                      "currencyCode": "TRY",
                      "contractId": "00000000-0000-4000-8000-000000000004",
                      "priceListId": "00000000-0000-4000-8000-000000000003",
                      "productId": "00000000-0000-4000-8000-000000000001",
                      "pricesIncludeVat": true
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Geçerli erişim belirteci gerekli."
          },
          "403": {
            "description": "İşlem veya veri kapsamı için yetki yok."
          },
          "404": {
            "description": "Belirtilen tarih ve saat için geçerli fiyat bulunamadı."
          },
          "400": {
            "description": "Sorgu parametreleri geçersiz."
          }
        },
        "description": "Cari kimliğiyle geçerli bir sözleşme bulunursa sözleşme fiyatı döner. Aksi durumda fiyat listesi kaydı döner."
      }
    },
    "/api/inventory/balances/{productId}": {
      "get": {
        "tags": [
          "Depo bakiyeleri"
        ],
        "summary": "Ürünün belirtilen depodaki bakiyesini getir",
        "operationId": "getWarehouseBalance",
        "parameters": [
          {
            "name": "productId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "warehouseId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "X-Ivmego-Company",
            "in": "header",
            "description": "Şirket kapsamlı işlemlerde zorunlu olan aktif şirket kimliği. Bu başlık erişim yetkisi sağlamaz.",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StockBalanceResponse"
                },
                "examples": {
                  "balance": {
                    "summary": "Örnek depo bakiyesi",
                    "value": {
                      "productId": "00000000-0000-4000-8000-000000000001",
                      "warehouseId": "00000000-0000-4000-8000-000000000005",
                      "quantity": 42.5
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Geçerli erişim belirteci gerekli."
          },
          "403": {
            "description": "İşlem veya veri kapsamı için yetki yok."
          },
          "400": {
            "description": "Sorgu parametreleri geçersiz."
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "Bearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "Yetkili ERP oturumunun erişim belirteci."
      }
    },
    "schemas": {
      "ProductBarcodeDetailResponse": {
        "type": "object",
        "required": [
          "id",
          "recordId",
          "productId",
          "barcode",
          "barcodeType",
          "canonicalGtin",
          "isPrimary",
          "isActive",
          "isDeleted",
          "changeVersion",
          "source",
          "allocationId",
          "unitOfMeasureId",
          "factor",
          "unitPrice",
          "usesBaseUnitPriceAuthority"
        ],
        "properties": {
          "id": {
            "format": "uuid",
            "type": "string"
          },
          "recordId": {
            "format": "int64",
            "type": "integer"
          },
          "productId": {
            "format": "uuid",
            "type": "string"
          },
          "barcode": {
            "type": "string"
          },
          "barcodeType": {
            "type": "string"
          },
          "canonicalGtin": {
            "nullable": true,
            "type": "string"
          },
          "isPrimary": {
            "type": "boolean"
          },
          "isActive": {
            "type": "boolean"
          },
          "isDeleted": {
            "type": "boolean"
          },
          "changeVersion": {
            "type": "string"
          },
          "source": {
            "type": "string"
          },
          "allocationId": {
            "type": "string",
            "nullable": true,
            "format": "uuid"
          },
          "unitOfMeasureId": {
            "type": "string",
            "nullable": true,
            "format": "uuid"
          },
          "factor": {
            "nullable": true,
            "type": "number"
          },
          "unitPrice": {
            "nullable": true,
            "type": "number"
          },
          "usesBaseUnitPriceAuthority": {
            "type": "boolean"
          }
        }
      },
      "ProductUnitConversionResponse": {
        "type": "object",
        "required": [
          "id",
          "productId",
          "unitOfMeasureId",
          "factor",
          "isActive",
          "displayOrder",
          "createdByUserId",
          "createdAtUtc",
          "updatedByUserId",
          "updatedAtUtc",
          "changeVersion"
        ],
        "properties": {
          "id": {
            "format": "uuid",
            "type": "string"
          },
          "productId": {
            "format": "uuid",
            "type": "string"
          },
          "unitOfMeasureId": {
            "format": "uuid",
            "type": "string"
          },
          "factor": {
            "type": "number"
          },
          "isActive": {
            "type": "boolean"
          },
          "displayOrder": {
            "format": "int32",
            "type": "integer"
          },
          "createdByUserId": {
            "type": "string",
            "nullable": true,
            "format": "uuid"
          },
          "createdAtUtc": {
            "type": "string",
            "nullable": true,
            "format": "date-time"
          },
          "updatedByUserId": {
            "type": "string",
            "nullable": true,
            "format": "uuid"
          },
          "updatedAtUtc": {
            "type": "string",
            "nullable": true,
            "format": "date-time"
          },
          "changeVersion": {
            "type": "string"
          }
        }
      },
      "ProductProfile": {
        "type": "object",
        "required": [
          "productType",
          "secondaryName",
          "brand",
          "description",
          "currencyCode",
          "purchaseVatRateDefinitionId",
          "lotTrackingEnabled",
          "stockTrackingEnabled",
          "serialTrackingEnabled",
          "serialNumberStart",
          "warrantyDuration",
          "warrantyUnit",
          "posDepartmentCode",
          "posSortOrder",
          "isWebEnabled",
          "originCountryCode",
          "specificGravity",
          "gtin",
          "departmentDefinitionId",
          "posShortcutName",
          "customsTariffCode",
          "procurementLeadTimeDuration",
          "procurementLeadTimeUnit",
          "shelfLifeDuration",
          "shelfLifeUnit",
          "shelfLocation",
          "shelfLocationTrackingEnabled",
          "unavailableBranchIds",
          "expirationDateTrackingEnabled",
          "productionDateTrackingEnabled",
          "lotIssueMethod",
          "allowNegativeLotStock",
          "expirationWarningDays",
          "specificUnitOfMeasureId",
          "serialEntryMethod",
          "automaticSerialPrefix",
          "isFavorite"
        ],
        "properties": {
          "productType": {
            "format": "int32",
            "type": "integer"
          },
          "secondaryName": {
            "nullable": true,
            "type": "string"
          },
          "brand": {
            "nullable": true,
            "type": "string"
          },
          "description": {
            "nullable": true,
            "type": "string"
          },
          "currencyCode": {
            "type": "string"
          },
          "purchaseVatRateDefinitionId": {
            "type": "string",
            "nullable": true,
            "format": "uuid"
          },
          "lotTrackingEnabled": {
            "type": "boolean"
          },
          "stockTrackingEnabled": {
            "type": "boolean"
          },
          "serialTrackingEnabled": {
            "type": "boolean"
          },
          "serialNumberStart": {
            "nullable": true,
            "type": "string"
          },
          "warrantyDuration": {
            "type": "integer",
            "nullable": true,
            "format": "int32"
          },
          "warrantyUnit": {
            "type": "integer",
            "nullable": true,
            "format": "int32"
          },
          "posDepartmentCode": {
            "nullable": true,
            "type": "string"
          },
          "posSortOrder": {
            "type": "integer",
            "nullable": true,
            "format": "int32"
          },
          "isWebEnabled": {
            "type": "boolean"
          },
          "originCountryCode": {
            "nullable": true,
            "type": "string"
          },
          "specificGravity": {
            "nullable": true,
            "type": "number"
          },
          "gtin": {
            "nullable": true,
            "type": "string"
          },
          "departmentDefinitionId": {
            "type": "string",
            "nullable": true,
            "format": "uuid"
          },
          "posShortcutName": {
            "nullable": true,
            "type": "string"
          },
          "customsTariffCode": {
            "nullable": true,
            "type": "string"
          },
          "procurementLeadTimeDuration": {
            "type": "integer",
            "nullable": true,
            "format": "int32"
          },
          "procurementLeadTimeUnit": {
            "type": "integer",
            "nullable": true,
            "format": "int32"
          },
          "shelfLifeDuration": {
            "type": "integer",
            "nullable": true,
            "format": "int32"
          },
          "shelfLifeUnit": {
            "type": "integer",
            "nullable": true,
            "format": "int32"
          },
          "shelfLocation": {
            "nullable": true,
            "type": "string"
          },
          "shelfLocationTrackingEnabled": {
            "type": "boolean"
          },
          "unavailableBranchIds": {
            "type": "array",
            "nullable": true,
            "items": {
              "format": "uuid",
              "type": "string"
            }
          },
          "expirationDateTrackingEnabled": {
            "type": "boolean"
          },
          "productionDateTrackingEnabled": {
            "type": "boolean"
          },
          "lotIssueMethod": {
            "format": "int32",
            "type": "integer"
          },
          "allowNegativeLotStock": {
            "type": "boolean"
          },
          "expirationWarningDays": {
            "format": "int32",
            "type": "integer"
          },
          "specificUnitOfMeasureId": {
            "type": "string",
            "nullable": true,
            "format": "uuid"
          },
          "serialEntryMethod": {
            "format": "int32",
            "type": "integer"
          },
          "automaticSerialPrefix": {
            "nullable": true,
            "type": "string"
          },
          "isFavorite": {
            "type": "boolean"
          }
        }
      },
      "ProductAuditMetadata": {
        "type": "object",
        "required": [
          "createdByUserId",
          "createdAtUtc",
          "updatedByUserId",
          "updatedAtUtc"
        ],
        "properties": {
          "createdByUserId": {
            "type": "string",
            "nullable": true,
            "format": "uuid"
          },
          "createdAtUtc": {
            "type": "string",
            "nullable": true,
            "format": "date-time"
          },
          "updatedByUserId": {
            "type": "string",
            "nullable": true,
            "format": "uuid"
          },
          "updatedAtUtc": {
            "type": "string",
            "nullable": true,
            "format": "date-time"
          }
        }
      },
      "ProductWarehouseSetting": {
        "type": "object",
        "required": [
          "warehouseId",
          "isDefault",
          "minimumQuantity",
          "maximumQuantity",
          "minimumOrderQuantity",
          "isActive",
          "id"
        ],
        "properties": {
          "warehouseId": {
            "format": "uuid",
            "type": "string"
          },
          "isDefault": {
            "type": "boolean"
          },
          "minimumQuantity": {
            "nullable": true,
            "type": "number"
          },
          "maximumQuantity": {
            "nullable": true,
            "type": "number"
          },
          "minimumOrderQuantity": {
            "nullable": true,
            "type": "number"
          },
          "isActive": {
            "type": "boolean"
          },
          "id": {
            "format": "uuid",
            "type": "string"
          }
        }
      },
      "ProductResponse": {
        "type": "object",
        "required": [
          "id",
          "sku",
          "name",
          "isActive",
          "categoryId",
          "unitOfMeasureId",
          "vatRateDefinitionId",
          "barcodes",
          "primaryBarcode",
          "barcodeDetails",
          "unitConversions",
          "profile",
          "specialCodes",
          "warehouseSettings",
          "note",
          "audit",
          "productMaster",
          "isVariantEnabled",
          "changeVersion"
        ],
        "properties": {
          "id": {
            "format": "uuid",
            "type": "string"
          },
          "sku": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "isActive": {
            "type": "boolean"
          },
          "categoryId": {
            "type": "string",
            "nullable": true,
            "format": "uuid"
          },
          "unitOfMeasureId": {
            "type": "string",
            "nullable": true,
            "format": "uuid"
          },
          "vatRateDefinitionId": {
            "type": "string",
            "nullable": true,
            "format": "uuid"
          },
          "barcodes": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "primaryBarcode": {
            "nullable": true,
            "type": "string"
          },
          "barcodeDetails": {
            "items": {
              "$ref": "#/components/schemas/ProductBarcodeDetailResponse"
            },
            "type": "array"
          },
          "unitConversions": {
            "items": {
              "$ref": "#/components/schemas/ProductUnitConversionResponse"
            },
            "type": "array"
          },
          "profile": {
            "$ref": "#/components/schemas/ProductProfile"
          },
          "specialCodes": {
            "additionalProperties": {
              "type": "string"
            },
            "type": "object"
          },
          "warehouseSettings": {
            "items": {
              "$ref": "#/components/schemas/ProductWarehouseSetting"
            },
            "type": "array"
          },
          "note": {
            "nullable": true,
            "type": "string"
          },
          "audit": {
            "$ref": "#/components/schemas/ProductAuditMetadata"
          },
          "productMaster": {
            "properties": {
              "tradeItemId": {
                "format": "uuid",
                "type": "string"
              },
              "catalogVersion": {
                "format": "int64",
                "type": "integer"
              }
            },
            "required": [
              "tradeItemId",
              "catalogVersion"
            ],
            "type": "object",
            "nullable": true
          },
          "isVariantEnabled": {
            "type": "boolean"
          },
          "changeVersion": {
            "type": "string"
          }
        }
      },
      "ProductPriceResponse": {
        "type": "object",
        "required": [
          "id",
          "priceListId",
          "productId",
          "amount",
          "effectiveFrom",
          "effectiveFromTime",
          "effectiveTo",
          "isDeleted",
          "changeVersion",
          "changedByUserName"
        ],
        "properties": {
          "id": {
            "format": "uuid",
            "type": "string"
          },
          "priceListId": {
            "format": "uuid",
            "type": "string"
          },
          "productId": {
            "format": "uuid",
            "type": "string"
          },
          "amount": {
            "type": "number"
          },
          "effectiveFrom": {
            "format": "date",
            "type": "string"
          },
          "effectiveFromTime": {
            "type": "string"
          },
          "effectiveTo": {
            "type": "string",
            "nullable": true,
            "format": "date"
          },
          "isDeleted": {
            "type": "boolean"
          },
          "changeVersion": {
            "type": "string",
            "format": "byte"
          },
          "changedByUserName": {
            "nullable": true,
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "StockBalanceResponse": {
        "type": "object",
        "required": [
          "productId",
          "warehouseId",
          "quantity"
        ],
        "properties": {
          "productId": {
            "format": "uuid",
            "type": "string"
          },
          "warehouseId": {
            "format": "uuid",
            "type": "string"
          },
          "quantity": {
            "type": "number"
          }
        }
      },
      "PartnerContractPrice": {
        "type": "object",
        "required": [
          "amount",
          "currencyCode",
          "contractId",
          "priceListId",
          "productId",
          "pricesIncludeVat"
        ],
        "properties": {
          "amount": {
            "type": "number"
          },
          "currencyCode": {
            "type": "string"
          },
          "contractId": {
            "format": "uuid",
            "type": "string"
          },
          "priceListId": {
            "format": "uuid",
            "type": "string"
          },
          "productId": {
            "format": "uuid",
            "type": "string"
          },
          "pricesIncludeVat": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      }
    }
  }
}
