Creating a Loan Portfolio
Description
This web service creates a Portfolio.It commits an object of type Booking Order (Booking_Order__c) to the database.
Definition
POST https://<domain>/services/apexrest/peer/v1/portfolios/*
Parameters
The table given below provides details of the request parameters used by this web service:
Fields | Type | Description |
---|---|---|
investorId* | String |
|
amount* | Decimal |
|
Error messages
When you use this web service you can receive the possible error messages as shown in the table below:
Error code | Error Message | System.Label | Reason | HTTP Status Code |
---|---|---|---|---|
INVALID_INPUT | Unable to parse the Request parameters. | UNABLE_PARSE_REQ_PARAMS | You will receive this error if error occurs while parsing request parameters. | 400 |
INVALID_INPUT | Unknown Exception : <exception_message> | UNKNOWN_EXCEPTION | You will receive this error if there is an unknown exception while parsing request parameters. | 400 |
INVALID_INPUT | Investor Id is null. | INVESTOR_ID_NULL | You will receive this error if account Id for investor (investorId) is not specified in the request parameters. | 400 |
API_EXCEPTION | Insufficient Loan Applications. | INSUFFICIENT_LOANS_APPS | You will receive this error if there are no Loan Applications in the system. | 400 |
API_EXCEPTION | There are no loan applications for this investor. | NO_LOAN_APPS_FOR_THIS_INVESTOR | You will receive this error if the Investor has already invested in all possible Loan Applications. | 400 |
API_EXCEPTION | Insufficient Funds. | INSUFFICIENT_FUNDS | You will receive this error if the Investor doesn't have sufficient funds in his account. | 400 |
API_EXCEPTION | Portfolio Limit has reached. | PORTFOLIO_LIMIT_HIT | You will receive this error if limit for generating portfolios has been reached. These limits are defined using Portfolio Generation Count Per Day and Portfolio Generation Count Per Hour fields in Auto Portfolio Admin Params custom settings. | |
API_EXCEPTION | <exception_message> | NA | You will receive this error if any validation fails or any unexpected error occurs during the processing of the request, the system will raise the exception. | 500 |
Sample Request
The sample request to be sent is as shown below:
POST https://na11.salesforce.com/services/apexrest/peer/v1/portfolios
{ "investorId": "001G000001Phdoe", "amount": 10000 }
Sample Response
This sample response contains the newly created portfolio. The sample response that you will receive is as shown below:
{ "status": "SUCCESS", "response": [], "errorMessage": null, "errorCode": "NO_ERROR", "content": [ { "attributes": { "type": "peer__Booking_Order__c", "url": "/services/data/v30.0/sobjects/peer__Booking_Order__c/a2uG00000005nXuIAI" }, "peer__Funded_Amount__c": 0, "peer__Safe_Funds__c": 140, "peer__Weighted_Safe_Fund__c": 1.4, "peer__Status__c": "Uncommitted", "peer__Requested_Amount__c": 10000, "peer__Amount_In_Funding__c": 0, "peer__Weighted_Duration__c": 12, "Name": "BO-00006472", "peer__Investor__c": "001G000001PhdoeIAB", "peer__Investment_Bookings__r": { "totalSize": 1, "done": true, "records": [ { "attributes": { "type": "peer__Investment_Booking__c", "url": "/services/data/v30.0/sobjects/peer__Investment_Booking__c/a2tG00000004o9xIAA" }, "peer__Stage__c": "New", "peer__Safe_Fund_Amount__c": 140, "peer__Status__c": "Uncommitted", "peer__Service_Rate__c": 1, "peer__Investment_Amount__c": 9860, "peer__Booking_Order__r": { "attributes": { "type": "peer__Booking_Order__c", "url": "/services/data/v30.0/sobjects/peer__Booking_Order__c/a2uG00000005nXuIAI" }, "peer__Investor__r": { "attributes": { "type": "Account", "url": "/services/data/v30.0/sobjects/Account/001G000001PhdoeIAB" }, "Name": "Anil Bhat market place", "loan__Undeployed_Funds__c": 47286.5, "loan__Deployed_Funds__c": 281580, "peer__Nickname__c": "Anil", "Id": "001G000001PhdoeIAB", "loan__Reinvest_Principal__c": false, "loan__Reinvest_Interest__c": false }, "peer__Investor__c": "001G000001PhdoeIAB", "peer__Funded_Amount__c": 0, "peer__Amount__c": 9860, "peer__Number_of_Bookings__c": 1, "Id": "a2uG00000005nXuIAI", "peer__Date__c": "2014-07-25", "peer__Amount_In_Funding__c": 0 }, "Name": "IB-00016968", "peer__Loan_Application__r": { "attributes": { "type": "peer__Loan_Application__c", "url": "/services/data/v30.0/sobjects/peer__Loan_Application__c/a2qG00000009Iy3IAE" }, "peer__Minimum_Interest_Rate__c": 8, "peer__Borrower__r": { "attributes": { "type": "Account", "url": "/services/data/v30.0/sobjects/Account/001G000001TcbIsIAJ" }, "Id": "001G000001TcbIsIAJ" }, "peer__Borrower__c": "001G000001TcbIsIAJ", "peer__Loan_Purpose_1__c": "a1hG0000000IL3mIAG", "peer__Expiry_Date__c": "2014-08-31T17:21:00.000+0000", "peer__Loan_Purpose_1__r": { "attributes": { "type": "loan__Loan_Purpose__c", "url": "/services/data/v30.0/sobjects/loan__Loan_Purpose__c/a1hG0000000IL3mIAG" }, "Name": "Personal", "Id": "a1hG0000000IL3mIAG" }, "Id": "a2qG00000009Iy3IAE", "peer__Percent_Funded__c": 100, "peer__Time_Left__c": "240 Days -20 Hours -45 Minutes", "peer__Term__c": 12 }, "peer__Certificate_Rate__c": 9.8, "peer__Share__c": 65.73, "CreatedDate": "2014-09-25T14:06:52.000+0000", "peer__Bid_Date__c": "2014-07-25T14:06:51.000+0000", "Id": "a2tG00000004o9xIAA", "peer__Loan_Application__c": "a2qG00000009Iy3IAE", "peer__Booking_Order__c": "a2uG00000005nXuIAI" } ] }, "peer__Amount__c": 9860, "peer__Number_of_Bookings__c": 1, "peer__Weighted_Interest__c": 9.8, "Id": "a2uG00000005nXuIAI", "peer__Date__c": "2014-07-25", "peer__Portfolio_Actual_Amount__c": 9860 } ] }