mail-monster-lib 0.0.3 → 0.0.4
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.
|
@@ -1,27 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
*/
|
|
19
|
-
multiply(number1: number, number2: number): number;
|
|
20
|
-
/**
|
|
21
|
-
* Divide two numbers
|
|
22
|
-
* @param number1 First number to be divided
|
|
23
|
-
* @param number2 Second number to divide
|
|
24
|
-
*/
|
|
25
|
-
divide(number1: number, number2: number): number;
|
|
26
|
-
};
|
|
27
|
-
export declare function getEmails(): Promise<string>;
|
|
1
|
+
/**
|
|
2
|
+
* Parameters for fetching the latest emails via Mail Monster API.
|
|
3
|
+
*
|
|
4
|
+
* @property api_key - (Required) The API key used for authentication.
|
|
5
|
+
* @property email - (Optional) Only return messages for this recipient email address.
|
|
6
|
+
* @property title - (Optional) Case-insensitive substring to search for in the subject.
|
|
7
|
+
* @property keyword - (Optional) Case-insensitive string to match anywhere in subject, sender, content, or attachments.
|
|
8
|
+
* @property count - (Optional) Maximum number of email messages to return. Defaults to a small value if not specified.
|
|
9
|
+
*/
|
|
10
|
+
export interface IGetLatestEmailParams {
|
|
11
|
+
api_key: string;
|
|
12
|
+
email?: string;
|
|
13
|
+
title?: string;
|
|
14
|
+
keyword?: string;
|
|
15
|
+
count?: number;
|
|
16
|
+
}
|
|
17
|
+
export declare function getLatestEmails(params: IGetLatestEmailParams): Promise<string>;
|
package/dist/mail-monster-lib.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// my awesome library
|
|
3
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
4
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
@@ -36,56 +35,38 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
35
|
}
|
|
37
36
|
};
|
|
38
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Add two numbers
|
|
43
|
-
* @param number1 First number to add
|
|
44
|
-
* @param number2 Second number to add
|
|
45
|
-
*/
|
|
46
|
-
add: function (number1, number2) {
|
|
47
|
-
return number1 + number2;
|
|
48
|
-
},
|
|
49
|
-
/**
|
|
50
|
-
* Subtract two numbers
|
|
51
|
-
* @param number1 First number to be subtracted
|
|
52
|
-
* @param number2 Second number to subtract
|
|
53
|
-
*/
|
|
54
|
-
subtract: function (number1, number2) {
|
|
55
|
-
return number1 - number2;
|
|
56
|
-
},
|
|
57
|
-
/**
|
|
58
|
-
* Multiply two numbers
|
|
59
|
-
* @param number1 First number to multiply
|
|
60
|
-
* @param number2 Second number to multiply
|
|
61
|
-
*/
|
|
62
|
-
multiply: function (number1, number2) {
|
|
63
|
-
return number1 * number2;
|
|
64
|
-
},
|
|
65
|
-
/**
|
|
66
|
-
* Divide two numbers
|
|
67
|
-
* @param number1 First number to be divided
|
|
68
|
-
* @param number2 Second number to divide
|
|
69
|
-
*/
|
|
70
|
-
divide: function (number1, number2) {
|
|
71
|
-
return number1 / number2;
|
|
72
|
-
},
|
|
73
|
-
};
|
|
74
|
-
function getEmails() {
|
|
38
|
+
var LATEST_EMAIL_ENDPOINT = 'https://mail-monster-api.create-flow.ai/api/latest?';
|
|
39
|
+
function getLatestEmails(params) {
|
|
75
40
|
return __awaiter(this, void 0, void 0, function () {
|
|
76
|
-
var response;
|
|
41
|
+
var url, fetchEndpoint, response;
|
|
77
42
|
return __generator(this, function (_a) {
|
|
78
43
|
switch (_a.label) {
|
|
79
|
-
case 0:
|
|
44
|
+
case 0:
|
|
45
|
+
url = new URL(LATEST_EMAIL_ENDPOINT);
|
|
46
|
+
url.searchParams.append('apikey', params.api_key);
|
|
47
|
+
if (params.email) {
|
|
48
|
+
url.searchParams.append('email', params.email);
|
|
49
|
+
}
|
|
50
|
+
if (params.title) {
|
|
51
|
+
url.searchParams.append('title', params.title);
|
|
52
|
+
}
|
|
53
|
+
if (params.keyword) {
|
|
54
|
+
url.searchParams.append('keyword', params.keyword);
|
|
55
|
+
}
|
|
56
|
+
if (params.count !== undefined) {
|
|
57
|
+
url.searchParams.append('count', String(params.count));
|
|
58
|
+
}
|
|
59
|
+
fetchEndpoint = url.toString();
|
|
60
|
+
return [4 /*yield*/, fetch(fetchEndpoint)];
|
|
80
61
|
case 1:
|
|
81
62
|
response = _a.sent();
|
|
82
63
|
if (!response.ok) {
|
|
83
|
-
throw new Error("Failed to fetch: " + response.status + " " + response.statusText);
|
|
64
|
+
throw new Error("Failed to fetch email: " + response.status + " " + response.statusText);
|
|
84
65
|
}
|
|
85
66
|
return [2 /*return*/, response.text()];
|
|
86
67
|
}
|
|
87
68
|
});
|
|
88
69
|
});
|
|
89
70
|
}
|
|
90
|
-
exports.
|
|
71
|
+
exports.getLatestEmails = getLatestEmails;
|
|
91
72
|
//# sourceMappingURL=mail-monster-lib.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mail-monster-lib.js","sourceRoot":"","sources":["../src/mail-monster-lib.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mail-monster-lib.js","sourceRoot":"","sources":["../src/mail-monster-lib.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAM,qBAAqB,GAAG,qDAAqD,CAAC;AAmBpF,yBAAsC,MAA6B;;;;;;oBAC3D,GAAG,GAAG,IAAI,GAAG,CAAC,qBAAqB,CAAC,CAAC;oBAC3C,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;oBAClD,IAAI,MAAM,CAAC,KAAK,EAAE;wBAAE,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;qBAAE;oBACrE,IAAI,MAAM,CAAC,KAAK,EAAE;wBAAE,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;qBAAE;oBACrE,IAAI,MAAM,CAAC,OAAO,EAAE;wBAAE,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;qBAAE;oBAC3E,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,EAAE;wBAAE,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;qBAAE;oBACrF,aAAa,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC;oBACpB,qBAAM,KAAK,CAAC,aAAa,CAAC,EAAA;;oBAArC,QAAQ,GAAG,SAA0B;oBAC3C,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE;wBAChB,MAAM,IAAI,KAAK,CAAC,4BAA0B,QAAQ,CAAC,MAAM,SAAI,QAAQ,CAAC,UAAY,CAAC,CAAC;qBACrF;oBACD,sBAAO,QAAQ,CAAC,IAAI,EAAE,EAAC;;;;CACxB;AAbD,0CAaC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __awaiter=this&&this.__awaiter||function(thisArg,_arguments,P,generator){return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator["throw"](value))}catch(e){reject(e)}}function step(result){result.done?resolve(result.value):new P(function(resolve){resolve(result.value)}).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())})};var __generator=this&&this.__generator||function(thisArg,body){var _={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},f,y,t,g;return g={next:verb(0),throw:verb(1),return:verb(2)},typeof Symbol==="function"&&(g[Symbol.iterator]=function(){return this}),g;function verb(n){return function(v){return step([n,v])}}function step(op){if(f)throw new TypeError("Generator is already executing.");while(_)try{if(f=1,y&&(t=op[0]&2?y["return"]:op[0]?y["throw"]||((t=y["return"])&&t.call(y),0):y.next)&&!(t=t.call(y,op[1])).done)return t;if(y=0,t)op=[op[0]&2,t.value];switch(op[0]){case 0:case 1:t=op;break;case 4:_.label++;return{value:op[1],done:false};case 5:_.label++;y=op[1];op=[0];continue;case 7:op=_.ops.pop();_.trys.pop();continue;default:if(!(t=_.trys,t=t.length>0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]<t[3])){_.label=op[1];break}if(op[0]===6&&_.label<t[1]){_.label=t[1];t=op;break}if(t&&_.label<t[2]){_.label=t[2];_.ops.push(op);break}if(t[2])_.ops.pop();_.trys.pop();continue}op=body.call(thisArg,_)}catch(e){op=[6,e];y=0}finally{f=t=0}if(op[0]&5)throw op[1];return{value:op[0]?op[1]:void 0,done:true}}};Object.defineProperty(exports,"__esModule",{value:true});
|
|
1
|
+
"use strict";var __awaiter=this&&this.__awaiter||function(thisArg,_arguments,P,generator){return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator["throw"](value))}catch(e){reject(e)}}function step(result){result.done?resolve(result.value):new P(function(resolve){resolve(result.value)}).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())})};var __generator=this&&this.__generator||function(thisArg,body){var _={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},f,y,t,g;return g={next:verb(0),throw:verb(1),return:verb(2)},typeof Symbol==="function"&&(g[Symbol.iterator]=function(){return this}),g;function verb(n){return function(v){return step([n,v])}}function step(op){if(f)throw new TypeError("Generator is already executing.");while(_)try{if(f=1,y&&(t=op[0]&2?y["return"]:op[0]?y["throw"]||((t=y["return"])&&t.call(y),0):y.next)&&!(t=t.call(y,op[1])).done)return t;if(y=0,t)op=[op[0]&2,t.value];switch(op[0]){case 0:case 1:t=op;break;case 4:_.label++;return{value:op[1],done:false};case 5:_.label++;y=op[1];op=[0];continue;case 7:op=_.ops.pop();_.trys.pop();continue;default:if(!(t=_.trys,t=t.length>0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]<t[3])){_.label=op[1];break}if(op[0]===6&&_.label<t[1]){_.label=t[1];t=op;break}if(t&&_.label<t[2]){_.label=t[2];_.ops.push(op);break}if(t[2])_.ops.pop();_.trys.pop();continue}op=body.call(thisArg,_)}catch(e){op=[6,e];y=0}finally{f=t=0}if(op[0]&5)throw op[1];return{value:op[0]?op[1]:void 0,done:true}}};Object.defineProperty(exports,"__esModule",{value:true});var LATEST_EMAIL_ENDPOINT="https://mail-monster-api.create-flow.ai/api/latest?";function getLatestEmails(params){return __awaiter(this,void 0,void 0,function(){var url,fetchEndpoint,response;return __generator(this,function(_a){switch(_a.label){case 0:url=new URL(LATEST_EMAIL_ENDPOINT);url.searchParams.append("apikey",params.api_key);if(params.email){url.searchParams.append("email",params.email)}if(params.title){url.searchParams.append("title",params.title)}if(params.keyword){url.searchParams.append("keyword",params.keyword)}if(params.count!==undefined){url.searchParams.append("count",String(params.count))}fetchEndpoint=url.toString();return[4,fetch(fetchEndpoint)];case 1:response=_a.sent();if(!response.ok){throw new Error("Failed to fetch email: "+response.status+" "+response.statusText)}return[2,response.text()]}})})}exports.getLatestEmails=getLatestEmails;
|