Skip to content

Commit 49ef151

Browse files
committed
some adjusts
1 parent 5f02a7f commit 49ef151

File tree

3 files changed

+183
-32
lines changed

3 files changed

+183
-32
lines changed

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

Lines changed: 70 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,45 @@ export default {
3838
],
3939
optional: true,
4040
},
41-
emails: {
41+
workEmail: {
4242
propDefinition: [
4343
benchmarkone,
44-
"emails",
44+
"workEmail",
4545
],
4646
optional: true,
4747
},
48-
phones: {
48+
homeEmail: {
4949
propDefinition: [
5050
benchmarkone,
51-
"phones",
51+
"homeEmail",
5252
],
5353
optional: true,
5454
},
55-
addresses: {
55+
workPhone: {
5656
propDefinition: [
5757
benchmarkone,
58-
"addresses",
58+
"workPhone",
59+
],
60+
optional: true,
61+
},
62+
homePhone: {
63+
propDefinition: [
64+
benchmarkone,
65+
"homePhone",
66+
],
67+
optional: true,
68+
},
69+
workAddress: {
70+
propDefinition: [
71+
benchmarkone,
72+
"workAddress",
73+
],
74+
optional: true,
75+
},
76+
homeAddress: {
77+
propDefinition: [
78+
benchmarkone,
79+
"homeAddress",
5980
],
6081
optional: true,
6182
},
@@ -82,13 +103,53 @@ export default {
82103
},
83104
async run({ $ }) {
84105
try {
106+
const emails = [];
107+
if (this.workEmail) {
108+
emails.push({
109+
address: this.workEmail,
110+
type: "Work",
111+
});
112+
}
113+
if (this.homeEmail) {
114+
emails.push({
115+
address: this.homeEmail,
116+
type: "Home",
117+
});
118+
}
119+
const phones = [];
120+
if (this.workPhone) {
121+
phones.push({
122+
number: this.workPhone,
123+
type: "Work",
124+
});
125+
}
126+
if (this.homePhone) {
127+
phones.push({
128+
number: this.homePhone,
129+
type: "Home",
130+
});
131+
}
132+
const addresses = [];
133+
if (this.workAddress) {
134+
addresses.push({
135+
...parseObject(this.workAddress),
136+
type: "Work",
137+
});
138+
}
139+
if (this.homeAddress) {
140+
addresses.push({
141+
...parseObject(this.homeAddress),
142+
type: "Home",
143+
});
144+
}
145+
85146
const data = {
86147
contactId: this.contactId,
87148
firstName: this.firstName,
88149
lastName: this.lastName,
89-
emails: parseObject(this.emails),
90-
phones: parseObject(this.phones),
91-
addresses: parseObject(this.addresses),
150+
emails,
151+
phones,
152+
addresses,
92153
};
93154
if (this.status) {
94155
data.status = {

components/benchmarkone/actions/update-contact/update-contact.mjs

Lines changed: 70 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,45 @@ export default {
4444
],
4545
optional: true,
4646
},
47-
emails: {
47+
workEmail: {
4848
propDefinition: [
4949
benchmarkone,
50-
"emails",
50+
"workEmail",
5151
],
5252
optional: true,
5353
},
54-
phones: {
54+
homeEmail: {
5555
propDefinition: [
5656
benchmarkone,
57-
"phones",
57+
"homeEmail",
5858
],
5959
optional: true,
6060
},
61-
addresses: {
61+
workPhone: {
6262
propDefinition: [
6363
benchmarkone,
64-
"addresses",
64+
"workPhone",
65+
],
66+
optional: true,
67+
},
68+
homePhone: {
69+
propDefinition: [
70+
benchmarkone,
71+
"homePhone",
72+
],
73+
optional: true,
74+
},
75+
workAddress: {
76+
propDefinition: [
77+
benchmarkone,
78+
"workAddress",
79+
],
80+
optional: true,
81+
},
82+
homeAddress: {
83+
propDefinition: [
84+
benchmarkone,
85+
"homeAddress",
6586
],
6687
optional: true,
6788
},
@@ -89,13 +110,53 @@ export default {
89110
},
90111
async run({ $ }) {
91112
try {
113+
const emails = [];
114+
if (this.workEmail) {
115+
emails.push({
116+
address: this.workEmail,
117+
type: "Work",
118+
});
119+
}
120+
if (this.homeEmail) {
121+
emails.push({
122+
address: this.homeEmail,
123+
type: "Home",
124+
});
125+
}
126+
const phones = [];
127+
if (this.workPhone) {
128+
phones.push({
129+
number: this.workPhone,
130+
type: "Work",
131+
});
132+
}
133+
if (this.homePhone) {
134+
phones.push({
135+
number: this.homePhone,
136+
type: "Home",
137+
});
138+
}
139+
const addresses = [];
140+
if (this.workAddress) {
141+
addresses.push({
142+
...parseObject(this.workAddress),
143+
type: "Work",
144+
});
145+
}
146+
if (this.homeAddress) {
147+
addresses.push({
148+
...parseObject(this.homeAddress),
149+
type: "Home",
150+
});
151+
}
152+
92153
const data = {
93154
contactId: this.contactId,
94155
firstName: this.firstName,
95156
lastName: this.lastName,
96-
emails: parseObject(this.emails),
97-
phones: parseObject(this.phones),
98-
addresses: parseObject(this.addresses),
157+
emails,
158+
phones,
159+
addresses,
99160
};
100161
if (this.status) {
101162
data.status = {

components/benchmarkone/benchmarkone.app.mjs

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,49 @@ export default {
5959
label: "Company",
6060
description: "The contact's company name.",
6161
},
62-
emails: {
63-
type: "string[]",
64-
label: "Email Addresses",
65-
description: "A list of objects of contact's email address. **Example: [ { \"address\": \"[email protected]\", \"type\": \"Home\" } ]** [See the documentation](https://sandbox.hatchbuck.com/api/dist/#!/Contacts/post_contact) for further details.",
66-
},
67-
phones: {
68-
type: "string[]",
69-
label: "Phones",
70-
description: "A list of objects of contact's phone numbers. **Example: [ { \"number\": \"(123)4567890\", \"type\": \"Work\" } ]** [See the documentation](https://sandbox.hatchbuck.com/api/dist/#!/Contacts/post_contact) for further details.",
71-
},
72-
addresses: {
73-
type: "string[]",
74-
label: "Addresses",
75-
description: "A list of objects of contact's addresses. **Example: [ { \"street\": \"string\", \"city\": \"string\", \"state\": \"string\", \"zip\": \"string\", \"country\": \"string\", \"type\": \"string\" } ]** [See the documentation](https://sandbox.hatchbuck.com/api/dist/#!/Contacts/post_contact) for further details.",
62+
workEmail: {
63+
type: "string",
64+
label: "Work Email Address",
65+
description: "A contact's work email address.",
66+
},
67+
homeEmail: {
68+
type: "string",
69+
label: "Home Email Address",
70+
description: "A contact's home email address.",
71+
},
72+
workPhone: {
73+
type: "string",
74+
label: "Work Phone",
75+
description: "A contact's work phone number.",
76+
},
77+
homePhone: {
78+
type: "string",
79+
label: "Home Phone",
80+
description: "A contact's home phone number.",
81+
},
82+
workAddress: {
83+
type: "object",
84+
label: "Work Address",
85+
description: "An object of contact's work address.",
86+
default: {
87+
street: "",
88+
city: "",
89+
state: "",
90+
zip: "",
91+
country: "",
92+
},
93+
},
94+
homeAddress: {
95+
type: "object",
96+
label: "Home Address",
97+
description: "An object of contact's home address.",
98+
default: {
99+
street: "",
100+
city: "",
101+
state: "",
102+
zip: "",
103+
country: "",
104+
},
76105
},
77106
website: {
78107
type: "string",

0 commit comments

Comments
 (0)