Skip to content

Commit 195fe34

Browse files
committed
Update targeting field types and descriptions in schedule-message component; refactor LinkedIn targeting logic for improved clarity
1 parent ee44b67 commit 195fe34

File tree

2 files changed

+81
-57
lines changed

2 files changed

+81
-57
lines changed

components/hootsuite/actions/schedule-message/schedule-message.mjs

Lines changed: 65 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,20 @@ export default {
4747
optional: true,
4848
},
4949
targetingFacebookPageAgeMin: {
50-
type: "integer",
50+
type: "string",
5151
label: "Targeting Facebook Page - Age Min",
5252
description: "Minimum age to target the message at.",
5353
options: [
54-
13,
55-
17,
56-
18,
57-
19,
58-
21,
54+
"13",
55+
"17",
56+
"18",
57+
"19",
58+
"21",
5959
],
6060
optional: true,
6161
},
6262
targetingFacebookPageEducation: {
63-
type: "string",
63+
type: "string[]",
6464
label: "Targeting Facebook Page - Education",
6565
description: "The education level of the Facebook page to target.",
6666
options: [
@@ -81,7 +81,7 @@ export default {
8181
optional: true,
8282
},
8383
targetingFacebookPageRelationshipStatus: {
84-
type: "string",
84+
type: "string[]",
8585
label: "Targeting Facebook Page - Relationship Status",
8686
description: "Relationship status to target the message at.",
8787
options: [
@@ -95,25 +95,25 @@ export default {
9595
targetingFacebookPageCountry: {
9696
type: "string[]",
9797
label: "Targeting Facebook Page - Country",
98-
description: "Country to target the message at. 2-digit ISO 3166 format code as provided by Facebook.",
98+
description: "Country to target the message at. 2-digit ISO 3166 format code as provided by Facebook. **Format: [{\"k\": \"Canada\", \"v\": \"CA\"}]** [See the documentation](https://apidocs.hootsuite.com/docs/api/index.html#operation/scheduleMessage) for more information.",
9999
optional: true,
100100
},
101101
targetingFacebookPageRegions: {
102102
type: "string[]",
103103
label: "Targeting Facebook Page - Regions",
104-
description: "Region to target the message at. Note that regions can only be specified when there is exactly one country targeted. Limit 200.",
104+
description: "Region to target the message at. Note that regions can only be specified when there is exactly one country targeted. Limit 200. **Format: [{\"k\": \"British Columbia\", \"v\": \"2\"}]** [See the documentation](https://apidocs.hootsuite.com/docs/api/index.html#operation/scheduleMessage) for more information.",
105105
optional: true,
106106
},
107107
targetingFacebookPageCities: {
108108
type: "string[]",
109109
label: "Targeting Facebook Page - Cities",
110-
description: "City to target the message at. Note that cities can only be specified when there is exactly one country targeted. Limit 250.",
110+
description: "City to target the message at. Note that cities can only be specified when there is exactly one country targeted. Limit 250. **Format: [{\"k\": \"Burnaby, BC\", \"v\": \"292466\"}]** [See the documentation](https://apidocs.hootsuite.com/docs/api/index.html#operation/scheduleMessage) for more information.",
111111
optional: true,
112112
},
113113
targetingFacebookPageZips: {
114114
type: "string[]",
115115
label: "Targeting Facebook Page - Zip",
116-
description: "Zip/Postal Code to target the message at. Limit 50,000.",
116+
description: "Zip/Postal Code to target the message at. Limit 50,000. **Format: [{\"k\": \"K1S\", \"v\": \"CA:K1S\"}]** [See the documentation](https://apidocs.hootsuite.com/docs/api/index.html#operation/scheduleMessage) for more information.",
117117
optional: true,
118118
},
119119
targetingLinkedInCompanySize: {
@@ -238,7 +238,7 @@ export default {
238238
const facebookPage = {};
239239

240240
if (this.targetingFacebookPageAgeMin) {
241-
facebookPage.ageMin = this.targetingFacebookPageAgeMin;
241+
facebookPage.ageMin = parseInt(this.targetingFacebookPageAgeMin);
242242
}
243243
if (this.targetingFacebookPageEducation) {
244244
facebookPage.education = parseObject(this.targetingFacebookPageEducation);
@@ -250,24 +250,52 @@ export default {
250250
facebookPage.relationshipStatus = parseObject(this.targetingFacebookPageRelationshipStatus);
251251
}
252252
if (this.targetingFacebookPageCountry) {
253-
facebookPage.countries = parseObject(this.targetingFacebookPageCountry)?.map((country) => ({
254-
v: country,
255-
}));
253+
facebookPage.countries = parseObject(this.targetingFacebookPageCountry);
256254
}
257255
if (this.targetingFacebookPageRegions) {
258-
facebookPage.regions = parseObject(this.targetingFacebookPageRegions)?.map((region) => ({
259-
v: region,
260-
}));
256+
facebookPage.regions = parseObject(this.targetingFacebookPageRegions);
261257
}
262258
if (this.targetingFacebookPageCities) {
263-
facebookPage.cities = parseObject(this.targetingFacebookPageCities)?.map((city) => ({
264-
v: city,
265-
}));
259+
facebookPage.cities = parseObject(this.targetingFacebookPageCities);
266260
}
267261
if (this.targetingFacebookPageZips) {
268-
facebookPage.zips = parseObject(this.targetingFacebookPageZips)?.map((zip) => ({
269-
v: zip,
270-
}));
262+
facebookPage.zips = parseObject(this.targetingFacebookPageZips);
263+
}
264+
const linkedInCompany = {};
265+
if (this.targetingLinkedInCompanySize) {
266+
linkedInCompany.companySize = parseObject(this.targetingLinkedInCompanySize);
267+
}
268+
if (this.targetingLinkedInCompanyGeography) {
269+
linkedInCompany.geography = parseObject(this.targetingLinkedInCompanyGeography);
270+
}
271+
if (this.targetingLinkedInCompanyIndustry) {
272+
linkedInCompany.industry =
273+
parseObject(this.targetingLinkedInCompanyIndustry)?.map((item) => String(item));
274+
}
275+
if (this.targetingLinkedInCompanyJobFunction) {
276+
linkedInCompany.jobFunction = parseObject(this.targetingLinkedInCompanyJobFunction);
277+
}
278+
if (this.targetingLinkedInCompanySeniority) {
279+
linkedInCompany.seniority = parseObject(this.targetingLinkedInCompanySeniority);
280+
}
281+
282+
const linkedInV2Company = {};
283+
if (this.targetingLinkedInV2CompanyLocations) {
284+
linkedInV2Company.locations = parseObject(this.targetingLinkedInV2CompanyLocations);
285+
}
286+
if (this.targetingLinkedInV2CompanyStaffCountRange) {
287+
linkedInV2Company.staffCountRange =
288+
parseObject(this.targetingLinkedInV2CompanyStaffCountRange);
289+
}
290+
if (this.targetingLinkedInV2CompanySeniorities) {
291+
linkedInV2Company.seniorities = parseObject(this.targetingLinkedInV2CompanySeniorities);
292+
}
293+
if (this.targetingLinkedInV2CompanyIndustries) {
294+
linkedInV2Company.industries = parseObject(this.targetingLinkedInV2CompanyIndustries);
295+
}
296+
if (this.targetingLinkedInV2CompanyInterfaceLocations) {
297+
linkedInV2Company.interfaceLocations =
298+
parseObject(this.targetingLinkedInV2CompanyInterfaceLocations);
271299
}
272300

273301
const response = await this.hootsuite.scheduleMessage({
@@ -284,20 +312,16 @@ export default {
284312
facebookPage,
285313
}
286314
: {}),
287-
linkedInCompany: {
288-
companySize: parseObject(this.targetingLinkedInCompanySize),
289-
geography: parseObject(this.targetingLinkedInCompanyGeography),
290-
industry: parseObject(this.targetingLinkedInCompanyIndustry),
291-
jobFunction: parseObject(this.targetingLinkedInCompanyJobFunction),
292-
seniority: parseObject(this.targetingLinkedInCompanySeniority),
293-
},
294-
linkedInV2Company: {
295-
locations: parseObject(this.targetingLinkedInV2CompanyLocations),
296-
staffCountRange: parseObject(this.targetingLinkedInV2CompanyStaffCountRange),
297-
seniorities: parseObject(this.targetingLinkedInV2CompanySeniorities),
298-
industries: parseObject(this.targetingLinkedInV2CompanyIndustries),
299-
interfaceLocations: parseObject(this.targetingLinkedInV2CompanyInterfaceLocations),
300-
},
315+
...(Object.keys(linkedInCompany).length > 0
316+
? {
317+
linkedInCompany,
318+
}
319+
: {}),
320+
...(Object.keys(linkedInV2Company).length > 0
321+
? {
322+
linkedInV2Company,
323+
}
324+
: {}),
301325
},
302326
privacy: (this.privacyFacebookVisibility || this.privacyLinkedInVisibility) && {
303327
...(this.privacyFacebookVisibility
@@ -320,8 +344,8 @@ export default {
320344
: {}),
321345
},
322346
location: {
323-
latitude: this.latitude,
324-
longitude: this.longitude,
347+
latitude: parseFloat(this.latitude),
348+
longitude: parseFloat(this.longitude),
325349
},
326350
emailNotification: this.emailNotification,
327351
mediaUrls: parseObject(this.mediaUrls)?.map((mediaUrl) => ({

components/hootsuite/common/constants.mjs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,36 @@ export const COMPANY_SIZE_OPTIONS = [
44
value: "self",
55
},
66
{
7-
label: "1-10",
8-
value: "1 to 10 employees",
7+
label: "1 to 10 employees",
8+
value: "1-10",
99
},
1010
{
11-
label: "11-50",
12-
value: "11 to 50 employees",
11+
label: "11 to 50 employees",
12+
value: "11-50",
1313
},
1414
{
15-
label: "51-200",
16-
value: "51 to 200 employees",
15+
label: "51 to 200 employees",
16+
value: "51-200",
1717
},
1818
{
19-
label: "201-500",
20-
value: "201 to 500 employees",
19+
label: "201 to 500 employees",
20+
value: "201-500",
2121
},
2222
{
23-
label: "501-1000",
24-
value: "501 to 1000 employees",
23+
label: "501 to 1000 employees",
24+
value: "501-1000",
2525
},
2626
{
27-
label: "1001-5000",
28-
value: "1001 to 5000 employees",
27+
label: "1001 to 5000 employees",
28+
value: "1001-5000",
2929
},
3030
{
31-
label: "5001-10000",
32-
value: "5001 to 10000 employees",
31+
label: "5001 to 10000 employees",
32+
value: "5001-10000",
3333
},
3434
{
35-
label: "10001",
36-
value: "10001+ employees",
35+
label: "10001+ employees",
36+
value: "10001",
3737
},
3838
];
3939

0 commit comments

Comments
 (0)