Skip to content

Commit d782540

Browse files
committed
Merge remote-tracking branch 'origin/master' into issue-14212
2 parents f5b9468 + fec69d7 commit d782540

File tree

12 files changed

+334
-15
lines changed

12 files changed

+334
-15
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import cliento from "../../cliento.app.mjs";
2+
3+
export default {
4+
key: "cliento-get-ref-data",
5+
name: "Get Reference Data",
6+
description: "Fetch services, resources and mappings for the booking widget. [See the documentation](https://developers.cliento.com/docs/rest-api#fetch-ref-data)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
cliento,
11+
},
12+
async run({ $ }) {
13+
const response = await this.cliento.fetchRefData({
14+
$,
15+
});
16+
$.export("$summary", "Successfully fetched reference data");
17+
return response;
18+
},
19+
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import cliento from "../../cliento.app.mjs";
2+
3+
export default {
4+
key: "cliento-get-settings",
5+
name: "Fetch Settings",
6+
description: "Fetch settings and features for the booking widget. [See the documentation](https://developers.cliento.com/docs/rest-api#fetch-settings)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
cliento,
11+
},
12+
async run({ $ }) {
13+
const response = await this.cliento.fetchSettings({
14+
$,
15+
});
16+
$.export("$summary", "Successfully fetched settings");
17+
return response;
18+
},
19+
};
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import cliento from "../../cliento.app.mjs";
2+
3+
export default {
4+
key: "cliento-get-slots",
5+
name: "Get Slots",
6+
description: "Fetch available slots for the given service, resource and dates. [See the documentation](https://developers.cliento.com/docs/rest-api#fetch-slots)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
cliento,
11+
fromDate: {
12+
propDefinition: [
13+
cliento,
14+
"fromDate",
15+
],
16+
},
17+
toDate: {
18+
propDefinition: [
19+
cliento,
20+
"toDate",
21+
],
22+
},
23+
resourceIds: {
24+
propDefinition: [
25+
cliento,
26+
"resourceIds",
27+
],
28+
},
29+
serviceIds: {
30+
propDefinition: [
31+
cliento,
32+
"serviceIds",
33+
],
34+
},
35+
},
36+
async run({ $ }) {
37+
const response = await this.cliento.fetchSlots({
38+
$,
39+
params: {
40+
fromDate: this.fromDate,
41+
toDate: this.toDate,
42+
resIds: this.resourceIds.join(),
43+
srvIds: this.serviceIds.join(),
44+
},
45+
});
46+
if (response?.length) {
47+
$.export("$summary", `Successfully fetched ${response.length} slot${response.length === 1
48+
? ""
49+
: "s"}`);
50+
}
51+
return response;
52+
},
53+
};

components/cliento/cliento.app.mjs

Lines changed: 76 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,83 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "cliento",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
fromDate: {
8+
type: "string",
9+
label: "From Date",
10+
description: "The start date for the booking period (format: YYYY-MM-DD)",
11+
},
12+
toDate: {
13+
type: "string",
14+
label: "To Date",
15+
description: "The end date for the booking period (format: YYYY-MM-DD)",
16+
},
17+
resourceIds: {
18+
type: "string[]",
19+
label: "Resource IDs",
20+
description: "The IDs of the resources for the booking",
21+
async options() {
22+
const { resources } = await this.fetchRefData();
23+
return resources?.map(({
24+
id: value, name: label,
25+
}) => ({
26+
value,
27+
label,
28+
})) || [];
29+
},
30+
},
31+
serviceIds: {
32+
type: "string[]",
33+
label: "Service IDs",
34+
description: "The IDs of the services for the booking",
35+
async options() {
36+
const { services } = await this.fetchRefData();
37+
return services?.map(({
38+
serviceId: value, name: label,
39+
}) => ({
40+
value,
41+
label,
42+
})) || [];
43+
},
44+
},
45+
},
546
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
47+
_baseUrl() {
48+
return `https://cliento.com/api/v2/partner/cliento/${this.$auth.account_id}`;
49+
},
50+
_makeRequest(opts = {}) {
51+
const {
52+
$ = this,
53+
path,
54+
...otherOpts
55+
} = opts;
56+
return axios($, {
57+
...otherOpts,
58+
url: `${this._baseUrl()}${path}`,
59+
headers: {
60+
Accept: "application/json",
61+
},
62+
});
63+
},
64+
fetchSettings(opts = {}) {
65+
return this._makeRequest({
66+
path: "/settings/",
67+
...opts,
68+
});
69+
},
70+
fetchRefData(opts = {}) {
71+
return this._makeRequest({
72+
path: "/ref-data/",
73+
...opts,
74+
});
75+
},
76+
fetchSlots(opts = {}) {
77+
return this._makeRequest({
78+
path: "/resources/slots",
79+
...opts,
80+
});
981
},
1082
},
1183
};

components/cliento/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/cliento",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Cliento Components",
55
"main": "cliento.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
}
15-
}
18+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export default {
2+
type: "app",
3+
app: "franconnect",
4+
propDefinitions: {},
5+
methods: {
6+
// this.$auth contains connected account data
7+
authKeys() {
8+
console.log(Object.keys(this.$auth));
9+
},
10+
},
11+
};
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "@pipedream/franconnect",
3+
"version": "0.0.1",
4+
"description": "Pipedream FranConnect Components",
5+
"main": "franconnect.app.mjs",
6+
"keywords": [
7+
"pipedream",
8+
"franconnect"
9+
],
10+
"homepage": "https://pipedream.com/apps/franconnect",
11+
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
12+
"publishConfig": {
13+
"access": "public"
14+
}
15+
}
Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,41 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "highergov",
4-
propDefinitions: {},
56
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
7+
_baseUrl() {
8+
return "https://www.highergov.com/zapier";
9+
},
10+
_headers() {
11+
return {
12+
"Content-Type": "application/json",
13+
"Accept": "application/json",
14+
"X-API-KEY": this.$auth.api_key,
15+
};
16+
},
17+
_makeRequest({
18+
$ = this, path, ...opts
19+
}) {
20+
return axios($, {
21+
url: this._baseUrl() + path,
22+
headers: this._headers(),
23+
...opts,
24+
});
25+
},
26+
subscribeWebhook(opts = {}) {
27+
return this._makeRequest({
28+
method: "POST",
29+
path: "/pipeline/subscribe/",
30+
...opts,
31+
});
32+
},
33+
unsubscribeWebhook(opts = {}) {
34+
return this._makeRequest({
35+
method: "POST",
36+
path: "/pipeline/unsubscribe/",
37+
...opts,
38+
});
939
},
1040
},
11-
};
41+
};

components/highergov/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/highergov",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream HigherGov Components",
55
"main": "highergov.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.1"
1417
}
15-
}
18+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import highergov from "../../highergov.app.mjs";
2+
import sampleEmit from "./test-event.mjs";
3+
4+
export default {
5+
key: "highergov-new-pursuit-added-instant",
6+
name: "New Pursuit Added (Instant)",
7+
description: "Emit new event when a pursuit is added to the pipeline.",
8+
version: "0.0.1",
9+
type: "source",
10+
dedupe: "unique",
11+
props: {
12+
highergov,
13+
http: {
14+
type: "$.interface.http",
15+
customResponse: true,
16+
},
17+
db: "$.service.db",
18+
},
19+
hooks: {
20+
async activate() {
21+
await this.highergov.subscribeWebhook({
22+
data: {
23+
target_url: this.http.endpoint,
24+
},
25+
});
26+
},
27+
async deactivate() {
28+
await this.highergov.unsubscribeWebhook();
29+
},
30+
},
31+
async run({ body }) {
32+
this.$emit(body, {
33+
id: body.opp_key,
34+
summary: `New pursuit added: ${body.title}`,
35+
ts: Date.parse(body.current_datetime),
36+
});
37+
},
38+
sampleEmit,
39+
};

0 commit comments

Comments
 (0)