Skip to content

Commit 6e9034e

Browse files
authored
Launch27 - new components (#19514)
* wip * new components
1 parent 2595349 commit 6e9034e

File tree

6 files changed

+227
-5
lines changed

6 files changed

+227
-5
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import launch27 from "../../launch27.app.mjs";
2+
3+
export default {
4+
key: "launch27-get-booking-spots",
5+
name: "Get Booking Spots",
6+
description: "Retrieves all booking spots for a given event type. [See the documentation](https://bitbucket.org/awoo23/api-2.0/wiki/Spots_for_booking)",
7+
version: "0.0.1",
8+
type: "action",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: true,
13+
},
14+
props: {
15+
launch27,
16+
date: {
17+
type: "string",
18+
label: "Date",
19+
description: "The date to get booking spots for. Format: YYYY-MM-DD",
20+
},
21+
days: {
22+
type: "integer",
23+
label: "Days",
24+
description: "The number of days you need spots for starting from and including the date",
25+
},
26+
mode: {
27+
type: "string",
28+
label: "Mode",
29+
description: "Affects how available spots calculated: using reschedule booking policy or new booking policy. `new` mode should be used when you need to create new booking. Note: New booking policy is applied, so it is possible to have future spots not available because of the policy. `reschedule` mode should be used when you need to change date and/or time for already existing booking. Note: Booking reschedule policy is applied, so it is possible to have future spots not available because of the policy",
30+
options: [
31+
"new",
32+
"reschedule",
33+
],
34+
},
35+
grid: {
36+
type: "boolean",
37+
label: "Grid",
38+
description: "If `true` response will contain grid and days sections",
39+
optional: true,
40+
},
41+
},
42+
async run({ $ }) {
43+
const response = await this.launch27.getBookingSpots({
44+
$,
45+
data: {
46+
date: this.date,
47+
days: this.days,
48+
mode: this.mode,
49+
grid: this.grid,
50+
},
51+
});
52+
$.export("$summary", "Successfully retrieved booking spots");
53+
return response;
54+
},
55+
};
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import launch27 from "../../launch27.app.mjs";
2+
3+
export default {
4+
key: "launch27-get-next-booking-date",
5+
name: "Get Next Booking Date",
6+
description: "Retrieves the next booking date for a given frequency. [See the documentation](https://bitbucket.org/awoo23/api-2.0/wiki/Next_booking_date_for_frequency)",
7+
version: "0.0.1",
8+
type: "action",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: true,
13+
},
14+
props: {
15+
launch27,
16+
frequencyId: {
17+
propDefinition: [
18+
launch27,
19+
"frequencyId",
20+
],
21+
},
22+
date: {
23+
type: "string",
24+
label: "Date",
25+
description: "The date for which next recurring date should be calculated. Format: YYYY-MM-DDTHH:MM:SS",
26+
},
27+
},
28+
async run({ $ }) {
29+
const response = await this.launch27.getNextBookingDate({
30+
$,
31+
frequencyId: this.frequencyId,
32+
data: {
33+
date: this.date,
34+
},
35+
});
36+
$.export("$summary", "Successfully retrieved next booking date");
37+
return response;
38+
},
39+
};
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import launch27 from "../../launch27.app.mjs";
2+
3+
export default {
4+
key: "launch27-get-policy",
5+
name: "Get Policy",
6+
description: "Retrieves a policy. [See the documentation](https://bitbucket.org/awoo23/api-2.0/wiki/New_booking_policy)",
7+
version: "0.0.1",
8+
type: "action",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: true,
13+
},
14+
props: {
15+
launch27,
16+
type: {
17+
type: "string",
18+
label: "Type",
19+
description: "The type of policy to retrieve",
20+
options: [
21+
"booking",
22+
"reschedule",
23+
"cancellation",
24+
"location",
25+
],
26+
},
27+
},
28+
async run({ $ }) {
29+
const response = await this.launch27.getPolicy({
30+
$,
31+
type: this.type,
32+
});
33+
$.export("$summary", `Successfully retrieved ${this.type} policy`);
34+
return response;
35+
},
36+
};
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import launch27 from "../../launch27.app.mjs";
2+
3+
export default {
4+
key: "launch27-list-services",
5+
name: "List Services",
6+
description: "Lists all services. [See the documentation](https://bitbucket.org/awoo23/api-2.0/wiki/Services_for_booking)",
7+
version: "0.0.1",
8+
type: "action",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: true,
13+
},
14+
props: {
15+
launch27,
16+
},
17+
async run({ $ }) {
18+
const response = await this.launch27.listServices({
19+
$,
20+
});
21+
$.export("$summary", `Successfully listed ${response.length} service${response.length === 1
22+
? ""
23+
: "s"}`);
24+
return response;
25+
},
26+
};
Lines changed: 70 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,77 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "launch27",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
frequencyId: {
8+
type: "string",
9+
label: "Frequency ID",
10+
description: "The ID of the frequency to get",
11+
async options() {
12+
const frequencies = await this.listFrequencies();
13+
return frequencies?.map(({
14+
id: value, name: label,
15+
}) => ({
16+
label,
17+
value,
18+
})) || [];
19+
},
20+
},
21+
},
522
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
23+
_baseUrl() {
24+
return `https://${this.$auth.domain}.launch27.com/latest`;
25+
},
26+
_makeRequest({
27+
$ = this, path, ...opts
28+
}) {
29+
return axios($, {
30+
url: `${this._baseUrl()}${path}`,
31+
headers: {
32+
Authorization: `Bearer ${this.$auth.oauth_access_token}`,
33+
},
34+
...opts,
35+
});
36+
},
37+
listFrequencies(opts = {}) {
38+
return this._makeRequest({
39+
method: "GET",
40+
path: "/booking/frequencies",
41+
...opts,
42+
});
43+
},
44+
listServices(opts = {}) {
45+
return this._makeRequest({
46+
method: "GET",
47+
path: "/booking/services",
48+
...opts,
49+
});
50+
},
51+
getPolicy({
52+
type, ...opts
53+
}) {
54+
return this._makeRequest({
55+
method: "GET",
56+
path: `/policy/${type}`,
57+
...opts,
58+
});
59+
},
60+
getBookingSpots(opts = {}) {
61+
return this._makeRequest({
62+
method: "POST",
63+
path: "/booking/spots",
64+
...opts,
65+
});
66+
},
67+
getNextBookingDate({
68+
frequencyId, ...opts
69+
}) {
70+
return this._makeRequest({
71+
method: "POST",
72+
path: `/booking/frequencies/${frequencyId}/next`,
73+
...opts,
74+
});
975
},
1076
},
1177
};

components/launch27/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/launch27",
3-
"version": "0.6.0",
3+
"version": "0.7.0",
44
"description": "Pipedream launch27 Components",
55
"main": "launch27.app.mjs",
66
"keywords": [

0 commit comments

Comments
 (0)