Overview
When writing your skills, you may need to access data made available from the PrecisionLender API endpoints. The PrecisionLender API powers in Andi® allows you to access this data, but requires that your instance of PrecisionLender be set up to use the API and that your account has the required service username and tokens. With the API V2 Powers, you can get opportunity response and relationship response data via PrecisionLender's V2 API without the service username and tokens. For other PrecisionLender V2 API endpoints, you will still need to use the PrecisionLender API powers.
In this Article
What are the PrecisionLender API V2 Powers?
The PrecisionLender API V2 Powers allows you to return a promise using the 'get' method with the opportunityId parameter for the opportunity response and the relationshipId parameter for the relationship response (the defined parameters in the PrecisionLender API documentation).
Opportunity
- getOpportunityResponse (opportunityId: string) - returns the opportunity response model for a single, saved opportunity. For more information, see GetOpportunity API Documentation.
- getOpportunityRelationshipImpactResponse (opportunityId: string) - returns the relationship impact financial statement for a single, saved opportunity with an attached relationship. For more information, see GetOpportunityRelationshipImpact API Documentation.
- getRelationshipForOpportunity (opportunityId: string) - returns the account level detailed financial data and a list containing any child relationship information for the relationship that is attached to a given opportunityId. This Full Relationship data includes any Opportunity level Relationship override information. If Opportunity does not have a Relationship attached then it returns null.
Relationship
- getRelationshipSummaryResponse (relationshipId: string) - returns the relationship summary for a single relationship. This does not include account level data (ie loan and deposit level). For more information, see GetRelationshipSummary API Documentation.
- getRelationshipAccountSummariesResponse (relationshipId: string) - returns the account level financial summary data for a single relationship. The summary is grouped by product. For more information, see GetRelationshipAccountSummary API Documentation.
- getFullRelationshipResponse (relationshipId: string) - returns the account level detailed financial data and a list containing any child relationship information for a single relationship.
How to call the PrecisionLender API V2 Powers
The V2 powers will be called via their respective PrecisionLender model properties via the PrecisionLender powers and then returned as a promise:
Opportunity
//getOpportunityResponse
skillContext.powers.precisionLender.opportunity
.api.v2.getOpportunityResponse(opportunityId)
.then((opp) => {
//work within the oppportunityResponse model
})
//getOpportunityRelationshipImpactResponse
skillContext.powers.precisionLender.opportunity
.api.v2.getOpportunityRelationshipImpactResponse(opportunityId)
.then((opp) => {
//work within the oppportunityRelationshipImpactResponse model
})
//getRelationshipForOpportunity
skillContext.powers.precisionLender.opportunity
.api.v2.getRelationshipForOpportunity(opportunityId)
.then((relationship) => {
//work within the FullRelationshipReponse model
})
Relationship
//getRelationshipSummaryResponse
skillContext.powers.precisionLender.relationship
.api.v2.getRelationshipSummaryResponse(relationshipId)
.then((relationship) => {
//work within the relationshipSummaryResponse model
})
//getRelationshipAccountSummariesResponse
skillContext.powers.precisionLender.relationship
.api.v2.getRelationshipAccountSummariesResponse(relationshipId)
.then((relationship) => {
//work within the relationshipAccountSummariesResponse model
})
//getFullRelationshipResponse
skillContext.powers.precisionLender.relationship
.api.v2.getFullRelationshipResponse(relationshipId)
.then((relationship) => {
//work within the FullRelationshipResponse model
})
Here's an example of skill code that retrieves the stage of an opportunity using the V2 power:
return skillContext.powers.precisionLender
.opportunity.getSavedOpportunityModel()
.then((opportunityModel) => {
if (!opportunityModel){return null;}
return opportunityModel.id.id
})
.then ((opportunityId) => {
if(!opportunityId){return null}
return skillContext.powers.precisionLender.opportunity
.api.v2.getOpportunityResponse(opportunityId)
})
.then ((opportunityResponse) => {
if(!opportunityResponse) {return null}
let opportunityStage = opportunityResponse.stage
return skillContext.powers.andi.email.sendEmail(
"stage-change-email-notification",
andiSkills.EmailFrequencyTypes.Daily,
[new andiSkills.EmailUserModel("Joe Manager", "joemanager@bank.com")],
"branchupdate@bank.com",
"Opportunity Saved",
"An opportunity has been saved in the following stage: " + opportunityStage + "!",
"",
""
),
})