Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Class designed to make API calls into PMS to get Admin Tools, connectivity information
- https://na8.salesforce.com/a1kC00000006D1R
- Story: ST-034280
- Christian Linenko 5-26-2015
- */
- public with sharing class PMS
- {
- private static String serviceNS = 'com:expedia:lis:PricingMigration:messages:VendorSystemSearch:v1';
- private static String cNS = 'com:expedia:lis:Service:messages:BaseTypes:v2';
- public PMS()
- {
- }
- public static string getPMSInformation(String hotelId)
- {
- /*
- <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
- <ns2:VendorSystemSearchRQ
- xmlns="com:expedia:lis:Service:messages:BaseTypes:v2"
- xmlns:ns2="com:expedia:lis:PricingMigration:messages:VendorSystemSearch:v1">
- <BaseRequestIdentity>
- <ClientId>1</ClientId>
- <TransactionId>bf942ecb-186e-43fe-a2c5-7f9bef5d070a</TransactionId>
- </BaseRequestIdentity>
- <ns2:SearchCondition>
- <ns2:SearchCondition>1</ns2:VendorSystemID>
- <ns2:VendorSystemName>TestVendor</ns2:VendorSystemName>
- <ns2:VendorSystemLogin>SYS_EXPTest</ns2:VendorSystemLogin>
- <ns2:InterfaceTypeMask>7</ns2:InterfaceTypeMask>
- <ns2:EQCBool>1</ns2:EQCBool>
- </ns2:SearchCondition>
- </ns2:VendorSystemSearchRQ>
- */
- Dom.Document doc = new Dom.Document();
- dom.XmlNode envelope = doc.createRootElement('VendorSystemSearchRQ', 'ns2', 'ns2');
- envelope.setNamespace('', serviceNS);
- envelope.setNamespace('ns2', cns);
- // add request identity
- dom.XmlNode body = envelope.addChildElement('BaseRequestIdentity', null, null);
- body.addChildElement('ClientId', null, null).addTextNode('1');
- body.addChildElement('TransactionId', null, null).addTextNode('bf942ecb-186e-43fe-a2c5-7f9bef5d070a');
- // add search stuff
- body = envelope.addChildElement('ns2:SearchCondition', null, null);
- body.addChildElement('ns2:VendorSystemID', null, null).addTextNode(hotelId);
- HttpRequest req = new HttpRequest();
- req.setMethod('POST');
- req.setEndpoint('https://pricingmigrationservice.everestadmintools.com/LISService.svc/VendorSystemSearch');
- req.setHeader('Content-Type', 'text/xml');
- System.debug('XML Bod: ' + doc.toXmlString());
- req.setBody(doc.toXmlString());
- Http http = new Http();
- String retString = null;
- try {
- HttpResponse res = http.send(req);
- if (res != NULL && res.getStatusCode() == 200) {
- retString = res.getbody();
- }
- } catch (System.Exception e) {
- Logger.debug('PMS CALLOUT FAILED: ' + e.getMessage());
- }
- return retString;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement