Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. public with sharing class Cenas implements CalloutActionInterface {
  2. private String theBody;
  3. private String theEndpoint;
  4. private Map<String,String> theHeaders;
  5. private String theCertificate;
  6. public String theAplicationId;
  7. public Cenas(Tenas.Menas sessionDetails) {
  8. Integration IntegrationS = Utils.getIntegrationSsMap().get('Start_Session_Mobile');
  9. theEndpoint = IntegrationS.Endpoint__c;
  10. theAplicationId=Utils.getApplicationId();
  11. CenasRequest requestBody = (CenasRequest) JSON.deserialize(IntegrationS.Body__c, CenasRequest.class);
  12. requestBody.Id = theAplicationId;
  13. requestBody.RemoteIPAddress = sessionDetails.RemoteIPAdress;
  14. requestBody.OSName = sessionDetails.OSName;
  15. requestBody.OSVersion = sessionDetails.OSVersion;
  16. theBody = JSON.serialize(requestBody);
  17. theCertificate = IntegrationS.Certificate_Name__c;
  18. theHeaders = Web.getGeneralHeaders('');
  19. }
  20. public Object doAction(){
  21. WebW.RequestParams Request = new WebW.RequestParams()
  22. .setEndpoint (theEndpoint)
  23. .addHeaders(theHeaders)
  24. .setBodyRequest(theBody)
  25. .setCertificateName(theCertificate)
  26. .setMethod(WebW.METHOD.POST);
  27. Web.StartSession deserializedResponse = (Web.StartSession) JSON.deserialize(WebW.doTheCallFor(ocktoRequest), Web.StartSession.class);
  28. System.debug(LoggingLevel.FINEST, deserializedResponse);
  29. if (deserializedResponse.HasError == 'True' || deserializedResponse.Result == '') throw new Web.WebException('Start session token not received');
  30. return deserializedResponse.Result==null?'Dummy':deserializedResponse.Result;
  31. }
  32.  
  33. private class CenasRequest {
  34. public String Id;
  35. public String Provider;
  36. public String Type;
  37. public String CdmVersion;
  38. public String Mobile2Mobile;
  39. public String RemoteIPAddress;
  40. public String OSName;
  41. public String OSVersion;
  42. public String ConsentCode;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement