Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
feat: bill and bill history
Browse files Browse the repository at this point in the history
  • Loading branch information
dpgraham4401 committed Jul 13, 2021
1 parent 4df80fa commit 353d55f
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 4 deletions.
58 changes: 57 additions & 1 deletion lib/haztrak.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
57 changes: 56 additions & 1 deletion src/eManServices.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
23 changes: 21 additions & 2 deletions test/scratchTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 353d55f

Please sign in to comment.