OR
offers: stringified array of { id; startDate; endDate; duration; repaymentSchedule; lenderName; lenderEthAddr; BorrowerEthAddr}objects.
If only lenderEthAddr provided, then retrieve an array of offers made by that lender from db, excluding those which are also in accepted loans.
If more fields than lenderEthAddr are provided, wrap params object in array.
If offers passed, unwrap into array
Filter array keeping only objects where
all of { duration; lenderEthAddr; BorrowerEthAddr } provided or
all of { startDate; endDate; lenderEthAddr; BorrowerEthAddr } provided
For each object, calculate startDate; endDate; duration if missing.
For each object, add two properties txWithdraw & txRegister which are clones of each other:
= {
from: borrowerEthAddr,
to: contractAddr, // use env2 to set this as app constant - '0x12345' is fine
gasPrice: "9000000000",
gas: "85000",
data: ""
};
endpoint accepts as params:
lenderEthAddr
and, optionally,{ id; startDate; endDate; duration; repaymentSchedule; lenderName; lenderEthAddr; BorrowerEthAddr}
OR offers: stringified array of
{ id; startDate; endDate; duration; repaymentSchedule; lenderName; lenderEthAddr; BorrowerEthAddr}
objects.If only
lenderEthAddr
provided, then retrieve an array of offers made by that lender from db, excluding those which are also in accepted loans. If more fields thanlenderEthAddr
are provided, wrap params object in array. Ifoffers
passed, unwrap into arrayFilter array keeping only objects where all of
{ duration; lenderEthAddr; BorrowerEthAddr }
provided or all of{ startDate; endDate; lenderEthAddr; BorrowerEthAddr }
providedFor each object, calculate
startDate; endDate; duration
if missing.For each object, add two properties
txWithdraw
&txRegister
which are clones of each other:as in #5
and respond with stringified resulting array