Skip to content

Commit

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

* pnpm-lock.yaml

* bug fix

* bug fix
  • Loading branch information
michelle0927 committed Jun 21, 2024
1 parent d5566ea commit 18907e1
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "zoho_survey-send-email-invitation",
name: "Send Email Invitation",
description: "Sends an email invitation with Zoho Survey.",
version: "0.0.2",
version: "0.0.3",
type: "action",
props: {
zohoSurvey,
Expand Down
5 changes: 3 additions & 2 deletions 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.1",
"version": "0.1.2",
"description": "Pipedream Zoho Survey Components",
"main": "zoho_survey.app.mjs",
"keywords": [
Expand All @@ -13,6 +13,7 @@
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^1.5.1"
"@pipedream/platform": "^1.5.1",
"html-entities-decoder": "^1.0.5"
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import common from "../common/base.mjs";
import decode from "html-entities-decoder";
import sampleEmit from "./test-event.mjs";

export default {
...common,
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.2",
version: "0.0.3",
type: "source",
dedupe: "unique",
methods: {
Expand All @@ -17,8 +18,8 @@ export default {
generateMeta(response) {
const ts = Date.now();
return {
id: `${response["Response ID"]}${ts}`,
summary: `New Response ${response["Response ID"]}`,
id: `${response["RESPONSE_ID"]}${ts}`,
summary: `New Response ${response["RESPONSE_ID"]}`,
ts,
};
},
Expand All @@ -28,7 +29,7 @@ export default {
if (Array.isArray(obj)) {
obj.forEach((item) => recursiveSearch(item));
} else if (obj && typeof obj === "object") {
if ("label" in obj) {
if ("label" in obj && "key" in obj) {
labels[obj.key] = obj.label;
}
Object.values(obj).forEach((value) => recursiveSearch(value));
Expand All @@ -43,17 +44,32 @@ export default {
groupId: this.groupId,
surveyId: this.surveyId,
});
const labels = this.collectFieldLabels(variables);
const questions = (variables.find(({ label }) => label === "Questions"))?.variables;
const respondentVariables = (variables.find(({ label }) => label == "Respondent Variables"))?.variables;
if (respondentVariables?.length) {
questions.push(...respondentVariables);
}
const labels = this.collectFieldLabels(questions);
const response = {};
for (const [
key,
value,
] of Object.entries(body)) {
response[labels[key]] = value;
response[key] = labels[key]
? {
label: decode(labels[key]),
value: decode(value),
}
: decode(value);
}
for (const label of Object.values(labels)) {
if (!response[label]) {
response[label] = "";
for (const [
key,
value,
] of Object.entries(labels)) {
if (!response[key]) {
response[key] = {
label: decode(value),
};
}
}
return response;
Expand Down
11 changes: 6 additions & 5 deletions components/zoho_survey/zoho_survey.app.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { axios } from "@pipedream/platform";
import decode from "html-entities-decoder";
const DEFAULT_LIMIT = 50;

export default {
Expand All @@ -15,7 +16,7 @@ export default {
portalId: value, portalName: label,
}) => ({
value,
label,
label: decode(label),
})) || [];
},
},
Expand All @@ -30,7 +31,7 @@ export default {
groupUniqueId: value, name: label,
}) => ({
value,
label,
label: decode(label),
}));
},
},
Expand All @@ -56,7 +57,7 @@ export default {
id: value, name: label,
}) => ({
value,
label,
label: decode(label),
})) || [];
},
},
Expand All @@ -76,7 +77,7 @@ export default {
id: value, name: label,
}) => ({
value,
label,
label: decode(label),
})) || [];
},
},
Expand All @@ -100,7 +101,7 @@ export default {
id: value, name: label,
}) => ({
value,
label,
label: decode(label),
})) || [];
},
},
Expand Down
18 changes: 12 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 18907e1

Please sign in to comment.