UNPKG

ih-black-lion

Version:

State handler for Arus projects

29 lines (25 loc) 1.15 kB
import Connector from './Connector'; const URLS = { tryURL: __EVENTS_URL__, catchURL: process.env.EVENTS_URL, }; export default class EventsConnector extends Connector { constructor(requestMethod, requestParams, Model, numDaysPast, includeEvents, extraParam = undefined) { super(requestMethod, requestParams, Model, URLS, extraParam); this.numDaysPast = numDaysPast; this.includeEvents = includeEvents; this.modifySend(); } modifySend() { if (!this.params.send) { if (typeof this.numDaysPast !== 'number') { return Promise.reject(new TypeError(`Type of numDaysPast is ${typeof this.numDaysPast}. Expected a number\n\tnumDaysPast = ${this.numDaysPast}`)); } else if (typeof this.includeEvents !== 'string') { return Promise.reject(new TypeError(`Type of includeEvents is ${typeof this.includeEvents}. Expected a string\n\tincludeEvents = ${this.includeEvents}`)); } this.params.send = `<SCC_NTF_GET_EVENTS_REQ_R><NUM_PAST_DAYS>${this.numDaysPast}</NUM_PAST_DAYS><INCLUDE_EVENTS>${this.includeEvents}</INCLUDE_EVENTS></SCC_NTF_GET_EVENTS_REQ_R>`; } return true; } }