import { Logger } from "../models" ; import fetch from 'node-fetch' ; export class BusyLightService { param url public static async get ( url , log , debug = false ) { try { if ( debug ) { log . info ( `Calling the busy light API: ${ url }` ) ; } const data = await fetch ( url ) ; if ( debug ) { log . info ( `Call was: ${ data . ok }` ) ; } } catch ( error ) { log . warn ( `Seems to be the busy light API was offline` ) ; } } param url public static async post ( url , body , log , debug = false ) { try { if ( debug ) { log . info ( `Calling the busy light API: ${ url } - ${ JSON . stringify ( body ) }` ) ; } const data = await fetch ( url , { method : "POST" , headers : { "Content-Type" : "application/json" } , body : JSON . stringify ( body ) } ) ; if ( debug ) { log . info ( `Call was: ${ data . ok }` ) ; } } catch ( error ) { log . warn ( `Seems to be the busy light API was offline` ) ; } } }