Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import groovy.json.JsonOutput
- def payload = [:];
- def plsMap = [:];
- def nodMap = [:];
- def primaryPayload = [:];
- plsMap.BasicPlan = 1;
- plsMap.ExtendaPlan = 2;
- plsMap.OmniPlan = 3;
- plsMap.PrescriptionDrugBasic = 4;
- plsMap.DentalCare = 5;
- plsMap.HospitalCash = 6;
- plsMap.Travel15DaysPerTrip = 7;
- plsMap.Travel30DaysPerTrip = 9;
- plsMap.Travel48daysPerTrip = 10;
- plsMap.ExtendaPlan_SKOption1 = 11;
- plsMap.ExtendaPlan_SKOption2 = 12;
- plsMap.ExtendaPlan_SKPlus = 13;
- plsMap.PrescriptionDrugEnhanced = 14;
- plsMap.ChoiceDental = 15;
- plsMap.ChoiceDrug = 16;
- plsMap.ChoiceHealth = 17;
- plsMap.ChoiceTravel = 18;
- plsMap.EssentialDental = 19;
- plsMap.EssentialHealth = 20;
- plsMap.PremierDental = 21;
- plsMap.PremierDrug = 22;
- plsMap.PremierHealth = 23;
- plsMap.PremierTravel = 24;
- nodMap.ME = 1;
- nodMap.ME_AND_SPOUSE = 2;
- nodMap.ME_AND_SPOUSE_AND_KIDS = 3;
- nodMap.ME_AND_KID = 2;
- nodMap.ME_AND_KIDS = 3;
- primaryPayload.lep = false;
- primaryPayload.bId = 0;
- primaryPayload.pr = execution.getVariable('province');
- primaryPayload.nod = execution.getVariable('number_people_covered');
- if(execution.hasVariable('spouse_age')) {
- primaryPayload.aooa = java.lang.Math.max(execution.getVariable('spouse_age'), execution.getVariable('applicant_age'));
- } else {
- primaryPayload.aooa = execution.getVariable('applicant_age');
- }
- def arrPLS = [];
- arrPLS.add(plsMap.get(execution.getVariable('primary_recommendation_code')));
- if(execution.hasVariable('options')){
- execution.options.each{ value ->
- arrPLS.add(plsMap.get(value));
- }
- }
- if(execution.getVariable('primary_recommendation_code').indexOf('ExtendaPlan') > -1 && execution.getVariable('primary_recommendation_code') == 'ExtendaPlan'){
- arrPLS.add(plsMap.get('ExtendaPlan'));
- }
- primaryPayload.pls = arrPLS;
- payload.primary_url = 'https://my.gms.ca/buyflow/health/quote?settings=' + JsonOutput.toJson(primaryPayload).toString().bytes.encodeBase64().toString();
- payload.applicationDate = java.time.Instant.now().toString();
- payload.effectiveDate = java.time.Instant.now().toString();
- payload.province = execution.getVariable('province');
- payload.applicants = [];
- long age = execution.getVariable('applicant_age');
- def applicant = [:];
- applicant.id = 1;
- applicant.birthdate = java.time.Instant.now().minusSeconds(age*31556952).toString();
- payload.applicants.push(applicant);
- if (execution.hasVariable('spouse_age')) {
- age = execution.getVariable('spouse_age');
- def spouse = [:];
- spouse.id = 2;
- spouse.birthdate = java.time.Instant.now().minusSeconds(age*31556952).toString();
- payload.applicants.push(spouse);
- }
- if (execution.getVariable('number_people_covered').contains('ME_AND_SPOUSE_AND_KIDS') || execution.getVariable('number_people_covered').contains('ME_AND_KIDS')) {
- def kid = [:];
- kid.id = payload.applicants.size()+1;
- kid.birthdate = java.time.Instant.now().minusSeconds(5*31556952).toString();
- payload.applicants.push(kid);
- }
- def product = [:];
- product.plan = execution.getVariable('primary_recommendation_code');
- product.dentalCoverage = execution.getVariable('coverage_type').contains('DENTAL');
- product.hospitalCash=execution.getVariable('coverage_type').contains('HOSPITAL_CASH');;
- //product.drugCoverage='PrescriptionDrugBasic';
- payload.product = product;
- def request= JsonOutput.toJson(payload).toString();
- System.out.println('request: ' + request);
- request;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement