Skip to content

Instantly share code, notes, and snippets.

<flow name="getStockInfo">
<http:listener path="stock" method="GET" config-ref="httpListener">
<http:response>
<http:body>
<![CDATA[
%dw 2.0
output application/json
---
{
"ticker": attributes.queryParams.ticker,
<flow name="prersons">
<http:listener path="person" method="POST" config-ref="httpListener" />
<foreach collection="#[payload.persons]">
<choice>
<when expression="#[payload.age > 21"]>
<logger message="#['$(payload.name) is an adult']" />
</when>
<otherwise>
<logger message="#['$(payload.name) is a minor.']" />
</otherwise>
{
persons: [
{
name: "John Doe",
age: 35
},
{
name: "Jane Doe",
age: 32
},
<idempotent-message-validator idExpression="#[payload]" valueExpression="#[payload]">
<os:private-object-store
entryTtl="20"
entryTtlUnit="MILLISECONDS"
maxEntries="20"
persistent="false"
expirationInterval="20"
expirationIntervalUnit="MILLISECONDS"/>
</idempotent-message-validator>
<sfdc:config-with-oauth name="salesforce-oauth"
consumerKey="${salesforce.consumerKey}"
consumerSecret="${salesforce.consumerSecret}">
<sfdc:oauth-callback-config domain="localhost" localPort="8082"
remotePort="8082" path="callback" connector-ref="HTTP_HTTPS" />
<sfdc:oauth-store-config objectStore="tokensStore" />
</sfdc:config-with-oauth>
<os:object-store name="tokensStore"
entryTtl="1"
entryTtlUnit="HOURS"
maxEntries="100"
persistent="true"
expirationInterval="30"
expirationIntervalUnit="MINUTES" />
<os:retrieve key="state">
<os:default-value>
<![CDATA[#[
output application/json
---
{ "id": attributes.queryParams.id,
"timestamp": now(),
"name": payload.name
}
]]]>
<os:retrieve key="timestamp">
<os:default-value>#[now()]</os:default-value>
</os:retrieve>
<os:retrieve key="userId" />
<os:store key="state">
<os:value>
<![CDATA[#[
output application/json
---
{ "id": attributes.queryParams.id,
"timestamp": now(),
"name": payload.name
}
]]]>