Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions components/smslink_nc/actions/create-contact/create-contact.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import app from "../../smslink_nc.app.mjs";

export default {
key: "smslink_nc-create-contact",
name: "Create Contact",
description: "Create a new contact. [See the documentation](https://api.smslink.nc/api/documentation#/Contact/556b84f384422939a9db51e60685798a).",
version: "0.0.1",
type: "action",
props: {
app,
phoneNumber: {
type: "string",
label: "Phone Number",
description: "The phone number of the contact.",
},
email: {
type: "string",
label: "Email",
description: "The email of the contact.",
optional: true,
},
firstName: {
type: "string",
label: "First Name",
description: "The first name of the contact.",
optional: true,
},
lastName: {
type: "string",
label: "Last Name",
description: "The last name of the contact.",
optional: true,
},
param1: {
type: "string",
label: "Param 1",
description: "Custom parameter 1.",
optional: true,
},
param2: {
type: "string",
label: "Param 2",
description: "Custom parameter 2.",
optional: true,
},
param3: {
type: "string",
label: "Param 3",
description: "Custom parameter 3.",
optional: true,
},
},
methods: {
createContact(args = {}) {
return this.app.post({
path: "/contact",
...args,
});
},
},
async run({ $ }) {
const {
createContact,
phoneNumber,
email,
firstName,
lastName,
param1,
param2,
param3,
} = this;

const response = await createContact({
$,
data: {
contacts: [
{
phone_number: phoneNumber,
email,
first_name: firstName,
last_name: lastName,
param_1: param1,
param_2: param2,
param_3: param3,
},
],
},
});
$.export("$summary", "Successfully created a new contact.");
return response;
},
};
53 changes: 53 additions & 0 deletions components/smslink_nc/actions/delete-contact/delete-contact.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import app from "../../smslink_nc.app.mjs";

export default {
key: "smslink_nc-delete-contact",
name: "Delete Contact",
description: "Deletes a contact. [See the documentation](https://api.smslink.nc/api/documentation)",
version: "0.0.1",
type: "action",
props: {
app,
phoneNumber: {
label: "Contact Phone Number",
description: "The phone number of the contact to delete.",
propDefinition: [
app,
"contactId",
() => ({
mapper: ({
phone_number: value, first_name: firstName, last_name: lastName,
}) => ({
value,
label: `${firstName || ""} ${lastName || ""} (${value})`.trim(),
}),
}),
],
},
},
methods: {
deleteContact(args = {}) {
return this.app.delete({
path: "/contact",
...args,
});
},
},
async run({ $ }) {
const {
deleteContact,
phoneNumber,
} = this;

const response = await deleteContact({
$,
data: {
phone_numbers: [
phoneNumber,
],
},
});
$.export("$summary", "Successfully deleted contact.");
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import app from "../../smslink_nc.app.mjs";

export default {
key: "smslink_nc-delete-sms-campaign",
name: "Delete SMS Campaign",
description: "Delete an existing SMS campaign. [See the documentation](https://api.smslink.nc/api/documentation)",
version: "0.0.1",
type: "action",
props: {
app,
campaignId: {
propDefinition: [
app,
"campaignId",
],
},
},
methods: {
deleteCampaign({
campaignId, ...args
} = {}) {
return this.app.delete({
path: `/sms-campaign/${campaignId}`,
...args,
});
},
},
async run({ $ }) {
const {
deleteCampaign,
campaignId,
} = this;

await deleteCampaign({
$,
campaignId,
params: {
by: "id",
},
});

$.export("$summary", "Successfully deleted SMS campaign.");
return {
sucess: true,
};
},
};
7 changes: 5 additions & 2 deletions components/smslink_nc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/smslink_nc",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream SMSlink nc Components",
"main": "smslink_nc.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "3.0.3"
}
}
}
80 changes: 76 additions & 4 deletions components/smslink_nc/smslink_nc.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,83 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "smslink_nc",
propDefinitions: {},
propDefinitions: {
contactId: {
type: "string",
label: "Contact ID",
description: "The ID of the contact to delete or manipulate.",
async options({
mapper = ({
id: value, phone_number: phoneNumber, first_name: firstName, last_name: lastName,
}) => ({
value,
label: `${firstName || ""} ${lastName || ""} (${phoneNumber})`.trim(),
}),
}) {
const { object: { data } } = await this.getContacts();
return data.map(mapper);
},
},
campaignId: {
type: "string",
label: "Campaign ID",
description: "The ID of the SMS campaign to delete or manipulate.",
async options() {
const { object: { data } } = await this.getSMSCampaigns();
return data.map(({
id: value, title: label,
}) => ({
value,
label,
}));
},
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
getUrl(path) {
return `https://api.smslink.nc/api${path}`;
},
getHeaders(headers) {
return {
Accept: "application/json",
Authorization: `Bearer ${this.$auth.personal_access_token}`,
...headers,
};
},
_makeRequest({
$ = this, path, headers, ...args
} = {}) {
return axios($, {
...args,
url: this.getUrl(path),
headers: this.getHeaders(headers),
});
},
post(args = {}) {
return this._makeRequest({
method: "POST",
...args,
});
},
delete(args = {}) {
return this._makeRequest({
method: "DELETE",
...args,
});
},
getContacts(args = {}) {
return this._makeRequest({
path: "/contact",
...args,
});
},
getSMSCampaigns(args = {}) {
return this._makeRequest({
path: "/sms-campaign",
...args,
});
},
},
};
5 changes: 4 additions & 1 deletion pnpm-lock.yaml

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

Loading