const fs = require('fs');
const path = require('path');
const log = require('loglevel');

class InspectionServ {
    constructor () {
        this.axios = global.axiosInstances.axiosAfcInstance;
    }

    getPenalty = async (fineId) => {
        try {
            const res = await this.axios.get('inspection/fine/'+fineId);
            if (typeof res === 'undefined' || res.status >= 400) { return null; }
            return res;
        } catch (err) {
            log.error(err);
        }
    }

    payPenalty = async (fineId, penalty) => {
        try {
            const res = await this.axios.put('inspection/fine/'+fineId+'/mark-paid', penalty);
            if (typeof res === 'undefined' || res.status >= 400) { return false; }
            return true;
        } catch (err) {
            log.error(err);
        }
    }

    getPenaltiesForAccount = async (shortId) => {
        try {
            const res = await this.axios.get('inspection/fine/account/'+shortId);
            if (typeof res === 'undefined' || res.status >= 400) { return null; }
            return res;
        } catch (err) {
            log.error(err);
        }
    }

}

module.exports = InspectionServ;
