Skip to content

Commit bd03556

Browse files
committed
some adjusts
1 parent 69389c5 commit bd03556

File tree

2 files changed

+30
-12
lines changed

2 files changed

+30
-12
lines changed

components/easypromos/sources/common/base.mjs

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";
1+
import {
2+
ConfigurationError, DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
3+
} from "@pipedream/platform";
24
import easypromos from "../../easypromos.app.mjs";
35

46
export default {
@@ -35,19 +37,27 @@ export default {
3537
},
3638
async emitEvent(maxResults = false) {
3739
const lastId = this._getLastId();
40+
let responseArray = [];
3841

39-
const response = this.easypromos.paginate({
40-
fn: this.getFunction(),
41-
...this.getOpts(),
42-
params: {
43-
order: "created_desc",
44-
},
45-
});
42+
try {
43+
const response = this.easypromos.paginate({
44+
fn: this.getFunction(),
45+
...this.getOpts(),
46+
params: {
47+
order: "created_desc",
48+
},
49+
});
4650

47-
let responseArray = [];
48-
for await (const item of response) {
49-
if (item.id <= lastId) break;
50-
responseArray.push(item);
51+
for await (const item of response) {
52+
if (item.id <= lastId) break;
53+
responseArray.push(item);
54+
}
55+
} catch (err) {
56+
console.log(err);
57+
if (err?.response?.data?.code === 0) {
58+
throw new ConfigurationError("You can only use this trigger with promotions that have the 'Virtual Coins' feature enabled.");
59+
}
60+
throw new ConfigurationError(err);
5161
}
5262

5363
if (responseArray.length) {

components/easypromos/sources/new-coin-transaction/new-coin-transaction.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ export default {
99
version: "0.0.1",
1010
type: "source",
1111
dedupe: "unique",
12+
props: {
13+
...common.props,
14+
info2: {
15+
type: "alert",
16+
alertType: "warning",
17+
content: "You can only use this trigger with promotions that have the 'Virtual Coins' feature enabled.",
18+
},
19+
},
1220
methods: {
1321
...common.methods,
1422
getFunction() {

0 commit comments

Comments
 (0)