Skip to content

Commit db4f28b

Browse files
committed
Added actions
1 parent c08f93b commit db4f28b

File tree

6 files changed

+281
-18
lines changed

6 files changed

+281
-18
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import app from "../../etermin.app.mjs";
2+
3+
export default {
4+
key: "etermin-create-contact",
5+
name: "Create Contact",
6+
description: "Create a new contact on eTermin. [See the documentation](https://app.swaggerhub.com/apis/etermin.net/eTermin-API/1.0.0#/Contact/post_contact)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
updateWhenExistsgdt: {
12+
propDefinition: [
13+
app,
14+
"updateWhenExistsgdt",
15+
],
16+
},
17+
salutation: {
18+
propDefinition: [
19+
app,
20+
"salutation",
21+
],
22+
},
23+
title: {
24+
propDefinition: [
25+
app,
26+
"title",
27+
],
28+
},
29+
lastname: {
30+
propDefinition: [
31+
app,
32+
"lastName",
33+
],
34+
},
35+
firstname: {
36+
propDefinition: [
37+
app,
38+
"firstName",
39+
],
40+
},
41+
company: {
42+
propDefinition: [
43+
app,
44+
"company",
45+
],
46+
},
47+
birthday: {
48+
propDefinition: [
49+
app,
50+
"birthday",
51+
],
52+
},
53+
email: {
54+
propDefinition: [
55+
app,
56+
"email",
57+
],
58+
},
59+
},
60+
async run({ $ }) {
61+
const response = await this.app.createContact({
62+
$,
63+
params: {
64+
updatewhenexistsgdt: this.updateWhenExistsgdt,
65+
salutation: this.salutation,
66+
title: this.title,
67+
lastname: this.lastName,
68+
firstname: this.firstName,
69+
company: this.company,
70+
birthday: this.birthday,
71+
email: this.email,
72+
},
73+
});
74+
$.export("$summary", "Successfully created the new contact");
75+
return response;
76+
},
77+
};
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import app from "../../etermin.app.mjs";
2+
3+
export default {
4+
key: "etermin-create-voucher",
5+
name: "Create Voucher",
6+
description: "Create a new voucher on eTermin. [See the documentation](https://app.swaggerhub.com/apis/etermin.net/eTermin-API/1.0.0#/Voucher/post_api_voucher)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
id: {
12+
propDefinition: [
13+
app,
14+
"id",
15+
],
16+
},
17+
description: {
18+
propDefinition: [
19+
app,
20+
"description",
21+
],
22+
},
23+
priceInclVat: {
24+
propDefinition: [
25+
app,
26+
"priceInclVat",
27+
],
28+
},
29+
isPercentage: {
30+
propDefinition: [
31+
app,
32+
"isPercentage",
33+
],
34+
},
35+
customerEmail: {
36+
propDefinition: [
37+
app,
38+
"customerEmail",
39+
],
40+
},
41+
validFrom: {
42+
propDefinition: [
43+
app,
44+
"validFrom",
45+
],
46+
},
47+
validUntil: {
48+
propDefinition: [
49+
app,
50+
"validUntil",
51+
],
52+
},
53+
},
54+
async run({ $ }) {
55+
const response = await this.app.createVoucher({
56+
$,
57+
params: {
58+
id: this.id,
59+
description: this.description,
60+
priceinclvat: this.priceInClvat,
61+
priceoriginal: this.priceOriginal,
62+
ispercentage: this.isPercentage,
63+
customeremail: this.customerEmail,
64+
validfrom: this.validFrom,
65+
validuntil: this.validUntil,
66+
},
67+
});
68+
$.export("$summary", "Successfully created the new voucher");
69+
return response;
70+
},
71+
};
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export default {
2+
UPDATE_OPTIONS: [
3+
1,
4+
2,
5+
],
6+
};

components/etermin/etermin.app.mjs

Lines changed: 116 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,123 @@
1+
import { axios } from "@pipedream/platform";
2+
import constants from "./common/constants.mjs";
3+
14
export default {
25
type: "app",
36
app: "etermin",
4-
propDefinitions: {},
7+
propDefinitions: {
8+
updateWhenExistsgdt: {
9+
type: "string",
10+
label: "Update When Exists",
11+
description: "Set to 1 to check if the contact is already existing. If so the existing contact gets updated. Needs email or firstname, lastname and birthday",
12+
options: constants.UPDATE_OPTIONS,
13+
},
14+
salutation: {
15+
type: "string",
16+
label: "Salutation",
17+
description: "Salutation or greeting prefix",
18+
},
19+
title: {
20+
type: "string",
21+
label: "Title",
22+
description: "Title of the contact",
23+
},
24+
lastName: {
25+
type: "string",
26+
label: "Last Name",
27+
description: "Contact's last name",
28+
},
29+
firstName: {
30+
type: "string",
31+
label: "First Name",
32+
description: "Contact's first name",
33+
},
34+
company: {
35+
type: "string",
36+
label: "Company",
37+
description: "Name of the company associated with the contact",
38+
},
39+
birthday: {
40+
type: "string",
41+
label: "Birthday",
42+
description: "Contact's date of birth in YYYY-MM-DD format",
43+
},
44+
email: {
45+
type: "string",
46+
label: "Email",
47+
description: "Email address of the contact",
48+
},
49+
id: {
50+
type: "string",
51+
label: "ID",
52+
description: "ID of the voucher",
53+
},
54+
description: {
55+
type: "string",
56+
label: "Description",
57+
description: "Description of the voucher",
58+
},
59+
priceInclVat: {
60+
type: "string",
61+
label: "Price Including VAT",
62+
description: "Price including VAT of the voucher",
63+
},
64+
isPercentage: {
65+
type: "boolean",
66+
label: "Is Percentage",
67+
description: "Indicates if the value of the vaucher is a percentage",
68+
},
69+
customerEmail: {
70+
type: "string",
71+
label: "Customer Email",
72+
description: "Email address of the customer receiving the offer",
73+
},
74+
validFrom: {
75+
type: "string",
76+
label: "Valid From",
77+
description: "Start date of validity in YYYY-MM-DD format",
78+
},
79+
validUntil: {
80+
type: "string",
81+
label: "Valid Until",
82+
description: "End date of validity in YYYY-MM-DD format",
83+
},
84+
},
585
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
86+
_baseUrl() {
87+
return "https://www.etermin.net/api";
88+
},
89+
async _makeRequest(opts = {}) {
90+
const {
91+
$ = this,
92+
path,
93+
headers,
94+
...otherOpts
95+
} = opts;
96+
return axios($, {
97+
...otherOpts,
98+
url: this._baseUrl() + path,
99+
headers: {
100+
"publickey": `${this.$auth.public_key}`,
101+
"salt": `${this.$auth.salt}`,
102+
"signature": `${this.$auth.signature}`,
103+
...headers,
104+
},
105+
});
106+
},
107+
108+
async createContact(args = {}) {
109+
return this._makeRequest({
110+
path: "/contact",
111+
method: "post",
112+
...args,
113+
});
114+
},
115+
async createVoucher(args = {}) {
116+
return this._makeRequest({
117+
path: "/voucher",
118+
method: "post",
119+
...args,
120+
});
9121
},
10122
},
11123
};

components/etermin/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/etermin",
3-
"version": "0.6.0",
3+
"version": "0.7.0",
44
"description": "Pipedream etermin Components",
55
"main": "etermin.app.mjs",
66
"keywords": [
@@ -13,6 +13,6 @@
1313
"access": "public"
1414
},
1515
"dependencies": {
16-
"@pipedream/platform": "^3.0.0"
16+
"@pipedream/platform": "^3.1.0"
1717
}
1818
}

pnpm-lock.yaml

Lines changed: 9 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)