Skip to content

Commit 1679ec1

Browse files
feat(reach): add segment actions (#34)
Co-authored-by: Valentinas Čirba <[email protected]>
1 parent 49345e9 commit 1679ec1

File tree

3 files changed

+32
-44
lines changed

3 files changed

+32
-44
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,14 @@ Helpful link for beginners: [Try it out](https://docs.n8n.io/try-it-out/)
9898

9999
## Version history
100100

101-
- **v1.0.13**:
101+
- **v1.0.15**:
102+
- Added segment actions for Email Marketing (Reach)
103+
- List Segments operation
104+
- Get Segment operation
105+
- Get Segment Contacts operation
106+
- Removed contact groups functionality (replaced with segments)
107+
108+
- **v1.0.14**:
102109
- Added fields for Domain Purchase, Check Domain Availability and Update Domain Nameservers operations
103110
- Refactored scripts for building, linting, and releasing using n8n-node CLI
104111
- Added strict mode in n8n configuration

nodes/hostingerApi/HostingerApi.node.ts

Lines changed: 23 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,12 @@ export class HostingerApi implements INodeType {
416416
// eslint-disable-next-line n8n-nodes-base/node-param-operation-option-action-miscased
417417
{ name: 'Delete Contact', value: 'deleteContact', action: 'Delete Reach contact'},
418418
// eslint-disable-next-line n8n-nodes-base/node-param-operation-option-action-miscased
419-
{ name: 'List Contact Groups', value: 'listContactGroups', action: 'List Reach contact groups'},
419+
{ name: 'List Segments', value: 'listSegments', action: 'List Reach segments'},
420+
// eslint-disable-next-line n8n-nodes-base/node-param-operation-option-action-miscased
421+
{name: 'Get Segment', value: 'getSegment', action: 'Get Reach segment'},
422+
// eslint-disable-next-line n8n-nodes-base/node-param-operation-option-action-miscased
423+
{name: 'Get Segment Contacts', value: 'getSegmentContacts', action: 'Get Reach segment contacts'},
424+
420425
],
421426
default: 'listContacts',
422427
displayOptions: {
@@ -1117,19 +1122,6 @@ export class HostingerApi implements INodeType {
11171122
}
11181123
}
11191124
},
1120-
{
1121-
displayName: 'Group UUIDs',
1122-
name: 'contactGroupUuids',
1123-
type: 'string',
1124-
default: '',
1125-
description: 'Comma-separated list of group UUIDs to assign the contact to',
1126-
displayOptions: {
1127-
show: {
1128-
resource: ['reach'],
1129-
operation: ['createContact']
1130-
}
1131-
}
1132-
},
11331125
{
11341126
displayName: 'Note',
11351127
name: 'contactNote',
@@ -1158,19 +1150,6 @@ export class HostingerApi implements INodeType {
11581150
}
11591151
}
11601152
},
1161-
{
1162-
displayName: 'Group UUID',
1163-
name: 'groupUuid',
1164-
type: 'string',
1165-
default: '',
1166-
description: 'Filter contacts by group UUID',
1167-
displayOptions: {
1168-
show: {
1169-
resource: ['reach'],
1170-
operation: ['listContacts']
1171-
}
1172-
}
1173-
},
11741153
{
11751154
displayName: 'Subscription Status',
11761155
name: 'subscriptionStatus',
@@ -1203,6 +1182,19 @@ export class HostingerApi implements INodeType {
12031182
}
12041183
}
12051184
},
1185+
{
1186+
displayName: 'Segment UUID',
1187+
name: 'segmentUuid',
1188+
type: 'string',
1189+
default: '',
1190+
description: 'UUID of the segment',
1191+
displayOptions: {
1192+
show: {
1193+
resource: ['reach'],
1194+
operation: ['getSegment', 'getSegmentContacts']
1195+
}
1196+
}
1197+
}
12061198
]
12071199
};
12081200

@@ -1227,7 +1219,6 @@ export class HostingerApi implements INodeType {
12271219
const contactEmail = this.getNodeParameter('contactEmail', i) as string;
12281220
const contactName = this.getNodeParameter('contactName', i) as string;
12291221
const contactSurname = this.getNodeParameter('contactSurname', i) as string;
1230-
const contactGroupUuids = this.getNodeParameter('contactGroupUuids', i) as string;
12311222
const contactNote = this.getNodeParameter('contactNote', i) as string;
12321223

12331224
const contactData: IDataObject = {
@@ -1238,14 +1229,6 @@ export class HostingerApi implements INodeType {
12381229
if (contactSurname) contactData.surname = contactSurname;
12391230
if (contactNote) contactData.note = contactNote;
12401231

1241-
// Handle group UUIDs - convert comma-separated string to array
1242-
if (contactGroupUuids) {
1243-
const groupUuids = contactGroupUuids.split(',').map(uuid => uuid.trim()).filter(uuid => uuid);
1244-
if (groupUuids.length > 0) {
1245-
contactData.group_uuids = groupUuids;
1246-
}
1247-
}
1248-
12491232
requestBody = contactData;
12501233
} else if (operation === 'updateHostname') {
12511234
// For updateHostname, build request body from hostname field
@@ -1503,12 +1486,8 @@ export class HostingerApi implements INodeType {
15031486
//Reach
15041487
case 'listContacts': {
15051488
let contactsEndpoint = `/api/reach/v1/contacts?page=${getParam('page')}`;
1506-
const groupUuid = this.getNodeParameter('groupUuid', i) as string;
15071489
const subscriptionStatus = this.getNodeParameter('subscriptionStatus', i) as string;
1508-
1509-
if (groupUuid) {
1510-
contactsEndpoint += `&group_uuid=${groupUuid}`;
1511-
}
1490+
15121491
if (subscriptionStatus) {
15131492
contactsEndpoint += `&subscription_status=${subscriptionStatus}`;
15141493
}
@@ -1517,7 +1496,9 @@ export class HostingerApi implements INodeType {
15171496
}
15181497
case 'createContact': method = 'POST'; endpoint = '/api/reach/v1/contacts'; break;
15191498
case 'deleteContact': method = 'DELETE'; endpoint = `/api/reach/v1/contacts/${getParam('contactUuid')}`; break;
1520-
case 'listContactGroups': endpoint = '/api/reach/v1/contacts/groups'; break;
1499+
case 'listSegments': method = 'GET'; endpoint = '/api/reach/v1/segmentation/segments'; break;
1500+
case 'getSegment': method = 'GET'; endpoint = `/api/reach/v1/segmentation/segments/${getParam('segmentUuid')}`; break;
1501+
case 'getSegmentContacts': method = 'GET'; endpoint = `/api/reach/v1/segmentation/segments/${getParam('segmentUuid')}/contacts`; break;
15211502

15221503
default: throw new ApplicationError(`Unsupported operation: ${operation}`);
15231504
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "n8n-nodes-hostinger-api",
3-
"version": "1.0.13",
3+
"version": "1.0.14",
44
"description": "Hostinger API n8n Node",
55
"keywords": [
66
"n8n-community-node-package"

0 commit comments

Comments
 (0)