UNPKG

ih-black-lion

Version:

State handler for Arus projects

29 lines (26 loc) 982 B
import Connector from './Connector'; const URLS = { tryURL: __COURSES_URL__, catchURL: process.env.COURSES, }; export default class CoursesConnector extends Connector { constructor(requestMethod, requestParams, Model, subject, institution, extraParam = undefined) { super(requestMethod, requestParams, Model, URLS, extraParam); this.subject = subject; this.institution = institution; this.modifySend(); } checkTypes() { super.checkTypes(); if (typeof this.subject !== 'string') { return Promise.reject(new TypeError(`Type of subject is ${typeof this.subject}. Expected a string\n\tsubject = ${this.subject}`)); } return true; } modifySend() { if (!this.params.send) { this.params.send = `<SSR_GET_COURSES_REQ><COURSE_SEARCH_REQUEST><INSTITUTION>${this.institution}</INSTITUTION><SUBJECT>${this.subject}</SUBJECT><SSR_CRS_SRCH_MODE>D</SSR_CRS_SRCH_MODE></COURSE_SEARCH_REQUEST></SSR_GET_COURSES_REQ>`; } } }