๐ More Examples: Assign vs Stitch in OIC Gen3
๐งช Example 1: Set Boolean Flag (Assign)
Scenario: Based on a condition, set a flag to true or false.
isEligible = true
Why Assign? Simple scalar assignment.
๐งช Example 2: Combine Strings (Assign)
Scenario: Generate a unique ID for a transaction.
transactionId = "TXN-" + currentDate + "-" + customerId
Why Assign? String operations with known variables.
๐งช Example 3: Set a Variable from an Expression (Assign)
Scenario: Calculate tax based on amount.
taxAmount = totalAmount * 0.18
Why Assign? Mathematical expression with constants and variables.
๐ชข Example 4: Append Dynamic Payloads to a List (Stitch)
Scenario: While processing each record from an input array, append valid records to a result list.
validRecords.append(currentRecord)
Why Stitch? You’re dynamically building an array over iterations.
๐ชข Example 5: Merge Customer Profile Data (Stitch)
Scenario: You get partial customer data from two different sources and want to stitch them into one object.
customerProfile.name = source1.name
customerProfile.email = source2.email
customerProfile.address = source1.address
Why Stitch? Updating only specific fields inside a nested object.
๐ชข Example 6: Update an Element in a Nested List (Stitch)
Scenario: Change the quantity of the third item in the order list.
orderList[2].quantity = 5
Why Stitch? You're modifying an element deep within a data structure without affecting others.
๐ Summary Comparison
Use Case | Assign | Stitch |
---|---|---|
Set default values | ✅ | ❌ |
Append item to array | ❌ | ✅ |
Set calculated value | ✅ | ❌ |
Update nested field | ❌ | ✅ |
Build composite object | ❌ | ✅ |
No comments:
Post a Comment