forked from PipedreamHQ/pipedream
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
868f8f6
commit 3d5a9f7
Showing
275 changed files
with
17,623 additions
and
20 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
components/_8x8_connect/actions/get-log-result/get-log-result.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
45
components/_8x8_connect/actions/request-log/request-log.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}`, | ||
}); | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const LIMIT = 100; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} | ||
|
62 changes: 62 additions & 0 deletions
62
components/activecalculator/sources/new-submission-instant/new-submission-instant.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}; |
31 changes: 31 additions & 0 deletions
31
components/activecalculator/sources/new-submission-instant/test-event.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} | ||
} |
Oops, something went wrong.