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
19 changes: 19 additions & 0 deletions components/cliento/actions/get-ref-data/get-ref-data.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import cliento from "../../cliento.app.mjs";

export default {
key: "cliento-get-ref-data",
name: "Get Reference Data",
description: "Fetch services, resources and mappings for the booking widget. [See the documentation](https://developers.cliento.com/docs/rest-api#fetch-ref-data)",
version: "0.0.1",
type: "action",
props: {
cliento,
},
async run({ $ }) {
const response = await this.cliento.fetchRefData({
$,
});
$.export("$summary", "Successfully fetched reference data");
return response;
},
};
19 changes: 19 additions & 0 deletions components/cliento/actions/get-settings/get-settings.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import cliento from "../../cliento.app.mjs";

export default {
key: "cliento-get-settings",
name: "Fetch Settings",
description: "Fetch settings and features for the booking widget. [See the documentation](https://developers.cliento.com/docs/rest-api#fetch-settings)",
version: "0.0.1",
type: "action",
props: {
cliento,
},
async run({ $ }) {
const response = await this.cliento.fetchSettings({
$,
});
$.export("$summary", "Successfully fetched settings");
return response;
},
};
53 changes: 53 additions & 0 deletions components/cliento/actions/get-slots/get-slots.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import cliento from "../../cliento.app.mjs";

export default {
key: "cliento-get-slots",
name: "Get Slots",
description: "Fetch available slots for the given service, resource and dates. [See the documentation](https://developers.cliento.com/docs/rest-api#fetch-slots)",
version: "0.0.1",
type: "action",
props: {
cliento,
fromDate: {
propDefinition: [
cliento,
"fromDate",
],
},
toDate: {
propDefinition: [
cliento,
"toDate",
],
},
resourceIds: {
propDefinition: [
cliento,
"resourceIds",
],
},
serviceIds: {
propDefinition: [
cliento,
"serviceIds",
],
},
},
async run({ $ }) {
const response = await this.cliento.fetchSlots({
$,
params: {
fromDate: this.fromDate,
toDate: this.toDate,
resIds: this.resourceIds.join(),
srvIds: this.serviceIds.join(),
},
});
if (response?.length) {
$.export("$summary", `Successfully fetched ${response.length} slot${response.length === 1
? ""
: "s"}`);
}
return response;
},
};
82 changes: 77 additions & 5 deletions components/cliento/cliento.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: "cliento",
propDefinitions: {},
propDefinitions: {
fromDate: {
type: "string",
label: "From Date",
description: "The start date for the booking period (format: YYYY-MM-DD)",
},
toDate: {
type: "string",
label: "To Date",
description: "The end date for the booking period (format: YYYY-MM-DD)",
},
resourceIds: {
type: "string[]",
label: "Resource IDs",
description: "The IDs of the resources for the booking",
async options() {
const { resources } = await this.fetchRefData();
return resources?.map(({
id: value, name: label,
}) => ({
value,
label,
})) || [];
},
},
serviceIds: {
type: "string[]",
label: "Service IDs",
description: "The IDs of the services for the booking",
async options() {
const { services } = await this.fetchRefData();
return services?.map(({
serviceId: value, name: label,
}) => ({
value,
label,
})) || [];
},
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return `https://cliento.com/api/v2/partner/cliento/${this.$auth.account_id}`;
},
_makeRequest(opts = {}) {
const {
$ = this,
path,
...otherOpts
} = opts;
return axios($, {
...otherOpts,
url: `${this._baseUrl()}${path}`,
headers: {
Accept: "application/json",
},
});
},
fetchSettings(opts = {}) {
return this._makeRequest({
path: "/settings/",
...opts,
});
},
fetchRefData(opts = {}) {
return this._makeRequest({
path: "/ref-data/",
...opts,
});
},
fetchSlots(opts = {}) {
return this._makeRequest({
path: "/resources/slots",
...opts,
});
},
},
};
};
7 changes: 5 additions & 2 deletions components/cliento/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/cliento",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream Cliento Components",
"main": "cliento.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"
}
}
}
107 changes: 55 additions & 52 deletions pnpm-lock.yaml

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

Loading