selva-riskeval
Version:
Testing One MGA sdk creation
88 lines (77 loc) • 2.6 kB
JavaScript
import axios from "axios";
export default class InsuranceQuote{
apiKey;
baseURL='https://vz1z84zy6f.execute-api.us-west-2.amazonaws.com/quote/'
#headers={
'Content-Type': 'application/json'
}
constructor(apiKey){
this.apiKey= apiKey
}
async createQuoteRequest(data){
try{
// let response = await axios.post(this.baseURL+'request',data,this.#headers)
let mockResponse = {
"quote_request_id": "2e8f66e4-9371-4966-8210-e735c7559859"
}
return mockResponse["quote_request_id"]
}catch(err){
throw Error(err.message)
}
}
async acceptQuote(data){
try{
return {status: 'rejected'};
}catch(err){
throw Error(err.message)
}
}
async submitQuote(data){
try{
// let response = await axios.post(this.baseURL+'submit',data,this.#headers)
let mockResponse = {
"quote_id": "ddaaff52-0c87-4f2d-9ba4-3a7ff2d478bc"
}
return mockResponse['quote_id'];
}catch(err){
throw Error(err.message)
}
}
async rejectQuote(data){
try{
// let response = await axios.post(this.baseURL+'reject',data,this.#headers)
return {status: 'rejected'};
}catch(err){
throw Error(err.message)
}
}
async getAllQuotes(id){
try{
let mockResponse= { "quotes": [
{
"coverage_id": "7105ba81-dd0f-4b87-9736-f0e5a15e946c",
"issued_by": "15cc7cc5-3aa1-44b4-a662-95abc5c19bbe",
"approximate_start_date": "2022-12-04",
"coverage_layer": "100%",
"broker_id": "wer99141-e2db-49ad-aab7-e64ee88871af",
"quote_id": "cfb2fcf8-7cc4-4f59-9b48-53cabe2e0336",
"premium_amount": 294.93,
"valid_from": "2022-11-29",
"description": "Flood Insurance",
"deductible_amount": 1250,
"issued_for": "eb299141-e2db-49ad-aab7-e64ee88871af",
"issue_date": "2022-11-29",
"valid_to": "2022-12-14",
"for_product": "FLR100008",
"insured_risk_id": "181d1bac-072d-4579-b9a2-e40a67429ad0",
"term_type": "365 days",
"status": "new"
}
]}
return mockResponse["quotes"][0]
}catch(err){
throw Error(err.message)
}
}
}
// export {RiskEval}