@clxmedia/emailhub-client 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.d.ts +20 -0
- package/dist/client.js +33 -0
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -42,6 +42,23 @@ export interface CredentialBody {
|
|
|
42
42
|
client_email?: string;
|
|
43
43
|
private_key?: string;
|
|
44
44
|
}
|
|
45
|
+
export interface EmailHubSenderProfile {
|
|
46
|
+
id: number;
|
|
47
|
+
guid: string;
|
|
48
|
+
domain_name: string;
|
|
49
|
+
domain_id: string;
|
|
50
|
+
mailjet_sender_id: string;
|
|
51
|
+
dkim_txt_name: string;
|
|
52
|
+
dkim_txt_value: string;
|
|
53
|
+
dkim_status: string;
|
|
54
|
+
token_txt_name: string;
|
|
55
|
+
token_txt_value: string;
|
|
56
|
+
spf_txt_value: string;
|
|
57
|
+
spf_status: string;
|
|
58
|
+
created_at: string;
|
|
59
|
+
updated_at?: string;
|
|
60
|
+
verified_at?: string;
|
|
61
|
+
}
|
|
45
62
|
export declare class EmailHubClient {
|
|
46
63
|
private sender;
|
|
47
64
|
private server;
|
|
@@ -49,6 +66,9 @@ export declare class EmailHubClient {
|
|
|
49
66
|
constructor(cfg: EmailHubConfig);
|
|
50
67
|
private loadPubSubClient;
|
|
51
68
|
static validateEmailAddress(email?: string, regex?: RegExp): boolean;
|
|
69
|
+
createSenderProfile(domain: string): Promise<EmailHubSenderProfile>;
|
|
70
|
+
getSenderProfile(domainGuid: string): Promise<EmailHubSenderProfile>;
|
|
71
|
+
checkSenderProfile(domainGuid: string): Promise<EmailHubSenderProfile>;
|
|
52
72
|
sendEmail(msg: EmailHubMessage, options?: {
|
|
53
73
|
priority?: EmailHubPriorityLevel;
|
|
54
74
|
}): Promise<string>;
|
package/dist/client.js
CHANGED
|
@@ -49,6 +49,39 @@ class EmailHubClient {
|
|
|
49
49
|
}
|
|
50
50
|
return regex.test(email.toLocaleLowerCase());
|
|
51
51
|
}
|
|
52
|
+
createSenderProfile(domain) {
|
|
53
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
const result = yield axios_1.default.post(`${this.server}/sender-profiles`, { domain }, {
|
|
55
|
+
headers: { 'Content-Type': 'application/json', 'x-emailhub-sender-guid': this.sender.guid, 'x-emailhub-sender-secret': this.sender.secret }
|
|
56
|
+
});
|
|
57
|
+
if (result.status === 400) {
|
|
58
|
+
throw Error('Domain already taken or configured.');
|
|
59
|
+
}
|
|
60
|
+
return result.data;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
getSenderProfile(domainGuid) {
|
|
64
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
const result = yield axios_1.default.get(`${this.server}/sender-profiles/${domainGuid}`, {
|
|
66
|
+
headers: { 'Content-Type': 'application/json', 'x-emailhub-sender-guid': this.sender.guid, 'x-emailhub-sender-secret': this.sender.secret }
|
|
67
|
+
});
|
|
68
|
+
if (result.status >= 400) {
|
|
69
|
+
throw Error('Domain locator invalid or record not found.');
|
|
70
|
+
}
|
|
71
|
+
return result.data;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
checkSenderProfile(domainGuid) {
|
|
75
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
const result = yield axios_1.default.post(`${this.server}/sender-profiles/${domainGuid}`, undefined, {
|
|
77
|
+
headers: { 'Content-Type': 'application/json', 'x-emailhub-sender-guid': this.sender.guid, 'x-emailhub-sender-secret': this.sender.secret }
|
|
78
|
+
});
|
|
79
|
+
if (result.status >= 400) {
|
|
80
|
+
throw Error('Domain locator invalid or record not found.');
|
|
81
|
+
}
|
|
82
|
+
return result.data;
|
|
83
|
+
});
|
|
84
|
+
}
|
|
52
85
|
sendEmail(msg, options) {
|
|
53
86
|
return __awaiter(this, void 0, void 0, function* () {
|
|
54
87
|
yield this.loadPubSubClient();
|