Skip to content

Commit

Permalink
fix: re-structure account response
Browse files Browse the repository at this point in the history
  • Loading branch information
lykmapipo committed Mar 25, 2021
1 parent a4fce47 commit 0ab04ec
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,11 @@ export const getAccount = (optns) => {
// spread api rsults
spread((account = {}, bills = []) => {
// prepare normalized account
const myAccount = {
let myAccount = {
account: {},
customer: {},
bills: [],
accessors: [],
fetchedAt: new Date(),
};

// merge account results
Expand All @@ -209,6 +208,19 @@ export const getAccount = (optns) => {
myBills = orderBy([].concat(myBills), 'period.billedAt', 'desc');
myAccount.bills = myBills;

// re-shape results
myAccount = mergeObjects(
{},
myAccount.account,
{
accessors: myAccount.accessors,
bills: myAccount.bills,
},
{
fetchedAt: new Date(),
}
);

// return normalized account
return myAccount;
})
Expand Down

0 comments on commit 0ab04ec

Please sign in to comment.