ensend 0.0.9 → 0.0.10
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/apis/AudienceApi.js +16 -5
- package/dist/apis/SendApi.js +30 -15
- package/dist/client.d.ts +1 -1
- package/dist/client.js +17 -7
- package/package.json +1 -1
package/dist/apis/AudienceApi.js
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
export class AudienceApi {
|
|
2
11
|
constructor(http) {
|
|
3
12
|
this.http = http;
|
|
4
13
|
}
|
|
5
|
-
|
|
6
|
-
return this
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
14
|
+
CreateProfile(dto) {
|
|
15
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
return this.http({
|
|
17
|
+
body: dto,
|
|
18
|
+
method: "POST",
|
|
19
|
+
path: "/project/audience/profile/create",
|
|
20
|
+
});
|
|
10
21
|
});
|
|
11
22
|
}
|
|
12
23
|
}
|
package/dist/apis/SendApi.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
export class SendApi {
|
|
2
11
|
constructor(http) {
|
|
3
12
|
this.http = http;
|
|
@@ -19,11 +28,13 @@ export class SendApi {
|
|
|
19
28
|
* });
|
|
20
29
|
* @see {@link https://docs.ensend.co/send/mail-message | More in the documentation}
|
|
21
30
|
*/
|
|
22
|
-
|
|
23
|
-
return this
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
31
|
+
SendMailMessage(dto) {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
return this.http({
|
|
34
|
+
method: "POST",
|
|
35
|
+
path: "/send/mail",
|
|
36
|
+
body: dto,
|
|
37
|
+
});
|
|
27
38
|
});
|
|
28
39
|
}
|
|
29
40
|
/**
|
|
@@ -43,11 +54,13 @@ export class SendApi {
|
|
|
43
54
|
* });
|
|
44
55
|
* @see {@link https://docs.ensend.co/send/mail-broadast | More about personalization in the documentation}
|
|
45
56
|
*/
|
|
46
|
-
|
|
47
|
-
return this
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
57
|
+
SendMailBroadcast(dto) {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
return this.http({
|
|
60
|
+
method: "POST",
|
|
61
|
+
path: "/send/mail/broadcast",
|
|
62
|
+
body: dto,
|
|
63
|
+
});
|
|
51
64
|
});
|
|
52
65
|
}
|
|
53
66
|
/**
|
|
@@ -62,11 +75,13 @@ export class SendApi {
|
|
|
62
75
|
* // No other modifications can me made to a previously processed broadcast.
|
|
63
76
|
* @see {@link https://docs.ensend.co/send/mail-broadcast | More in the documentation}
|
|
64
77
|
*/
|
|
65
|
-
|
|
66
|
-
return this
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
78
|
+
SendExistingMailBroadcast(dto) {
|
|
79
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
+
return this.http({
|
|
81
|
+
method: "POST",
|
|
82
|
+
path: "/send/mail/broadcast",
|
|
83
|
+
body: dto,
|
|
84
|
+
});
|
|
70
85
|
});
|
|
71
86
|
}
|
|
72
87
|
}
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SendApi } from "./apis/SendApi";
|
|
1
|
+
import { SendApi } from "./apis/SendApi.js";
|
|
2
2
|
import type { ClientOptions, HttpClientError } from "./lib/types";
|
|
3
3
|
export declare class Client<const I extends readonly string[], const T extends readonly string[]> {
|
|
4
4
|
private ENSEND_BASE_URL;
|
package/dist/client.js
CHANGED
|
@@ -1,16 +1,26 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
import fetch from "node-fetch-native";
|
|
2
|
-
import { SendApi } from "./apis/SendApi";
|
|
11
|
+
import { SendApi } from "./apis/SendApi.js";
|
|
3
12
|
export class Client {
|
|
4
13
|
constructor(options) {
|
|
14
|
+
var _a;
|
|
5
15
|
this.ENSEND_BASE_URL = typeof process !== "undefined" && process.env.ENSEND_BASE_URL
|
|
6
16
|
? process.env.ENSEND_BASE_URL
|
|
7
17
|
: "https://api.ensend.co";
|
|
8
18
|
this.PROJECT_SECRET = typeof process !== "undefined"
|
|
9
|
-
? process
|
|
19
|
+
? (_a = process === null || process === void 0 ? void 0 : process.env) === null || _a === void 0 ? void 0 : _a.ENSEND_PROJECT_SECRET
|
|
10
20
|
: undefined;
|
|
11
|
-
this.http =
|
|
21
|
+
this.http = (options) => __awaiter(this, void 0, void 0, function* () {
|
|
12
22
|
try {
|
|
13
|
-
const res =
|
|
23
|
+
const res = yield fetch(this.ENSEND_BASE_URL + options.path, {
|
|
14
24
|
headers: {
|
|
15
25
|
"Content-Type": "application/json",
|
|
16
26
|
Authorization: `Bearer ${this.PROJECT_SECRET}`,
|
|
@@ -18,7 +28,7 @@ export class Client {
|
|
|
18
28
|
method: options.method,
|
|
19
29
|
body: options.method === "POST" ? JSON.stringify(options.body) : undefined,
|
|
20
30
|
});
|
|
21
|
-
const responseData =
|
|
31
|
+
const responseData = yield res.json();
|
|
22
32
|
if (res.status === 200) {
|
|
23
33
|
return { data: responseData, error: null };
|
|
24
34
|
}
|
|
@@ -33,9 +43,9 @@ export class Client {
|
|
|
33
43
|
},
|
|
34
44
|
};
|
|
35
45
|
}
|
|
36
|
-
};
|
|
46
|
+
});
|
|
37
47
|
this.SendApi = new SendApi(this.http);
|
|
38
|
-
if (options
|
|
48
|
+
if (options === null || options === void 0 ? void 0 : options.secret) {
|
|
39
49
|
this.PROJECT_SECRET = options.secret;
|
|
40
50
|
}
|
|
41
51
|
}
|
package/package.json
CHANGED