Advertisement
clinenko

Untitled

May 27th, 2015
4,047
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
J 2.77 KB | None | 0 0
  1. /*
  2.     Class designed to make API calls into PMS to get Admin Tools, connectivity information
  3.     https://na8.salesforce.com/a1kC00000006D1R
  4.     Story: ST-034280
  5.     Christian Linenko 5-26-2015
  6. */
  7.  
  8. public with sharing class PMS
  9. {
  10.     private static String serviceNS = 'com:expedia:lis:PricingMigration:messages:VendorSystemSearch:v1';
  11.     private static String cNS = 'com:expedia:lis:Service:messages:BaseTypes:v2';
  12.    
  13.     public PMS()
  14.     {
  15.     }
  16.     public static string getPMSInformation(String hotelId)
  17.     {
  18.       /*
  19.         <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  20.         <ns2:VendorSystemSearchRQ
  21.                                   xmlns="com:expedia:lis:Service:messages:BaseTypes:v2"
  22.                                   xmlns:ns2="com:expedia:lis:PricingMigration:messages:VendorSystemSearch:v1">
  23.          <BaseRequestIdentity>
  24.           <ClientId>1</ClientId>
  25.           <TransactionId>bf942ecb-186e-43fe-a2c5-7f9bef5d070a</TransactionId>
  26.          </BaseRequestIdentity>
  27.          <ns2:SearchCondition>
  28.            <ns2:SearchCondition>1</ns2:VendorSystemID>
  29.            <ns2:VendorSystemName>TestVendor</ns2:VendorSystemName>
  30.            <ns2:VendorSystemLogin>SYS_EXPTest</ns2:VendorSystemLogin>
  31.            <ns2:InterfaceTypeMask>7</ns2:InterfaceTypeMask>
  32.            <ns2:EQCBool>1</ns2:EQCBool>
  33.          </ns2:SearchCondition>
  34.         </ns2:VendorSystemSearchRQ>
  35.       */
  36.  
  37.       Dom.Document doc = new Dom.Document();
  38.  
  39.       dom.XmlNode envelope = doc.createRootElement('VendorSystemSearchRQ', 'ns2', 'ns2');
  40.       envelope.setNamespace('', serviceNS);
  41.       envelope.setNamespace('ns2', cns);
  42.  
  43.       // add request identity
  44.       dom.XmlNode body = envelope.addChildElement('BaseRequestIdentity', null, null);
  45.       body.addChildElement('ClientId', null, null).addTextNode('1');
  46.       body.addChildElement('TransactionId', null, null).addTextNode('bf942ecb-186e-43fe-a2c5-7f9bef5d070a');
  47.       // add search stuff
  48.       body = envelope.addChildElement('ns2:SearchCondition', null, null);
  49.       body.addChildElement('ns2:VendorSystemID', null, null).addTextNode(hotelId);
  50.  
  51.       HttpRequest req = new HttpRequest();
  52.       req.setMethod('POST');
  53.       req.setEndpoint('https://pricingmigrationservice.everestadmintools.com/LISService.svc/VendorSystemSearch');
  54.       req.setHeader('Content-Type', 'text/xml');
  55.       System.debug('XML Bod: ' + doc.toXmlString());
  56.       req.setBody(doc.toXmlString());
  57.  
  58.         Http http = new Http();
  59.         String retString = null;
  60.       try   {
  61.          HttpResponse res = http.send(req);
  62.          if (res != NULL && res.getStatusCode() == 200) {
  63.             retString = res.getbody();
  64.          }
  65.       } catch (System.Exception e) {
  66.          Logger.debug('PMS CALLOUT FAILED: ' + e.getMessage());
  67.       }
  68.       return retString;
  69.     }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement