Skip to content

Commit aa3f670

Browse files
committed
init
1 parent 88c121a commit aa3f670

File tree

4 files changed

+53
-49
lines changed

4 files changed

+53
-49
lines changed

components/daktela/actions/create-account/create-account.mjs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import daktela from "../../daktela.app.mjs";
2-
import { axios } from "@pipedream/platform";
32

43
export default {
54
key: "daktela-create-account",
@@ -53,16 +52,17 @@ export default {
5352
},
5453
},
5554
async run({ $ }) {
56-
const params = {
57-
user: this.user,
58-
sla: this.sla,
59-
survey: this.survey,
60-
name: this.name,
61-
title: this.title,
62-
description: this.description,
63-
};
64-
65-
const response = await this.daktela.createAccount(params);
55+
const response = await this.daktela.createAccount({
56+
$,
57+
data: {
58+
user: this.user,
59+
sla: this.sla,
60+
survey: this.survey,
61+
name: this.name,
62+
title: this.title,
63+
description: this.description,
64+
},
65+
});
6666

6767
$.export("$summary", `Successfully created account: ${response.title}`);
6868
return response;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const LIMIT = 100;

components/daktela/daktela.app.mjs

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { axios } from "@pipedream/platform";
2+
import { LIMIT } from "./common/constants.mjs";
23

34
export default {
45
type: "app",
@@ -8,8 +9,13 @@ export default {
89
type: "string",
910
label: "User",
1011
description: "The user associated with the account",
11-
async options() {
12-
const users = await this.getUsers();
12+
async options({ page }) {
13+
const users = await this.getUsers({
14+
params: {
15+
take: LIMIT,
16+
skip: LIMIT * page,
17+
},
18+
});
1319
return users.map((user) => ({
1420
label: user.name,
1521
value: user.id,
@@ -20,31 +26,26 @@ export default {
2026
type: "integer",
2127
label: "SLA",
2228
description: "The SLA ID for the account",
23-
optional: true,
2429
},
2530
survey: {
2631
type: "boolean",
2732
label: "Survey",
2833
description: "Indicate if a survey should be sent",
29-
optional: true,
3034
},
3135
name: {
3236
type: "string",
3337
label: "Name",
3438
description: "Unique identification for the account",
35-
optional: true,
3639
},
3740
title: {
3841
type: "string",
3942
label: "Title",
4043
description: "Display name for the account",
41-
optional: true,
4244
},
4345
description: {
4446
type: "string",
4547
label: "Description",
4648
description: "Optional description for the account",
47-
optional: true,
4849
},
4950
receiverNumber: {
5051
type: "string",
@@ -60,7 +61,6 @@ export default {
6061
type: "string",
6162
label: "Sender's Name",
6263
description: "Optional sender's name for the SMS",
63-
optional: true,
6464
},
6565
phoneNumber: {
6666
type: "string",
@@ -69,60 +69,60 @@ export default {
6969
},
7070
callerNumber: {
7171
type: "string",
72-
label: "Callers Number",
72+
label: "Caller's Number",
7373
description: "The number being used to make the call",
74-
optional: true,
7574
},
7675
callingTime: {
7776
type: "string",
7877
label: "Calling Time",
7978
description: "Time to initiate the call",
80-
optional: true,
8179
},
8280
},
8381
methods: {
84-
_baseUrl() {
85-
return "https://customer.daktela.com/api/v6";
86-
},
87-
async _makeRequest(opts = {}) {
88-
const {
89-
$ = this, method = "GET", path = "/", headers, ...otherOpts
90-
} = opts;
91-
return axios($, {
92-
...otherOpts,
93-
method,
94-
url: this._baseUrl() + path,
95-
headers: {
96-
...headers,
97-
"Content-Type": "application/json",
98-
"Authorization": `Bearer ${this.$auth.access_token}`,
99-
},
100-
});
82+
_baseUrl(version = "v5.0") {
83+
return `${this.$auth.instance_url}/api/${version}`;
84+
},
85+
_params(params = {}) {
86+
return {
87+
...params,
88+
"Authorization": `Bearer ${this.$auth.access_token}`,
89+
};
90+
},
91+
_makeRequest({
92+
$ = this, path, version, params, ...opts
93+
}) {
94+
const config = {
95+
url: this._baseUrl(version) + path,
96+
params: this._params(params),
97+
...opts,
98+
};
99+
console.log("config: ", config);
100+
return axios($, config);
101101
},
102-
async createAccount(params) {
102+
createAccount(opts = {}) {
103103
return this._makeRequest({
104104
method: "POST",
105-
path: "/accounts",
106-
data: params,
105+
path: "/accounts.json",
106+
...opts,
107107
});
108108
},
109-
async sendSms(params) {
109+
sendSms(opts = {}) {
110110
return this._makeRequest({
111111
method: "POST",
112112
path: "/sms_activities",
113-
data: params,
113+
...opts,
114114
});
115115
},
116-
async initiateCall(params) {
116+
initiateCall(opts = {}) {
117117
return this._makeRequest({
118118
method: "POST",
119119
path: "/call_activities",
120-
data: params,
120+
...opts,
121121
});
122122
},
123-
async getUsers(opts = {}) {
123+
getUsers(opts = {}) {
124124
return this._makeRequest({
125-
path: "/users",
125+
path: "/users.json",
126126
...opts,
127127
});
128128
},

components/daktela/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/daktela",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Daktela Components",
55
"main": "daktela.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.0.3"
1417
}
1518
}

0 commit comments

Comments
 (0)