File tree Expand file tree Collapse file tree 2 files changed +30
-12
lines changed
components/easypromos/sources Expand file tree Collapse file tree 2 files changed +30
-12
lines changed Original file line number Diff line number Diff line change 1- import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform" ;
1+ import {
2+ ConfigurationError , DEFAULT_POLLING_SOURCE_TIMER_INTERVAL ,
3+ } from "@pipedream/platform" ;
24import easypromos from "../../easypromos.app.mjs" ;
35
46export 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 ) {
Original file line number Diff line number Diff 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 ( ) {
You can’t perform that action at this time.
0 commit comments