Skip to content

Commit f5f3ca1

Browse files
committed
some adjusts
1 parent 9cd2cb1 commit f5f3ca1

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

components/mailosaur/sources/common/base.mjs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,23 @@ export default {
2828
getData() {
2929
return {};
3030
},
31+
dataValidation() {
32+
return true;
33+
},
34+
getOtherOpts() {
35+
return {};
36+
},
3137
async emitEvent(maxResults = false) {
3238
const lastDate = this._getLastDate();
3339

40+
const otherOpts = this.getOtherOpts();
3441
const response = this.mailosaur.paginate({
3542
fn: this.getFunction(),
3643
params: {
3744
receivedAfter: lastDate,
3845
server: this.serverId,
3946
},
40-
data: this.getData(),
47+
...otherOpts,
4148
});
4249

4350
let responseArray = [];
@@ -68,6 +75,7 @@ export default {
6875
},
6976
},
7077
async run() {
78+
await this.dataValidation();
7179
await this.emitEvent();
7280
},
7381
};

components/mailosaur/sources/new-email-matching-criteria/new-email-matching-criteria.mjs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { ConfigurationError } from "@pipedream/platform";
12
import { MATCH_OPTIONS } from "../../common/constants.mjs";
23
import common from "../common/base.mjs";
34
import sampleEmit from "./test-event.mjs";
@@ -41,20 +42,27 @@ export default {
4142
label: "Match",
4243
description: "If set to `ALL` (default), then only results that match all specified criteria will be returned. If set to `ANY`, results that match any of the specified criteria will be returned.",
4344
options: MATCH_OPTIONS,
44-
optional: true,
4545
},
4646
},
4747
methods: {
4848
...common.methods,
49-
getData() {
49+
getOtherOpts() {
5050
return {
51-
sentFrom: this.sentFrom,
52-
sentTo: this.sentTo,
53-
subject: this.subject,
54-
body: this.body,
55-
match: this.match,
51+
data: {
52+
sentFrom: this.sentFrom,
53+
sentTo: this.sentTo,
54+
subject: this.subject,
55+
body: this.body,
56+
match: this.match,
57+
},
5658
};
5759
},
60+
dataValidation() {
61+
if (!this.sentFrom && !this.sentTo && !this.subject && !this.body) {
62+
throw new ConfigurationError("Please provide at least one search criteria.");
63+
}
64+
return true;
65+
},
5866
getFunction() {
5967
return this.mailosaur.searchMessages;
6068
},

0 commit comments

Comments
 (0)