diff --git a/lib/haztrak.js b/lib/haztrak.js index 90d5f57..56bb515 100644 --- a/lib/haztrak.js +++ b/lib/haztrak.js @@ -16050,6 +16050,60 @@ async function eManRevert (mtn) { } } +/** + * Retrieve bill for provided bill id or date + * + * @param {object} bill billing object by ID or date + * @param {string} bill.billId invoice id number + * @param {string} bill.billingAccount billing account number + * @param {string} monthYear invoice month and year (mm/yyy) + * */ +async function eManBill (bill) { + try { + const billData = JSON.stringify(bill); + const res = await axiosPost({ + url: '/emanifest/billing/bill', + headers: { + Accept: 'application/json', + 'Content-Type': 'text/plain' + }, + data: billData + }); + return res.data + } catch (error) { + console.error('Problem retrieving bill'); + console.error(error.message); + console.error(error.response.data); + } +} + +/** + * Retrieve billing history by account ID + * + * @param {object} bill billing object by ID or date + * @param {string} bill.billingAccount billing account number + * @param {string} bill.startMonthYear start of invoice months and year (mm/yyy) + * @param {string} bill.endMonthYear end of invoice months and year (mm/yyy) + * */ +async function eManBillHistory (bill) { + try { + const billData = JSON.stringify(bill); + const res = await axiosPost({ + url: '/emanifest/billing/bill-history', + headers: { + Accept: 'application/json', + 'Content-Type': 'text/plain' + }, + data: billData + }); + return res.data + } catch (error) { + console.error('Problem retrieving bill history'); + console.error(error.message); + console.error(error.response.data); + } +} + var eManServices = /*#__PURE__*/Object.freeze({ __proto__: null, get: eManGet, @@ -16058,7 +16112,9 @@ var eManServices = /*#__PURE__*/Object.freeze({ sites: eManSites, exists: mtnExists, siteMtn: siteMtn, - revert: eManRevert + revert: eManRevert, + bill: eManBill, + billHistory: eManBillHistory }); // lookServ.js diff --git a/src/eManServices.js b/src/eManServices.js index c2f72a3..9d8be61 100644 --- a/src/eManServices.js +++ b/src/eManServices.js @@ -190,7 +190,62 @@ async function eManRevert (mtn) { } } +/** + * Retrieve bill for provided bill id or date + * + * @param {object} bill billing object by ID or date + * @param {string} bill.billId invoice id number + * @param {string} bill.billingAccount billing account number + * @param {string} monthYear invoice month and year (mm/yyy) + * */ +async function eManBill (bill) { + try { + const billData = JSON.stringify(bill) + const res = await eManAPI.post({ + url: '/emanifest/billing/bill', + headers: { + Accept: 'application/json', + 'Content-Type': 'text/plain' + }, + data: billData + }) + return res.data + } catch (error) { + console.error('Problem retrieving bill') + console.error(error.message) + console.error(error.response.data) + } +} + +/** + * Retrieve billing history by account ID + * + * @param {object} bill billing object by ID or date + * @param {string} bill.billingAccount billing account number + * @param {string} bill.startMonthYear start of invoice months and year (mm/yyy) + * @param {string} bill.endMonthYear end of invoice months and year (mm/yyy) + * */ +async function eManBillHistory (bill) { + try { + const billData = JSON.stringify(bill) + const res = await eManAPI.post({ + url: '/emanifest/billing/bill-history', + headers: { + Accept: 'application/json', + 'Content-Type': 'text/plain' + }, + data: billData + }) + return res.data + } catch (error) { + console.error('Problem retrieving bill history') + console.error(error.message) + console.error(error.response.data) + } +} + export { eManGet as get, eManSave as save, eManDel as delete, - eManSites as sites, mtnExists as exists, siteMtn, eManRevert as revert + eManSites as sites, mtnExists as exists, siteMtn, + eManRevert as revert, eManBill as bill, eManBillHistory as billHistory } diff --git a/test/scratchTest.js b/test/scratchTest.js index 869dea3..b368d82 100644 --- a/test/scratchTest.js +++ b/test/scratchTest.js @@ -18,9 +18,28 @@ import haztrak from '../index.js' // console.log(res) // } +// const fooBar = async () => { +// const mtn = '100030514ELC' +// const res = await haztrak.eMan.revert(mtn) +// console.log(res) +// } + +// const fooBar = async () => { +// const bill = { +// billId: '28391471', +// billingAccount: 'VAD000532119' +// } +// const res = await haztrak.eMan.bill(bill) +// console.log(res) +// } + const fooBar = async () => { - const mtn = '100030514ELC' - const res = await haztrak.eMan.revert(mtn) + const bill = { + billingAccount: 'VAD000532119', + startMonthYear: '01/2021', + endMonthYear: '04/2021' + } + const res = await haztrak.eMan.billHistory(bill) console.log(res) } fooBar()