Skip to content

Commit

Permalink
Update Zoho Survey per feedback from their team (#12644)
Browse files Browse the repository at this point in the history
* updates

* update
  • Loading branch information
michelle0927 committed Jul 2, 2024
1 parent 4e2a709 commit 85e229a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
2 changes: 1 addition & 1 deletion components/zoho_survey/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/zoho_survey",
"version": "0.1.2",
"version": "0.1.3",
"description": "Pipedream Zoho Survey Components",
"main": "zoho_survey.app.mjs",
"keywords": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default {
key: "zoho_survey-new-survey-response",
name: "New Survey Response (Instant)",
description: "Emit new event when a new survey response is received in Zoho Surveys.",
version: "0.0.3",
version: "0.0.4",
type: "source",
dedupe: "unique",
methods: {
Expand All @@ -25,19 +25,33 @@ export default {
},
collectFieldLabels(obj) {
const labels = {};
function recursiveSearch(obj) {
function recursiveSearch(obj, primaryLabel) {
if (Array.isArray(obj)) {
obj.forEach((item) => recursiveSearch(item));
} else if (obj && typeof obj === "object") {
if ("label" in obj && "key" in obj) {
labels[obj.key] = obj.label;
}
Object.values(obj).forEach((value) => recursiveSearch(value));
obj.forEach((question) => recursiveSearch(question, primaryLabel));
}
if ("variables" in obj && "label" in obj) {
recursiveSearch(obj.variables, `${primaryLabel
? primaryLabel + " - "
: ""}${obj.label}`);
}
if ("label" in obj && "key" in obj) {
labels[obj.key] = `${primaryLabel
? primaryLabel + " - "
: ""}${obj.label}`;
}
}
recursiveSearch(obj);
return labels;
},
formatValue(value) {
return typeof value === "string"
? decode(value)
: Array.isArray(value)
? value.map((v) => v
? decode(v)
: "")
: "";
},
async formatResponse(body) {
const { variables } = await this.zohoSurvey.listSurveyFields({
portalId: this.portalId,
Expand All @@ -58,9 +72,9 @@ export default {
response[key] = labels[key]
? {
label: decode(labels[key]),
value: decode(value),
value: this.formatValue(value),
}
: decode(value);
: this.formatValue(value);
}
for (const [
key,
Expand All @@ -69,6 +83,7 @@ export default {
if (!response[key]) {
response[key] = {
label: decode(value),
value: "",
};
}
}
Expand Down

0 comments on commit 85e229a

Please sign in to comment.