Monday, July 13, 2020

#784 Using Pagination with the OIC Shopify adapter



Introduction

Starting point is the OIC Shopify adapter doc here
Quotes from the doc in italics.

In this simple example I will paginate thru my product list -
I have ca. 600 products. The number of products returned per page by Shopify can range from 50 to 250. I will set this value in the Shopify invoke mapping.

The OIC integration will use the Shopify Adapter to retrieve all products.
The structure returned will have the following format.






















the page_info value is a link to the next page of results.
So the processing logic is very simple - process all pages!

This I will do in a WHILE loop - condition is - while there are still more pages available.


Implementing Shopify Pagination in OIC


I will use a scheduled orchestration - first step in that orchestration is to
Assign the following variables -















v_link will hold the page_info value.
v_check is simply an indicator set initially to false.
I will set this to true, when all pages have been processed.


















Now I add the WHILE loop - condition will be v_check != "true"











































Now I will query Products -

I configure the Shopify connection as follows -












































Map as follows -















Target limit - number of Products per page limit - can be up to 250.
I set mine to 50.

Target link - The page_info element is a unique ID required to 
search and access the next page in the results.

Now I add a SWITCH (If) after the RetrieveAllProducts invoke.
Here I check if there are more pages -
















Then I add an ASSIGN in this IF path to update my variables -
















I also add an ASSIGN to the OTHERWISE path -
Here I set v_check = true

The integration looks as follows -

























I activate and test - I have ca. 600 products - ergo the 12 iterations 







Wednesday, July 8, 2020

#783 OIC integrating BigCommerce with Netsuite


Big Commerce is a very popular SaaS eCommerce platform, used by many Netsuite customers.
Ergo, integration between the two is necessary and easy with Oracle Integration (OIC).

Welcome to my Hare of the Dog shop on Big Commerce -



I add a couple of top quality products - Hare of the Dog T-Shirts - handmade by medieval philosophy students. The material is 100% recycled and recyclable, and is also edible.






















Ok, now that we have something, let's check out the BigCommerce REST apis.







































I set the OAuth scopes - Products are not shown in the screenshot below, but suffice to say, I select modify for them.

























I save my selection and the following is displayed -


















Now it's time for Postman - let's get the Products -








































There's my T-Shirt - in all it's pristine glory.

OIC Integration Syncing Products between BigCommerce and Netsuite

Step 1 - Create a REST Connection to Big Commerce

Here I create a REST connection specifying the base url -
https://api.bigcommerce.com/stores/myStoreId/v3

I specify API-Key based Security.





















I copy my Big Commerce Access Token to the API Key field and
then configure API Key Usage as follows -

-H X-Auth-Token:${api-key}

So that's my token taken care of.
The X-Auth-Client will be passed as a custom header, as you will shortly see.

So here is the basic integration -































A scheduled integration that invokes the Big commerce REST connection to retrieve Products.
Here is the configuration of GetProducts -


























I have used the response from my Postman test as the sample json payload above.

All I need to map is the custom header -



















The rest of the integration is the usual modus operandi -
For each Product -
check if its pendant InventoryItem exists in Netsuite.
This I do via a GET on InventoryItem -




















I check the InventoryItem externalId - key is the BigCommerce Product sku -












and log the result in either case.

Test Result 





















Ok, so the basic sanity test worked -

Main use case between Big Commerce and Netsuite is probably order processing.

Again my starting point is Postman -
















Now that is disappointing - I google and read that /orders is not yet supported in the v3 REST api.
So I try with v2 -



























and there is my T-Shirt order.
Note the response is in xml.

OIC Processing Big Commerce Orders 

I need to define a new REST connection for v2 -
















I add the v2 connection - configuring as follows -



























Naturally, I could also amend the original REST connection -

Now for a test ... I just included the GetOrders after GetProducts processing -


























Imagine such an integration runs daily, then I will only want to pick up the orders created/modified since the last run. I can use the following fields for this -













Another useful field for filtering will be the status field.

Yet another -











The order processing logic could be as follows -

1. Retrieve new/modified orders from Big Commerce 
2. Check status

2.1. If "Awaiting Fulfillment" - customer has paid, but has not yet received the goods
2.1.1. Check if B2B or B2C (if company set, then it is a B2B order)
2.1.1.1. IF B2B - create Sales order in Netsuite
2.1.1.2. If B2C - create Cash Sale in Netsuite

2.2. If "Fulfilled" - customer has received goods (shipped by Big Commerce)
2.2.1. Create ItemFulfillment in Netsuite
We may also need to cater for a "PartiallyFulfilled" order as well.



Friday, July 3, 2020

#782 Sugar CRM 2 Netsuite Integration with OIC REST Adapter




I just got access to a trial account of SugarCRM, so no time like the present to try out
an integration use case with Netsuite - syncing SugarCRM Accounts with Netsuite Customers.

I begin by looking at the SugarCRM REST api - this I will be using, courtesy of the OIC REST adapter.

SugarCRM REST API


The REST api base endpoint is  mySugarCRMInstance/rest/v10

You should see the following, when you add a /help to that url.


























Now what about Authentication?
The screenshot below is one I took from the SugarCRM docs here








Ok I try this out in Postman -



















Now I can use this access token in further requests to SugarCRM -

Here I create an Account -










































Looks good - and just to prove it - here it is in SugarCRM -













Retrieving an Account is easy - just use the id as key

















I can also add a filter to the GET - here I am retrieving Accounts modified after a particular dateTime.


























Ok, let's implement this use case in OIC.

Integrating SugarCRM and Netsuite using OIC

I will use the OIC REST adapter to integrate with SugarCRM via its REST API.
The OIC REST adapter makes it very easy to do so, allowing one to configure
the 2 legged OAuth at connection level. This means my integration can concentrate on the
business logic - retrieving modified SugarCRM accounts and syncing them with Netsuite.


Step 1 - Create the REST connection for SugarCRM -

Base URL =  mySugarCRMInstance/rest/v10
This is what we have already used in Postman.

Security Settings -


























Now let's go thru these settings one by one -
A great reference here is this excellent blog post from Anuj.

Let's look at setting the Access Token Request field -
What we need here is the curl request minus the curl, so to speak 

Starting point again is Postman -













Here is the curl -















I massage this and end up with -






The other settings are mainly default -

























Notice the access_token_usage value - this is the Header I use in Postman -





















I Test and Save the Connection -









Step 2 - Create a Scheduled Integration

Here is the finished product -



So what's happening here?
This integration runs according to a schedule, e.g. at 5pm every working day.

First action is to GetModifiedAccounts from SugarCRM, leveraging the REST connection I just created. I query for all accounts modified after a particular date - just as I did in the Postman example.

Then I check if the count of modified accounts is greater than 0.
If so, I iterate over the accounts returned - for each account I check whether it already exists in Netsuite. If it doesn't, I create a Netsuite customer for that SugarCRM Account.

A very simple use case - the logic is over-simplified and no error handling has been implemented,
but it will suffice to illustrate how easy it is to do such with OIC.


Step 2.1. Configure a schedule parameter - dateModified













This we will use to query SugarCRM.

Step 2.2. Invoke SugarCRM to get the modified Accounts

Here I leverage the SugarCRM REST Connection, configured as follows -

















Request and Response payloads are set to those from my Postman example.
Going back to my test in Postman - the response payload from SugarCRM included
empty arrays e.g.
















OIC won't accept this so either remove the element or add some values.

Now to the Mapping -













Step 2.3. I log the number of Accounts returns - default pagination is set to 20.


















Step 2.4. I add a SWITCH to branch on count

If count is greater than 0 - I use a FOR EACH action to iterate over each modified account.
Here I just output the Account name




















































Final Step - Leverage the Netsuite connection to Create Customer

For in-depth how to implement the GET / Create Netsuite Customer use case,
please refer to the my Netsuite related blog posts here

Here is an extract from the integration, with the Netsuite connectivity  -














I check whether the customer exists in Netsuite - using the Netsuite connection - Search - capability























If customer is not found, I use the Netsuite connection to create the customer -




















Now to testing the completed integration -
















I check in Netsuite for the SugarCRM account,  Mississippi Bank Group -