Skip to content

Commit

Permalink
fix: salesforce update kamelet fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Matheusafonsouza committed Jan 17, 2023
1 parent 2e08e0c commit c2a8159
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 43 deletions.
41 changes: 21 additions & 20 deletions kamelets/salesforce-update-sink.kamelet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,21 @@ spec:
description: |-
Update an object in Salesforce.
The body received must contain a JSON key-value pair for each property to update, for example: `{ "Phone": "1234567890", "Name": "Antonia" }`
The body received must contain a JSON key-value pair for each property to update inside the payload attribute, for example:
The body received must include the `sObjectName` and `sObjectId` properties.
`{ "payload": { "Phone": "1234567890", "Name": "Antonia" } }`
The body received must include the `sObjectName` and `sObjectId` properties, for example:
`{ "payload": { "Phone": "1234567890", "Name": "Antonia" }, "sObjectId": "sObjectId", "sObjectName": "sObjectName" }`
required:
- sObjectName
- sObjectId
- clientId
- clientSecret
- userName
- password
type: object
properties:
sObjectName:
title: Object Name
description: The type of the Salesforce object. Required if using a key-value pair.
type: string
example: Contact
sObjectId:
title: Object Id
description: The ID of the Salesforce object. Required if using a key-value pair.
type: string
loginUrl:
title: Login URL
description: The Salesforce instance login URL.
Expand Down Expand Up @@ -91,6 +84,9 @@ spec:
in:
mediaType: application/json
dependencies:
- "camel:core"
- "camel:jsonpath"
- "camel:jackson"
- "camel:salesforce"
- "camel:kamelet"
template:
Expand All @@ -103,12 +99,17 @@ spec:
userName: "{{userName}}"
password: "{{password}}"
loginUrl: "{{loginUrl}}"
from:
from:
uri: kamelet:source
steps:
- to:
uri: "{{local-salesforce}}:updateSObject"
parameters:
sObjectId: "{{sObjectId}}"
sObjectName: "{{sObjectName}}"
rawPayload: "true"
- set-property:
name: sObjectId
jsonpath: "$['sObjectId']"
- set-property:
name: sObjectName
jsonpath: "$['sObjectName']"
- transform:
jsonpath: "$['payload']"
- marshal:
json: {}
- toD: "{{local-salesforce}}:updateSObject?sObjectId=${exchangeProperty.sObjectId}&sObjectName=${exchangeProperty.sObjectName}&rawPayload=true"
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,21 @@ spec:
description: |-
Update an object in Salesforce.
The body received must contain a JSON key-value pair for each property to update, for example: `{ "Phone": "1234567890", "Name": "Antonia" }`
The body received must contain a JSON key-value pair for each property to update inside the payload attribute, for example:
The body received must include the `sObjectName` and `sObjectId` properties.
`{ "payload": { "Phone": "1234567890", "Name": "Antonia" } }`
The body received must include the `sObjectName` and `sObjectId` properties, for example:
`{ "payload": { "Phone": "1234567890", "Name": "Antonia" }, "sObjectId": "sObjectId", "sObjectName": "sObjectName" }`
required:
- sObjectName
- sObjectId
- clientId
- clientSecret
- userName
- password
type: object
properties:
sObjectName:
title: Object Name
description: The type of the Salesforce object. Required if using a key-value pair.
type: string
example: Contact
sObjectId:
title: Object Id
description: The ID of the Salesforce object. Required if using a key-value pair.
type: string
loginUrl:
title: Login URL
description: The Salesforce instance login URL.
Expand Down Expand Up @@ -91,6 +84,9 @@ spec:
in:
mediaType: application/json
dependencies:
- "camel:core"
- "camel:jsonpath"
- "camel:jackson"
- "camel:salesforce"
- "camel:kamelet"
template:
Expand All @@ -103,12 +99,17 @@ spec:
userName: "{{userName}}"
password: "{{password}}"
loginUrl: "{{loginUrl}}"
from:
from:
uri: kamelet:source
steps:
- to:
uri: "{{local-salesforce}}:updateSObject"
parameters:
sObjectId: "{{sObjectId}}"
sObjectName: "{{sObjectName}}"
rawPayload: "true"
- set-property:
name: sObjectId
jsonpath: "$['sObjectId']"
- set-property:
name: sObjectName
jsonpath: "$['sObjectName']"
- transform:
jsonpath: "$['payload']"
- marshal:
json: {}
- toD: "{{local-salesforce}}:updateSObject?sObjectId=${exchangeProperty.sObjectId}&sObjectName=${exchangeProperty.sObjectName}&rawPayload=true"
8 changes: 5 additions & 3 deletions test/salesforce-sink/direct-to-salesforce-update-binding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ spec:
period: 60000
message: |-
{
"Phone": "1234567890"
"payload": {
"Phone": "1234567890"
},
"sObjectId": "Contact",
"sObjectName": "Contact"
}
sink:
ref:
Expand All @@ -41,5 +45,3 @@ spec:
clientSecret: "${client_secret}"
userName: "${userName}"
password: "${password}"
sObjectId: "${id}"
sObjectName: "Contact"

0 comments on commit c2a8159

Please sign in to comment.