This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-kamelets.git
The following commit(s) were added to refs/heads/main by this push:
new 8c0162b0 fix: salesforce update kamelet fix
8c0162b0 is described below
commit 8c0162b0d10b6aa788b0bc7462ff43fc586511f9
Author: Matheusafonsouza <[email protected]>
AuthorDate: Tue Jan 17 16:17:32 2023 -0300
fix: salesforce update kamelet fix
---
kamelets/salesforce-update-sink.kamelet.yaml | 39 +++++++++++-----------
.../kamelets/salesforce-update-sink.kamelet.yaml | 39 +++++++++++-----------
.../direct-to-salesforce-update-binding.yaml | 8 +++--
3 files changed, 45 insertions(+), 41 deletions(-)
diff --git a/kamelets/salesforce-update-sink.kamelet.yaml
b/kamelets/salesforce-update-sink.kamelet.yaml
index d87504d8..be056ee8 100644
--- a/kamelets/salesforce-update-sink.kamelet.yaml
+++ b/kamelets/salesforce-update-sink.kamelet.yaml
@@ -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.
@@ -91,6 +84,9 @@ spec:
in:
mediaType: application/json
dependencies:
+ - "camel:core"
+ - "camel:jsonpath"
+ - "camel:jackson"
- "camel:salesforce"
- "camel:kamelet"
template:
@@ -106,9 +102,14 @@ spec:
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"
diff --git
a/library/camel-kamelets/src/main/resources/kamelets/salesforce-update-sink.kamelet.yaml
b/library/camel-kamelets/src/main/resources/kamelets/salesforce-update-sink.kamelet.yaml
index d87504d8..be056ee8 100644
---
a/library/camel-kamelets/src/main/resources/kamelets/salesforce-update-sink.kamelet.yaml
+++
b/library/camel-kamelets/src/main/resources/kamelets/salesforce-update-sink.kamelet.yaml
@@ -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.
@@ -91,6 +84,9 @@ spec:
in:
mediaType: application/json
dependencies:
+ - "camel:core"
+ - "camel:jsonpath"
+ - "camel:jackson"
- "camel:salesforce"
- "camel:kamelet"
template:
@@ -106,9 +102,14 @@ spec:
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"
diff --git a/test/salesforce-sink/direct-to-salesforce-update-binding.yaml
b/test/salesforce-sink/direct-to-salesforce-update-binding.yaml
index f0fdbaa7..102793fb 100644
--- a/test/salesforce-sink/direct-to-salesforce-update-binding.yaml
+++ b/test/salesforce-sink/direct-to-salesforce-update-binding.yaml
@@ -29,7 +29,11 @@ spec:
period: 60000
message: |-
{
- "Phone": "1234567890"
+ "payload": {
+ "Phone": "1234567890"
+ },
+ "sObjectId": "Contact",
+ "sObjectName": "Contact"
}
sink:
ref:
@@ -41,5 +45,3 @@ spec:
clientSecret: "${client_secret}"
userName: "${userName}"
password: "${password}"
- sObjectId: "${id}"
- sObjectName: "Contact"