Integration Samples
The LeaseAccelerator API combines the simplicity of REST requests with the robust data exchange capabilities of XML Remote Procedure Calls (RPC). Each request is stateless and multiple method requests can be submitted concurrently from the same secure session.
Sample Client
The following is a working Java client that, given credentials and a properly configured IdP, connects to the LeaseAccelerator API using the SAML2 Enhanced Client or Proxy (ECP) profile and submits a FindDeals request to our beta testing environment. This program leverages several open source components – most notably Apache HttpComponents (https://hc.apache.org/), OpenSAML-J (https://wiki.shibboleth.net/confluence/display/OpenSAML/Home/), and Shibbolethized HTTPClient (see http://mvnrepository.com/artifact/de.tudarmstadt.ukp.shibhttpclient/shib-http-client/1.0.0 for the Maven entry and links to the source repository).
package com.leaseacc.auth.admin;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpResponse;
import org.apache.http.HttpEntity;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.entity.mime.content.StringBody;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.opensaml.DefaultBootstrap;
import org.opensaml.xml.ConfigurationException;
import de.tudarmstadt.ukp.shibhttpclient.ShibHttpClient;
public class ShibECPTestClient
{
private static String idpBaseUrl="https://didp.leaseaccelerator.com";
private static String spUrl="https://b.leaseaccelerator.com";
private static String userName="yourUserName";
private static String password="yourPassword";
private static String apiUrl = "https://b.leaseaccelerator.com/lease_accelerator/api/LeaseAccelerator/FindDeals";
private static String token = "";
private static String xmlRequestFile = "FindDeals.xml";
private static InputStream in;
public static void main(String[] args)
{
System.setProperty("org.apache.commons.logging.Log","org.apache.commons.logging.impl.SimpleLog");
System.setProperty("org.apache.commons.logging.simplelog.showdatetime","true");
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http","DEBUG");
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http.wire","DEBUG");
try
{
DefaultBootstrap.bootstrap();
}
catch (ConfigurationException e)
{
e.printStackTrace();
}
HttpClient client= new ShibHttpClient(idpBaseUrl + "/idp/profile/SAML2/SOAP/ECP", userName, password);
HttpGet req = new HttpGet(spUrl + "/auth/api");
try
{
HttpResponse res = client.execute(req);
InputStream ins= res.getEntity().getContent();
BufferedReader br= new BufferedReader(new InputStreamReader(ins));
while ((token=br.readLine()) != null)
{
System.out.println("Read Line Data :" + token);
CloseableHttpClient apiClient = HttpClients.createDefault();
HttpPost httppost = new HttpPost(apiUrl);
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.addPart("token", new StringBody(token, ContentType.DEFAULT_TEXT));
File requestFile = new File(xmlRequestFile);
builder.addPart("file", new FileBody(requestFile.getAbsoluteFile()));
HttpEntity entity = builder.build();
httppost.setEntity(entity);
try
{
CloseableHttpResponse responseFromPost = apiClient.execute(httppost);
System.out.println(responseFromPost.toString());
in = responseFromPost.getEntity().getContent();
String body = IOUtils.toString(in);
System.out.println(body);
}
catch (ClientProtocolException e)
{
System.out.println(e);
}
catch (IOException e)
{
System.out.println(e);
}
}
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
The FindDeals.xml file referenced in the above client contains the following request:
<APIRequest>
<Request>
<RequestId>12345</RequestId>
<WarningPolicy>Ignore</WarningPolicy>
<ErrorPolicy>Ignore</ErrorPolicy>
</Request>
<Payload>
<Criteria>
<ArtifactNumber>*test*</ArtifactNumber>
</Criteria>
</Payload>
</APIRequest>
Sample Long Life Token Example:
petualTokenClient;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import javax.net.ssl.SSLContext;
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpEntity;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.config.Registry;
import org.apache.http.config.RegistryBuilder;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.entity.mime.content.StringBody;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.BasicHttpClientConnectionManager;
import org.apache.http.ssl.SSLContexts;
public class perpetualTokenClient
{
private static InputStream in;
public static void main(String[] args)
{
//Simple Debug On off for detail info appearing 0 or 1.
Integer debug = 1;
if (debug == 1)
{
System.setProperty("org.apache.commons.logging.Log","org.apache.commons.logging.impl.SimpleLog");
System.setProperty("org.apache.commons.logging.simplelog.showdatetime","true");
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http","DEBUG");
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http.wire","DEBUG");
}
String token = "ENTER_TOKEN_HERE";
String operation = "ENTER_OPERATION_HERE_SUCH_AS_ImportExchangeRates";
String xmlRequestFile = "C:/path/file_xml_here.xml";
//Choose Proper URL for testing
String apiUrl = "https://beta.leaseaccelerator.com/lease_accelerator/api/LeaseAccelerator/";
try
{
if (token != null)
{
if (debug == 1)
{
System.out.println("Token Data :" + token);
}
BasicHttpClientConnectionManager clientConnectionManager = new BasicHttpClientConnectionManager(getRegistry());
CloseableHttpClient apiClient = HttpClients.custom().setConnectionManager(clientConnectionManager).build();
HttpPost httppost = new HttpPost(apiUrl + operation);
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.addPart("token", new StringBody(token, ContentType.DEFAULT_TEXT));
builder.addPart("requestId", new StringBody("12345", ContentType.DEFAULT_TEXT));
File requestFile = new File(xmlRequestFile);
builder.addPart("file", new FileBody(requestFile.getAbsoluteFile()));
HttpEntity entity = builder.build();
httppost.setEntity(entity);
try
{
CloseableHttpResponse responseFromPost = apiClient.execute(httppost);
if (debug == 1)
{
System.out.println(responseFromPost.toString());
}
in = responseFromPost.getEntity().getContent();
String body = IOUtils.toString(in, "UTF-8");
System.out.println(body);
}
catch (ClientProtocolException e)
{
System.out.println(e);
}
catch (IOException e)
{
System.out.println(e);
}
}
}
catch (Exception nsae)
{
System.out.println("NoSuchAlgorithmException in InvokeAPIFromFile: " + nsae.getLocalizedMessage());
}
finally
{
//end
}
}
private static Registry<ConnectionSocketFactory> getRegistry() throws KeyManagementException, NoSuchAlgorithmException {
SSLContext sslContext = SSLContexts.custom().build();
SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory(sslContext,
new String[]{"TLSv1.2"}, null, SSLConnectionSocketFactory.getDefaultHostnameVerifier());
return RegistryBuilder.<ConnectionSocketFactory>create()
.register("http", PlainConnectionSocketFactory.getSocketFactory())
.register("https", sslConnectionSocketFactory)
.build();
}
}
Sample - Capture Posted Document XML
Operation: CaptureDocumentId
<APIRequest>
<Request>
<RequestId>333335</RequestId>
</Request>
<Payload>
<ExternalDocuments>
<ExternalDocument>
<LedgerEntrySubId>2.1.61489591.61489591</LedgerEntrySubId>
<ExternalDocumentId>POSTED</ExternalDocumentId>
</ExternalDocument>
<ExternalDocument>
<LedgerEntrySubId>2.1.61489591.61489592</LedgerEntrySubId>
<ExternalDocumentId>POSTED</ExternalDocumentId>
</ExternalDocument>
</ExternalDocuments>
</Payload>
</APIRequest>
Sample – FX Rates XML
Operation: FindContacts
<APIRequest>
<Request>
<RequestId>326542</RequestId>
</Request>
<Payload>
<Rate>
<ToCurrency>EUR</ToCurrency>
<FromCurrency>USD</FromCurrency>
<EffectiveDate>02/01/2024</EffectiveDate>
<Rate>1.25</Rate>
<RateType>Spot</RateType>
<Source>WSJ</Source>
</Rate>
<Rate>
<ToCurrency>PLN</ToCurrency>
<FromCurrency>USD</FromCurrency>
<EffectiveDate>02/01/2024</EffectiveDate>
<Rate>2.25</Rate>
<RateType>Spot</RateType>
<Source>WSJ</Source>
</Rate>
<Rate>
<ToCurrency>CAD</ToCurrency>
<FromCurrency>USD</FromCurrency>
<EffectiveDate>02/01/2024</EffectiveDate>
<Rate>0.99</Rate>
<RateType>Spot</RateType>
<Source>WSJ</Source>
</Rate>
</Payload>
</APIRequest>
<APIResponse>
<Response>
<Status>0</Status>
<Context>Ok</Context>
<RequestId>326542</RequestId>
</Response>
<Payload>
<Results></Results>
</Payload>
</APIResponse>
Sample - Find Contacts XML
Operation: FindContacts
<APIRequest>
<Request>
<RequestId>333335</RequestId>
</Request>
<Payload>
<Contact>
<Scope>Person</Scope>
<Company>ACME MARKETS INC</Company>
</Contact>
</Payload>
</APIRequest>
<APIResponse>
<Response>
<Status>0</Status>
<Context>Ok</Context>
<RequestId>12345</RequestId>
</Response>
<Payload>
<Contacts>
<Contact>
<CompanyId>5</CompanyId>
<Company>ACME MARKETS INC</Company>
<Email>syewale@leaseaccelerator.com</Email>
<AddressId/>
<Address1/>
<Address2/>
<Phone/>
<City/>
<Country/>
<PostalCode/>
<StateProvince/>
<PartyId>14269</PartyId>
<FullName>Op1</FullName>
<ContactType/>
<Url/>
<Title/>
</Contact>
<Contact>
<CompanyId>5</CompanyId>
<Company>ACME MARKETS INC</Company>
<Email>syewale@leaseaccelerator.com</Email>
<AddressId/>
<Address1/>
<Address2/>
<Phone/>
<City/>
<Country/>
<PostalCode/>
<StateProvince/>
<PartyId>14255</PartyId>
<FullName>Tester2</FullName>
<ContactType/>
<Url/>
<Title/>
</Contact>
<Contact>
<CompanyId>5</CompanyId>
<Company>ACME MARKETS INC</Company>
<Email>syewale@leaseaccelerator.com</Email>
<AddressId/>
<Address1/>
<Address2/>
<Phone/>
<City/>
<Country/>
<PostalCode/>
<StateProvince/>
<PartyId>14256</PartyId>
<FullName>Tester3</FullName>
<ContactType/>
<Url/>
<Title/>
</Contact>
</Contacts>
</Payload>
</APIResponse>
Sample – Get Events for Deal
Operation: GetEventsForDeal
<APIRequest>
<Request>
<RequestId>20190312</RequestId>
</Request>
<Payload>
<EventCriteria>
<DealId>25325</DealId>
</EventCriteria>
</Payload>
</APIRequest>
<APIResponse>
<Response>
<Status>0</Status>
<Context>Ok</Context>
<RequestId>20190312</RequestId>
</Response>
<Payload>
<Events>
<Event>
<Id>49257</Id>
<EventType>GenClassification</EventType>
<DealId>25325</DealId>
<UserName>jburney</UserName>
<Comments/>
<IsSuperseded>N</IsSuperseded>
<Timestamp/>
</Event>
<Event>
<Id>49252</Id>
<EventType>NewClassification</EventType>
<DealId>25325</DealId>
<UserName>jburney</UserName>
<Comments/>
<IsSuperseded>N</IsSuperseded>
<Timestamp/>
</Event>
<Event>
<Id>49251</Id>
<EventType>SummaryChanged</EventType>
<DealId>25325</DealId>
<UserName>jburney</UserName>
<Comments>Changed financing terms</Comments>
<IsSuperseded>N</IsSuperseded>
<Timestamp/>
</Event>
<Event>
<Id>49250</Id>
<EventType>Annotate</EventType>
<DealId/>
<UserName>jburney</UserName>
<Comments>Changed deal status from NULL to Active</Comments>
<IsSuperseded>N</IsSuperseded>
<Timestamp/>
</Event>
<Event>
<Id>49249</Id>
<EventType>BookCA</EventType>
<DealId/>
<UserName>jburney</UserName>
<Comments/>
<IsSuperseded>N</IsSuperseded>
<Timestamp/>
</Event>
</Events>
</Payload>
</APIResponse>
Sample – Find Deals
Operation: FindDeals
<APIRequest>
<Request>
<RequestId>20190312</RequestId>
</Request>
<Payload>
<Criteria>
<ArtifactNumber></ArtifactNumber>
<ArtifactType></ArtifactType>
<ArtifactState></ArtifactState>
<FromDate></FromDate>
<ToDate></ToDate>
<ContactType></ContactType>
<Company>Acme*</Company>
<City></City>
<StateProvince></StateProvince>
<Country></Country>
<Status>Active</Status>
<MaxRows>100</MaxRows>
</Criteria>
<TargetArtifact>Deal</TargetArtifact>
</Payload>
</APIResponse>