Wednesday, September 14, 2016

#523 REST & ICS Orchestration Pattern and how to find the best pubs in Dublin

A simple example...

Here I create an Organization in Service Cloud -

input -

{
"OrgName":"TheHareOfTheDog"
}

output -

{

"Created":"true",
"NewOrg":[
  {"OrgID":"orgID"
  }
  ]
}

I create a REST connection in ICS -



















I now create a new Integration - selecting Orchestration













I drag and drop my NC-REST connection as the Trigger -










I configure as follows -




 I add my sample JSON response via the inline link.




 The result -



I add the Invoke for Service Cloud -









The result is -

























I do the mapping for the CreateOrgServiceCloud.











































I then map the response -






































I add a Tracking field -













I activate the Integration - and then check out the metadata link -

...oraclecloud.com/integration/flowapi/rest/NC_REST_CREATEORG/v01/metadata

















I test, using the url -
... .oraclecloud.com/integration/flowapi/rest/NC_REST_CREATEORG/v01/CreateOrg?OrgName=TheHareOfTheDog Financial Services

The Response -









Phase 2 - Looking for Pubs



Now, let's make this more interesting, let's have an Orchestration that searches for Pubs in Dublin.

I will leverage Google Place API for this.


Here is a sample Google Place request -

https://maps.googleapis.com/maps/api/place/textsearch/json?query=pubs+in+Kells%20Co.%20Meath&key=myGoogleKey

This will deliver me a list of pubs in the town of Kells in Co. Meath.
































The first pub returned is Jack's Railway Bar, an iconoclastic drink hole.

Now my app will restrict results to only those old enough to drink.

The request will be -
city and age.


The response is as follows -

{
"Result":"Great Pubs found",
  "Pubs" : [
    {
      "Name" : "The Hare of The Dog Pub",
      "Address" : "Harmonstown Rise Dublin 5"
    },
    {
      "ID" : "The Horse and Hound",
      "Name" : "Harmonstown Road Dublin 5"
    }
  ]
}

So I begin by getting a key from Google






































I note the API Key for future use - and use it in a simple test -


















Now I am looking for pubs in Dublin,
First Pub found is O'Donoghues Bar, a very fine hostelry.

I save this as a file for future use.

Now its on to ICS -


I create the REST Connection in ICS - and configure accordingly.
Note: no security is required. I will be hard coding the key in my ICS Integration.

























This I now create -






I drag and drop my generic NC-REST connection as the Trigger.

















































I add a Switch to check the user's age -































































I drag and drop my Google Place REST adapter  - and configure it.















































I add the saved response json via the inline option




















Note: I filled in any empty [arrays] beforehand.

















I do the required mapping -















I enter my Google key, note no quotes!


I set the response -


























I also set the response for the Otherwise path -
























I set the Tracking and Save.

Then I activate and test -


















Now I look for pubs in Dublin -

My request is of the format -
https://my ICS Instance/integration/flowapi/rest/NC_FIND_HOSTELRYS/v01/findPubs?yourAge=32&place=pubs+in+Dublin

The result is a list of the finest hostelries in the fair city of Dublin!


No comments:

Post a Comment