arazzo: 1.0.1 info: title: Salla Upsert Product by SKU summary: Find a product by keyword and update it if it exists, otherwise create it. description: >- A common catalog synchronization pattern. The workflow searches the product catalog for an existing product matching a SKU or name keyword and then branches: when a match is found it updates that product in place, and when no match is found it creates a new product. Each step spells out its request inline so the flow can be read and executed without opening the underlying OpenAPI description. version: 1.0.0 sourceDescriptions: - name: merchantApi url: ../openapi/salla-merchant-api-openapi.yml type: openapi workflows: - workflowId: upsert-product summary: Upsert a product into the catalog keyed by a SKU or name keyword. description: >- Searches the catalog for a product matching the supplied keyword and either updates the matched product or creates a new one. inputs: type: object required: - keyword - name - price - productType properties: keyword: type: string description: SKU or name fragment used to detect an existing product. name: type: string description: Display name to write to the product. price: type: number description: Price to write to the product. productType: type: string description: Product type (e.g. product, service, digital). quantity: type: integer description: Stock quantity to write to the product. steps: - stepId: findProduct description: >- Search the catalog for a product whose name or SKU matches the supplied keyword, returning at most one match. operationId: listProducts parameters: - name: keyword in: query value: $inputs.keyword - name: per_page in: query value: 1 successCriteria: - condition: $statusCode == 200 outputs: matchedProductId: $response.body#/data/0/id onSuccess: - name: productExists type: goto stepId: updateExisting criteria: - context: $response.body condition: $.data.length > 0 type: jsonpath - name: productMissing type: goto stepId: createNew criteria: - context: $response.body condition: $.data.length == 0 type: jsonpath - stepId: updateExisting description: >- Update the matched product in place with the supplied attributes. operationId: updateProduct parameters: - name: product_id in: path value: $steps.findProduct.outputs.matchedProductId requestBody: contentType: application/json payload: name: $inputs.name price: $inputs.price product_type: $inputs.productType quantity: $inputs.quantity successCriteria: - condition: $statusCode == 200 outputs: productId: $response.body#/data/id onSuccess: - name: done type: end - stepId: createNew description: >- Create a new product when no existing product matched the keyword. operationId: createProduct requestBody: contentType: application/json payload: name: $inputs.name price: $inputs.price product_type: $inputs.productType quantity: $inputs.quantity successCriteria: - condition: $statusCode == 201 outputs: productId: $response.body#/data/id outputs: updatedProductId: $steps.updateExisting.outputs.productId createdProductId: $steps.createNew.outputs.productId