arazzo: 1.0.1 info: title: Salla Upsert Customer summary: Find a customer in a page of results and update them, otherwise create a new customer. description: >- A CRM synchronization pattern for a Salla store. The workflow reads a page of customers, branches on whether the directory already holds any customers, and either updates the first matched customer in place or creates a brand new customer record. 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-customer summary: Upsert a customer into the store directory. description: >- Reads a page of customers and either updates the first existing customer or creates a new one when the directory is empty. inputs: type: object required: - firstName - mobile - mobileCode properties: firstName: type: string description: Customer first name. lastName: type: string description: Customer last name. mobile: type: string description: Customer mobile number. mobileCode: type: string description: Country dialing code for the mobile number. email: type: string description: Customer email address. steps: - stepId: findCustomer description: >- Read the first page of customers to determine whether the directory already holds a customer to update. operationId: listCustomers parameters: - name: per_page in: query value: 1 successCriteria: - condition: $statusCode == 200 outputs: matchedCustomerId: $response.body#/data/0/id onSuccess: - name: customerExists type: goto stepId: updateExisting criteria: - context: $response.body condition: $.data.length > 0 type: jsonpath - name: customerMissing type: goto stepId: createNew criteria: - context: $response.body condition: $.data.length == 0 type: jsonpath - stepId: updateExisting description: >- Update the first matched customer with the supplied contact details. operationId: updateCustomer parameters: - name: customer_id in: path value: $steps.findCustomer.outputs.matchedCustomerId requestBody: contentType: application/json payload: first_name: $inputs.firstName last_name: $inputs.lastName mobile: $inputs.mobile mobile_code: $inputs.mobileCode email: $inputs.email successCriteria: - condition: $statusCode == 200 outputs: customerId: $response.body#/data/id onSuccess: - name: done type: end - stepId: createNew description: >- Create a new customer record when the directory held no customer to update. operationId: createCustomer requestBody: contentType: application/json payload: first_name: $inputs.firstName last_name: $inputs.lastName mobile: $inputs.mobile mobile_code: $inputs.mobileCode email: $inputs.email successCriteria: - condition: $statusCode == 201 outputs: customerId: $response.body#/data/id outputs: updatedCustomerId: $steps.updateExisting.outputs.customerId createdCustomerId: $steps.createNew.outputs.customerId