Skip to content

Commit a78b196

Browse files
lcaresiamichelle0927
authored andcommitted
Merging pull request #18415
* Added actions * Added actions * Added actions * Added actions * Update components/etermin/etermin.app.mjs --------- Co-authored-by: michelle0927 <michelle0927@users.noreply.github.com>
1 parent 35134f5 commit a78b196

File tree

5 files changed

+284
-8
lines changed

5 files changed

+284
-8
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
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+
annotations: {
9+
openWorldHint: true,
10+
destructiveHint: false,
11+
readOnlyHint: false,
12+
},
13+
type: "action",
14+
props: {
15+
app,
16+
updateWhenExistsgdt: {
17+
propDefinition: [
18+
app,
19+
"updateWhenExistsgdt",
20+
],
21+
},
22+
salutation: {
23+
propDefinition: [
24+
app,
25+
"salutation",
26+
],
27+
},
28+
title: {
29+
propDefinition: [
30+
app,
31+
"title",
32+
],
33+
},
34+
lastname: {
35+
propDefinition: [
36+
app,
37+
"lastName",
38+
],
39+
},
40+
firstname: {
41+
propDefinition: [
42+
app,
43+
"firstName",
44+
],
45+
},
46+
company: {
47+
propDefinition: [
48+
app,
49+
"company",
50+
],
51+
},
52+
birthday: {
53+
propDefinition: [
54+
app,
55+
"birthday",
56+
],
57+
},
58+
email: {
59+
propDefinition: [
60+
app,
61+
"email",
62+
],
63+
},
64+
},
65+
async run({ $ }) {
66+
const updateWhenExistsgdt = this.updateWhenExistsgdt === true || this.updateWhenExistsgdt === "true"
67+
? 1
68+
: 0;
69+
70+
const response = await this.app.createContact({
71+
$,
72+
params: {
73+
updatewhenexistsgdt: updateWhenExistsgdt,
74+
salutation: this.salutation,
75+
title: this.title,
76+
lastname: this.lastname,
77+
firstname: this.firstname,
78+
company: this.company,
79+
birthday: this.birthday,
80+
email: this.email,
81+
},
82+
});
83+
$.export("$summary", "Successfully created the new contact");
84+
return response;
85+
},
86+
};
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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+
annotations: {
9+
openWorldHint: true,
10+
destructiveHint: false,
11+
readOnlyHint: false,
12+
},
13+
type: "action",
14+
props: {
15+
app,
16+
id: {
17+
propDefinition: [
18+
app,
19+
"id",
20+
],
21+
},
22+
description: {
23+
propDefinition: [
24+
app,
25+
"description",
26+
],
27+
},
28+
priceInclVat: {
29+
propDefinition: [
30+
app,
31+
"priceInclVat",
32+
],
33+
},
34+
isPercentage: {
35+
propDefinition: [
36+
app,
37+
"isPercentage",
38+
],
39+
},
40+
customerEmail: {
41+
propDefinition: [
42+
app,
43+
"customerEmail",
44+
],
45+
},
46+
validFrom: {
47+
propDefinition: [
48+
app,
49+
"validFrom",
50+
],
51+
},
52+
validUntil: {
53+
propDefinition: [
54+
app,
55+
"validUntil",
56+
],
57+
},
58+
},
59+
async run({ $ }) {
60+
const response = await this.app.createVoucher({
61+
$,
62+
params: {
63+
id: this.id,
64+
description: this.description,
65+
priceinclvat: this.priceInclVat,
66+
priceoriginal: this.priceInclVat, // Docs: Should be the same value as in priceinclvat, important with contingent
67+
ispercentage: this.isPercentage
68+
? 1
69+
: 0,
70+
customeremail: this.customerEmail,
71+
validfrom: this.validFrom,
72+
validuntil: this.validUntil,
73+
},
74+
});
75+
$.export("$summary", "Successfully created the new voucher");
76+
return response;
77+
},
78+
};

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+
13
export default {
24
type: "app",
35
app: "etermin",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
updateWhenExistsgdt: {
8+
type: "boolean",
9+
label: "Update When Exists",
10+
description: "Set to `true` to check if the contact already exists. If found, the existing contact is updated. Requires email, or first name + last name + birthday.",
11+
},
12+
salutation: {
13+
type: "string",
14+
label: "Salutation",
15+
description: "Salutation or greeting prefix",
16+
},
17+
title: {
18+
type: "string",
19+
label: "Title",
20+
description: "Title of the contact",
21+
},
22+
lastName: {
23+
type: "string",
24+
label: "Last Name",
25+
description: "Contact's last name",
26+
},
27+
firstName: {
28+
type: "string",
29+
label: "First Name",
30+
description: "Contact's first name",
31+
},
32+
company: {
33+
type: "string",
34+
label: "Company",
35+
description: "Name of the company associated with the contact",
36+
},
37+
birthday: {
38+
type: "string",
39+
label: "Birthday",
40+
description: "Contact's date of birth in YYYY-MM-DD format",
41+
},
42+
email: {
43+
type: "string",
44+
label: "Email",
45+
description: "Email address of the contact",
46+
},
47+
id: {
48+
type: "string",
49+
label: "ID",
50+
description: "ID of the voucher",
51+
},
52+
description: {
53+
type: "string",
54+
label: "Description",
55+
description: "Description of the voucher",
56+
},
57+
priceInclVat: {
58+
type: "string",
59+
label: "Price Including VAT",
60+
description: "Price including VAT of the voucher",
61+
},
62+
isPercentage: {
63+
type: "boolean",
64+
label: "Is Percentage",
65+
description: "Indicates if the value of the voucher is a percentage",
66+
},
67+
customerEmail: {
68+
type: "string",
69+
label: "Customer Email",
70+
description: "Email address of the customer receiving the offer",
71+
},
72+
validFrom: {
73+
type: "string",
74+
label: "Valid From",
75+
description: "Start date of validity in YYYY-MM-DD format",
76+
},
77+
validUntil: {
78+
type: "string",
79+
label: "Valid Until",
80+
description: "End date of validity in YYYY-MM-DD format",
81+
},
82+
},
583
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
84+
_baseUrl() {
85+
return "https://www.etermin.net/api";
86+
},
87+
async _makeRequest(opts = {}) {
88+
const {
89+
$,
90+
path,
91+
headers,
92+
...otherOpts
93+
} = opts;
94+
return axios($, {
95+
...otherOpts,
96+
url: this._baseUrl() + path,
97+
headers: {
98+
"publickey": `${this.$auth.public_key}`,
99+
"salt": `${this.$auth.salt}`,
100+
"signature": `${this.$auth.signature}`,
101+
"accept": "application/json",
102+
"content-type": "application/json",
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: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)