Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
remoteretrieval committed Aug 29, 2024
1 parent 868f8f6 commit 3d5a9f7
Show file tree
Hide file tree
Showing 275 changed files with 17,623 additions and 20 deletions.
28 changes: 28 additions & 0 deletions components/_8x8_connect/actions/get-log-result/get-log-result.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import app from "../../_8x8_connect.app.mjs";

export default {
key: "_8x8_connect-get-log-result",
name: "Get Log Result",
description: "Check the status of an SMS Logs export job and to get a download link if its generation has succeeded. [See the documentation](https://developer.8x8.com/connect/reference/get-log-export-job-result)",
version: "0.0.1",
type: "action",
props: {
app,
jobId: {
propDefinition: [
app,
"jobId",
],
},
},
async run({ $ }) {
const response = await this.app.getLog({
$,
jobId: this.jobId,
});

$.export("$summary", `Successfully retrieved the log status: '${response.status}'`);

return response;
},
};
45 changes: 45 additions & 0 deletions components/_8x8_connect/actions/request-log/request-log.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import app from "../../_8x8_connect.app.mjs";

export default {
key: "_8x8_connect-request-log",
name: "Request Log",
description: "Request an SMS log file. [See the documentation](https://developer.8x8.com/connect/reference/start-log-export-job)",
version: "0.0.4",
type: "action",
props: {
app,
destination: {
propDefinition: [
app,
"destination",
],
optional: true,
},
from: {
propDefinition: [
app,
"from",
],
},
to: {
propDefinition: [
app,
"to",
],
},
},
async run({ $ }) {
const response = await this.app.requestLog({
$,
data: {
phoneNumber: this.destination,
from: this.from,
to: this.to,
},
});

$.export("$summary", `Successfully requested SMS log. You will need the following ID get the request result: '${response.jobId}'`);

return response;
},
};
38 changes: 38 additions & 0 deletions components/_8x8_connect/actions/send-sms/send-sms.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import app from "../../_8x8_connect.app.mjs";

export default {
key: "_8x8_connect-send-sms",
name: "Send SMS",
description: "Send a SMS to the specified destination. [See the documentation](https://developer.8x8.com/connect/reference/send-sms-single)",
version: "0.0.2",
type: "action",
props: {
app,
destination: {
propDefinition: [
app,
"destination",
],
},
text: {
propDefinition: [
app,
"text",
],
},

},
async run({ $ }) {
const response = await this.app.sendSms({
$,
data: {
destination: this.destination,
text: this.text,
},
});

$.export("$summary", `Successfully queued SMS for processing. ID: '${response.umid}'`);

return response;
},
};
67 changes: 67 additions & 0 deletions components/activecalculator/activecalculator.app.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { axios } from "@pipedream/platform";
import { LIMIT } from "./common/constants.mjs";

export default {
type: "app",
app: "activecalculator",
propDefinitions: {
calculatorIds: {
type: "string[]",
label: "Calculator Ids",
description: "A list of calculator's Ids.",
async options({ page }) {
const { data } = await this.listCalculators({
params: {
limit: LIMIT,
offset: LIMIT * page,
},
});

return data.map(({
id: value, name: label,
}) => ({
label,
value,
}));
},
},
},
methods: {
_baseUrl() {
return "https://app.activecalculator.com/api/v1";
},
_headers() {
return {
"x-ac-api-key": `${this.$auth.api_key}`,
};
},
_makeRequest({
$ = this, path, ...opts
}) {
return axios($, {
url: this._baseUrl() + path,
headers: this._headers(),
...opts,
});
},
listCalculators(opts = {}) {
return this._makeRequest({
path: "/calculators",
...opts,
});
},
createWebhook(opts = {}) {
return this._makeRequest({
method: "POST",
path: "/webhooks",
...opts,
});
},
deleteWebhook(webhookId) {
return this._makeRequest({
method: "DELETE",
path: `/webhooks/${webhookId}`,
});
},
},
};
1 change: 1 addition & 0 deletions components/activecalculator/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const LIMIT = 100;
24 changes: 24 additions & 0 deletions components/activecalculator/common/utils.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export const parseObject = (obj) => {
if (!obj) return undefined;

if (Array.isArray(obj)) {
return obj.map((item) => {
if (typeof item === "string") {
try {
return JSON.parse(item);
} catch (e) {
return item;
}
}
return item;
});
}
if (typeof obj === "string") {
try {
return JSON.parse(obj);
} catch (e) {
return obj;
}
}
return obj;
};
19 changes: 19 additions & 0 deletions components/activecalculator/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "@pipedream/activecalculator",
"version": "0.1.0",
"description": "Pipedream ActiveCalculator Components",
"main": "activecalculator.app.mjs",
"keywords": [
"pipedream",
"activecalculator"
],
"homepage": "https://pipedream.com/apps/activecalculator",
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.0"
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import activecalculator from "../../activecalculator.app.mjs";
import { parseObject } from "../../common/utils.mjs";
import sampleEmit from "./test-event.mjs";

export default {
key: "activecalculator-new-submission-instant",
name: "New Submission (Instant)",
description: "Emit new event when there's a new submission.",
version: "0.0.1",
type: "source",
dedupe: "unique",
props: {
activecalculator,
http: {
type: "$.interface.http",
customResponse: false,
},
db: "$.service.db",
name: {
type: "string",
label: "Name",
description: "The name of the webhook.",
optional: true,
},
calculatorIds: {
propDefinition: [
activecalculator,
"calculatorIds",
],
},
},
hooks: {
async activate() {
const { data } = await this.activecalculator.createWebhook({
data: {
url: this.http.endpoint,
name: this.name,
source: "pipedream",
triggers: [
"newSubmission",
],
calculators: parseObject(this.calculatorIds),
},
});
this.db.set("webhookId", data.id);
},
async deactivate() {
const webhookId = this.db.get("webhookId");
if (webhookId) {
await this.activecalculator.deleteWebhook(webhookId);
}
},
},
async run({ body }) {
this.$emit(body, {
id: body.data.id,
summary: `New Submission: ${body.data.id}`,
ts: Date.parse(body.data.createdAt),
});
},
sampleEmit,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
export default {
"webhookId": "cm02xzoe0cdm287pcs",
"event": "newSubmission",
"data": {
"id": "cm02xzoe0cdm287pcs",
"createdAt": "2024-08-20T21:34:07.076Z",
"updatedAt": "2024-08-20T21:34:07.076Z",
"calculatorId": "cm02xzoe0cdm287pcs",
"finished": true,
"data": {
"UHvky": "[email protected]",
"tWKDQ": {
"id": "cm02xzoe0cdm287pcs",
"value": 1,
"label": "Basic"
},
"cm02xzoe0cdm287pcs": 10,
"cm02xzoe0cdm287pcs": 100,
"cm02xzoe0cdm287pcs": 10
},
"meta": {
"source": "",
"url": "https://my.activecalculator.com/cm02xzoe0cdm287pcs",
"userAgent": {
"browser": "Chrome",
"os": "Windows"
},
"country": "BR"
}
}
}
Loading

0 comments on commit 3d5a9f7

Please sign in to comment.