Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.38 KB | None | 0 0
  1. import groovy.json.JsonOutput
  2.  
  3. def payload = [:];
  4. def plsMap = [:];
  5. def nodMap = [:];
  6. def primaryPayload = [:];
  7.  
  8. plsMap.BasicPlan = 1;
  9. plsMap.ExtendaPlan = 2;
  10. plsMap.OmniPlan = 3;
  11. plsMap.PrescriptionDrugBasic = 4;
  12. plsMap.DentalCare = 5;
  13. plsMap.HospitalCash = 6;
  14. plsMap.Travel15DaysPerTrip = 7;
  15. plsMap.Travel30DaysPerTrip = 9;
  16. plsMap.Travel48daysPerTrip = 10;
  17. plsMap.ExtendaPlan_SKOption1 = 11;
  18. plsMap.ExtendaPlan_SKOption2 = 12;
  19. plsMap.ExtendaPlan_SKPlus = 13;
  20. plsMap.PrescriptionDrugEnhanced = 14;
  21. plsMap.ChoiceDental = 15;
  22. plsMap.ChoiceDrug = 16;
  23. plsMap.ChoiceHealth = 17;
  24. plsMap.ChoiceTravel = 18;
  25. plsMap.EssentialDental = 19;
  26. plsMap.EssentialHealth = 20;
  27. plsMap.PremierDental = 21;
  28. plsMap.PremierDrug = 22;
  29. plsMap.PremierHealth = 23;
  30. plsMap.PremierTravel = 24;
  31.  
  32. nodMap.ME = 1;
  33. nodMap.ME_AND_SPOUSE = 2;
  34. nodMap.ME_AND_SPOUSE_AND_KIDS = 3;
  35. nodMap.ME_AND_KID = 2;
  36. nodMap.ME_AND_KIDS = 3;
  37.  
  38. primaryPayload.lep = false;
  39. primaryPayload.bId = 0;
  40. primaryPayload.pr = execution.getVariable('province');
  41. primaryPayload.nod = execution.getVariable('number_people_covered');
  42.  
  43. if(execution.hasVariable('spouse_age')) {
  44. primaryPayload.aooa = java.lang.Math.max(execution.getVariable('spouse_age'), execution.getVariable('applicant_age'));
  45. } else {
  46. primaryPayload.aooa = execution.getVariable('applicant_age');
  47. }
  48.  
  49. def arrPLS = [];
  50. arrPLS.add(plsMap.get(execution.getVariable('primary_recommendation_code')));
  51.  
  52. if(execution.hasVariable('options')){
  53. execution.options.each{ value ->
  54. arrPLS.add(plsMap.get(value));
  55. }
  56. }
  57.  
  58. if(execution.getVariable('primary_recommendation_code').indexOf('ExtendaPlan') > -1 && execution.getVariable('primary_recommendation_code') == 'ExtendaPlan'){
  59. arrPLS.add(plsMap.get('ExtendaPlan'));
  60. }
  61.  
  62. primaryPayload.pls = arrPLS;
  63.  
  64. payload.primary_url = 'https://my.gms.ca/buyflow/health/quote?settings=' + JsonOutput.toJson(primaryPayload).toString().bytes.encodeBase64().toString();
  65.  
  66. payload.applicationDate = java.time.Instant.now().toString();
  67. payload.effectiveDate = java.time.Instant.now().toString();
  68. payload.province = execution.getVariable('province');
  69.  
  70. payload.applicants = [];
  71.  
  72. long age = execution.getVariable('applicant_age');
  73. def applicant = [:];
  74. applicant.id = 1;
  75. applicant.birthdate = java.time.Instant.now().minusSeconds(age*31556952).toString();
  76. payload.applicants.push(applicant);
  77.  
  78. if (execution.hasVariable('spouse_age')) {
  79. age = execution.getVariable('spouse_age');
  80. def spouse = [:];
  81. spouse.id = 2;
  82. spouse.birthdate = java.time.Instant.now().minusSeconds(age*31556952).toString();
  83. payload.applicants.push(spouse);
  84. }
  85.  
  86. if (execution.getVariable('number_people_covered').contains('ME_AND_SPOUSE_AND_KIDS') || execution.getVariable('number_people_covered').contains('ME_AND_KIDS')) {
  87. def kid = [:];
  88. kid.id = payload.applicants.size()+1;
  89. kid.birthdate = java.time.Instant.now().minusSeconds(5*31556952).toString();
  90. payload.applicants.push(kid);
  91. }
  92.  
  93. def product = [:];
  94. product.plan = execution.getVariable('primary_recommendation_code');
  95. product.dentalCoverage = execution.getVariable('coverage_type').contains('DENTAL');
  96. product.hospitalCash=execution.getVariable('coverage_type').contains('HOSPITAL_CASH');;
  97. //product.drugCoverage='PrescriptionDrugBasic';
  98. payload.product = product;
  99.  
  100. def request= JsonOutput.toJson(payload).toString();
  101.  
  102. System.out.println('request: ' + request);
  103.  
  104. request;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement