Skip to content

Commit 90547a8

Browse files
committed
[Components] alegra #13261
Sources - New Client (Instant) - New Invoice (Instant) - New Item (Instant) Actions - Create Contact - Create Invoice - Find Contact
1 parent cc07a4e commit 90547a8

File tree

17 files changed

+685
-752
lines changed

17 files changed

+685
-752
lines changed

components/alegra/actions/create-contact/create-contact.mjs

Lines changed: 91 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,149 +1,171 @@
11
import alegra from "../../alegra.app.mjs";
2-
import { axios } from "@pipedream/platform";
2+
import {
3+
STATUS_OPTIONS,
4+
TYPE_OPTIONS,
5+
} from "../../common/constants.mjs";
6+
import { parseObject } from "../../common/utils.mjs";
37

48
export default {
59
key: "alegra-create-contact",
610
name: "Create Contact",
7-
description: "Adds a new contact to Alegra. [See the documentation]().",
8-
version: "0.0.{{ts}}",
11+
description: "Adds a new contact to Alegra. [See the documentation](https://developer.alegra.com/reference/post_contacts).",
12+
version: "0.0.1",
913
type: "action",
1014
props: {
1115
alegra,
1216
name: {
13-
propDefinition: [
14-
"alegra",
15-
"name",
16-
],
17+
type: "string",
18+
label: "Name",
19+
description: "Name of the contact",
1720
},
1821
identification: {
19-
propDefinition: [
20-
"alegra",
21-
"identification",
22-
],
22+
type: "string",
23+
label: "Identification",
24+
description: "Identification of the contact",
2325
optional: true,
2426
},
2527
address: {
26-
propDefinition: [
27-
"alegra",
28-
"address",
29-
],
28+
type: "string",
29+
label: "Address",
30+
description: "Address of the contact",
3031
optional: true,
3132
},
3233
city: {
33-
propDefinition: [
34-
"alegra",
35-
"city",
36-
],
34+
type: "string",
35+
label: "City",
36+
description: "City of the contact",
3737
optional: true,
3838
},
3939
phonePrimary: {
40-
propDefinition: [
41-
"alegra",
42-
"phonePrimary",
43-
],
40+
type: "string",
41+
label: "Primary Phone",
42+
description: "Primary phone number of the contact",
4443
optional: true,
4544
},
4645
phoneSecondary: {
47-
propDefinition: [
48-
"alegra",
49-
"phoneSecondary",
50-
],
46+
type: "string",
47+
label: "Secondary Phone",
48+
description: "Secondary phone number of the contact",
5149
optional: true,
5250
},
5351
mobile: {
54-
propDefinition: [
55-
"alegra",
56-
"mobile",
57-
],
52+
type: "string",
53+
label: "Mobile",
54+
description: "Mobile phone number of the contact",
5855
optional: true,
5956
},
6057
email: {
61-
propDefinition: [
62-
"alegra",
63-
"email",
64-
],
58+
type: "string",
59+
label: "Email",
60+
description: "Email of the contact",
6561
optional: true,
6662
},
6763
type: {
68-
propDefinition: [
69-
"alegra",
70-
"type",
71-
],
64+
type: "string",
65+
label: "Type",
66+
description: "Type of the contact",
67+
options: TYPE_OPTIONS,
7268
optional: true,
7369
},
7470
status: {
75-
propDefinition: [
76-
"alegra",
77-
"status",
78-
],
71+
type: "string",
72+
label: "Status",
73+
description: "Status of the contact",
74+
options: STATUS_OPTIONS,
7975
optional: true,
8076
},
8177
fax: {
82-
propDefinition: [
83-
"alegra",
84-
"fax",
85-
],
78+
type: "string",
79+
label: "Fax",
80+
description: "Fax number of the contact",
8681
optional: true,
8782
},
8883
debtToPay: {
8984
propDefinition: [
90-
"alegra",
85+
alegra,
9186
"debtToPay",
9287
],
9388
optional: true,
9489
},
9590
accountReceivable: {
9691
propDefinition: [
97-
"alegra",
98-
"accountReceivable",
92+
alegra,
93+
"debtToPay",
9994
],
95+
label: "Account Receivable",
96+
description: "Id of the account receivable associated with the contact",
10097
optional: true,
10198
},
10299
internalContacts: {
103-
propDefinition: [
104-
"alegra",
105-
"internalContacts",
106-
],
100+
type: "string[]",
101+
label: "Internal Contacts",
102+
description: "A list of objects of internal contacts related to the contact. **Example: [ { name: \"John Doe\", email: \"[email protected]\"}]**. [See the documentation](https://developer.alegra.com/reference/post_contacts) for further information.",
107103
optional: true,
108104
},
109105
ignoreRepeated: {
110-
propDefinition: [
111-
"alegra",
112-
"ignoreRepeated",
113-
],
106+
type: "boolean",
107+
label: "Ignore Repeated",
108+
description: "Ignore repeated contacts",
114109
optional: true,
115110
},
116111
statementAttached: {
117-
propDefinition: [
118-
"alegra",
119-
"statementAttached",
120-
],
112+
type: "boolean",
113+
label: "Statement Attached",
114+
description: "Indicates whether to include a statement for the contact",
121115
optional: true,
122116
},
123117
seller: {
124118
propDefinition: [
125-
"alegra",
126-
"sellerContact",
119+
alegra,
120+
"seller",
127121
],
128122
optional: true,
129123
},
130124
priceList: {
131125
propDefinition: [
132-
"alegra",
133-
"priceListContact",
126+
alegra,
127+
"priceList",
134128
],
135129
optional: true,
136130
},
137131
term: {
138132
propDefinition: [
139-
"alegra",
140-
"termContact",
133+
alegra,
134+
"term",
141135
],
142136
optional: true,
143137
},
144138
},
145139
async run({ $ }) {
146-
const response = await this.alegra.createContact();
140+
const {
141+
alegra,
142+
city,
143+
address,
144+
debtToPay,
145+
accountReceivable,
146+
internalContacts,
147+
statementAttached,
148+
...data
149+
} = this;
150+
151+
const response = await alegra.createContact({
152+
$,
153+
data: {
154+
...data,
155+
address: {
156+
city,
157+
address,
158+
},
159+
accounting: {
160+
debtToPay,
161+
accountReceivable,
162+
},
163+
internalContacts: parseObject(internalContacts),
164+
statementAttached: statementAttached
165+
? "yes"
166+
: "no",
167+
},
168+
});
147169
$.export("$summary", `Created contact with ID ${response.id}`);
148170
return response;
149171
},

0 commit comments

Comments
 (0)