This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

Product Marketing in Shopify

The first use case in the Shopify business scenario is used for product marketing. This page describes the relevant tasks and the operations you use in the Shopify connector and the other ESB connectors.

Overview

The flow for product marketing is illustrated in the following diagram. The ESB connectors for Facebook and MailChimp will be used to connect to each service. 

  1. Retrieve products from the Shopify API using the getProductById operation. 
  2. Create a campaign in MailChimp using the createDraftCampaign operation, and send the campaign using the sendCampaign operation.
  3. Post campaign details on the company's Facebook page using the publishPagePost operation in the Facebook API.
Shopify operations
MailChimp operations
Facebook operations
Samples
Sample Template for Creating a Draft Campaign in MailChimp, Sending the Created Campaigns Immediately, and then Creating a Page Post in Facebook According to the Given API Key and Access Token of MailChimp and Facebook with Other Parameters
<?xml version="1.0" encoding="UTF-8"?>
<!-- 
	This template responsible for creating a draft campaign in mailchimp and send created campaign immediately. 
	Then creating a page post in facebook according to given api key and access token of mailchimp & facebook with other parameters.
 -->
<template xmlns="http://ws.apache.org/ns/synapse" name="shopify-publishProductDetailsOnSocialMedia">
	<!-- Mailchimp related template parameters -->
	<parameter name="mcApiUrl" description="Base endpoint URL of MailChimp API." />
	<parameter name="mcApiKey" description="API Authentication Key to access the MailChimp API." />
	<parameter name="mcFormat" description="Format of the Response expected from the API. It can be either JSON or XML." />
	<parameter name="mcType" description="The Campaign Type to create - one of 'regular', 'plaintext', 'absplit', 'ss', 'auto'." />
	<parameter name="mcOptions" description="A struct of the standard options for this campaign." />
	<parameter name="mcContent" description="The content for this campaign." />
	<parameter name="mcSegmentOptions" description="Do segmentation within the Campaign." />
	<parameter name="mcTypeOptions" description="Various extra options based on the campaign type." />
	<!-- Facebook related template parameters -->
	<parameter name="fbApiUrl" description="API url of Facebook." />
	<parameter name="fbAccessToken" description="Access token which provides temporary, secure access to Facebook APIs." />
	<parameter name="fbPageId" description="Unique identifier of the page." />
	<parameter name="fbMessage" description="The main body of the post." />
	<parameter name="fbLink" description="The URL of a link to attach to the post." />
	<parameter name="fbPicture" description="Determines the preview image associated with the link." />
	<parameter name="fbName" description="Overwrites the title of the link preview." />
	<parameter name="fbCaption" description="Overwrites the caption under the title in the link preview." />
	<parameter name="fbDescription" description="Overwrites the description in the link preview." />
	<parameter name="fbActions" description="The action links attached to the post." />
	<parameter name="fbPlace" description="Page ID of a location associated with this post." />
	<parameter name="fbTags" description="List of user IDs of people tagged in this post." />
	<parameter name="fbObjectAttachment" description="Facebook ID for an existing picture." />
	<parameter name="fbTargeting" description="Object that limits the audience for this content." />
	<parameter name="fbFeedTargeting" description="Object that controls news feed targeting for this content." />
	<parameter name="fbPublished" description="Whether a story is shown about this newly published object." />
	<parameter name="fbScheduledPublishTime" description="Time when this post should go live." />
	<parameter name="fbBackdatedTime" description="Specifies a time in the past to back-date this post to." />
	<parameter name="fbBackdatedTimeGranularity" description="Controls the display of how a backdated post appears." />
    <sequence>
		<!-- Mailchimp related template properties -->
		<property name="uri.var.mcApiUrl" expression="$func:mcApiUrl"/>
		<property name="uri.var.mcApiKey" expression="$func:mcApiKey"/>
		<property name="uri.var.mcFormat" expression="$func:mcFormat"/>
		<property name="uri.var.mcType" expression="$func:mcType"/>
		<property name="uri.var.mcOptions" expression="$func:mcOptions"/>
		<property name="uri.var.mcContent" expression="$func:mcContent"/>
		<property name="uri.var.mcSegmentOptions" expression="$func:mcSegmentOptions"/>
		<property name="uri.var.mcTypeOptions" expression="$func:mcTypeOptions"/>
		
		<!-- Facebook related template properties -->
		<property name="uri.var.fbApiUrl" expression="$func:fbApiUrl" />
		<property name="uri.var.fbAccessToken" expression="$func:fbAccessToken" />
		<property name="uri.var.fbPageId" expression="$func:fbPageId" />
		<property name="uri.var.fbMessage" expression="$func:fbMessage" />
		<property name="uri.var.fbLink" expression="$func:fbLink" />
		<property name="uri.var.fbPicture" expression="$func:fbPicture" />
		<property name="uri.var.fbName" expression="$func:fbName" />
		<property name="uri.var.fbCaption" expression="$func:fbCaption" />
		<property name="uri.var.fbDescription" expression="$func:fbDescription" />
		<property name="uri.var.fbActions" expression="$func:fbActions" />
		<property name="uri.var.fbPlace" expression="$func:fbPlace" />
		<property name="uri.var.fbTags" expression="$func:fbTags" />
		<property name="uri.var.fbObjectAttachment" expression="$func:fbObjectAttachment" />
		<property name="uri.var.fbTargeting" expression="$func:fbTargeting" />
		<property name="uri.var.fbFeedTargeting" expression="$func:fbFeedTargeting" />
		<property name="uri.var.fbPublished" expression="$func:fbPublished" />
		<property name="uri.var.fbScheduledPublishTime" expression="$func:fbScheduledPublishTime" />
		<property name="uri.var.fbBackdatedTime" expression="$func:fbBackdatedTime" />
		<property name="uri.var.fbBackdatedTimeGranularity" expression="$func:fbBackdatedTimeGranularity" />
		<property name="messageType" value="application/json" scope="axis2"/>
		<!-- START: Checking mailchimp api key is provided to proceed with mailchimp create draft campaign call -->
		<filter source="boolean(get-property('uri.var.mcApiKey'))" regex="true">
            <then>
				<!-- Calling the mailchimp createDraftCampaign method to create a draft campaign -->
				<mailchimp.init>
	                <apiUrl>{$ctx:uri.var.mcApiUrl}</apiUrl>
	                <apiKey>{$ctx:uri.var.mcApiKey}</apiKey>
	                <format>{$ctx:uri.var.mcFormat}</format>
	            </mailchimp.init>
	            <mailchimp.createDraftCampaign>
	                <type>{$ctx:uri.var.mcType}</type>
	                <options>{$ctx:uri.var.mcOptions}</options>
	                <content>{$ctx:uri.var.mcContent}</content>
	                <segmentOptions>{$ctx:uri.var.mcSegmentOptions}</segmentOptions>
	                <typeOptions>{$ctx:uri.var.mcTypeOptions}</typeOptions>
	            </mailchimp.createDraftCampaign>
				<!-- Getting the created campaign id -->
				<property name="uri.var.campaignId" expression="json-eval($.id)" />
				<property name="idParam" expression="fn:concat('{&quot;campaign_id&quot;:&quot;',get-property('uri.var.campaignId'),'&quot;}')" />
				
				<!-- Getting the created campaign archived URL -->
				<property name="uri.var.archivedUrl" expression="json-eval($.archive_url_long)" />
							
				<!-- START: Checking draft campaign creation was successful by returning created campaign id, then proceed with send draft campaign -->
				<filter source="boolean(get-property('uri.var.campaignId'))" regex="true">
					<then>
					
						<!-- Calling the mailchimp sendCampaign method to send a created draft campaign -->
						<mailchimp.init>
			                <apiUrl>{$ctx:uri.var.mcApiUrl}</apiUrl>
			                <apiKey>{$ctx:uri.var.mcApiKey}</apiKey>
			                <format>{$ctx:uri.var.mcFormat}</format>
			            </mailchimp.init>
			            <mailchimp.sendCampaign>
			                <campaignId>{$ctx:uri.var.campaignId}</campaignId>
			            </mailchimp.sendCampaign>
			            <!-- Getting the response status of send campaign of mailchimp -->
						<property name="completeStatus" expression="json-eval($.complete)" />
						<!-- START: Checking draft campaign send was successful then give successful message, otherwise returned error message -->
						<filter source="boolean(get-property('completeStatus'))" regex="true">
							<then>
							
								<property name="status" value="Success" />
								<property name="message" value="Draft campaign successfully created and sent." />
								
								<!-- Calling the response handler template to give successful message of campaign creation and send campaign immediately -->
								<call-template target="responseHandlerTemplate">
									<with-param name="activity" value="mailchimp_createAndSendCampaign" />
									<with-param name="id" value="{$ctx:idParam}" />
									<with-param name="status" value="{$ctx:status}" />
									<with-param name="message" value="{$ctx:message}" />
								</call-template>
								
							</then>
							<else>
							
								<property name="messageType" value="application/json" scope="axis2"/>
								<property name="message" expression="json-eval($.)" />
								<!-- Response generator for create and send campaign error response -->
								<call-template target="responseHandlerTemplate">
									<with-param name="activity" value="mailchimp_createAndSendCampaign" />
									<with-param name="status" value="Error" />
									<with-param name="message" value="{$ctx:message}" />
								</call-template>
								<loopback/>
								
							</else>
						</filter>
						<!-- END: Checking created draft campaign send was successful -->
						
					</then>
					<else>				
						<property name="messageType" value="application/json" scope="axis2"/>
						<property name="message" expression="json-eval($.)" />
						<!-- Response generator for create and send campaign error response -->
						<call-template target="responseHandlerTemplate">
							<with-param name="activity" value="mailchimp_createAndSendCampaign" />
							<with-param name="status" value="Error" />
							<with-param name="message" value="{$ctx:message}" />
						</call-template>
						<loopback/>
					</else>
				</filter>
				<!-- END: Checking draft campaign creation was successful by returning created campaign id -->
            </then>
		</filter>
		<!-- END: Checking mailchimp api key is provided -->
		<!-- START: Checking facebook access token is available proceed with facebook page post creation call -->
		<filter source="boolean(get-property('uri.var.fbAccessToken'))" regex="true">
            <then>
            	<!-- Property to construct the facebook message body for publish page post -->
            	<property name="uri.var.fbMessage" expression="fn:concat('If interested enter \&quot;',get-property('uri.var.campaignId'), '\&quot; as your comment. We will get back to you soon. For more details click below.')" />
            	<!-- Property to construct the facebook message link for publish page post -->
				<property name="uri.var.fbLink" expression="get-property('uri.var.archivedUrl')" />
				<!-- Calling the facebook publishPagePost method to create a page post -->
				<facebook.init>
		            <apiUrl>{$ctx:uri.var.fbApiUrl}</apiUrl>
		            <accessToken>{$ctx:uri.var.fbAccessToken}</accessToken>
		        </facebook.init>
		        <facebook.publishPagePost>
		            <pageId>{$ctx:uri.var.fbPageId}</pageId>
		            <message>{$ctx:uri.var.fbMessage}</message>
		            <link>{$ctx:uri.var.fbLink}</link>
		            <picture>{$ctx:uri.var.fbPicture}</picture>
		            <name>{$ctx:uri.var.fbName}</name>
		            <caption>{$ctx:uri.var.fbCaption}</caption>
		            <description>{$ctx:uri.var.fbDescription}</description>
		            <actions>{$ctx:uri.var.fbActions}</actions>
		            <place>{$ctx:uri.var.fbPlace}</place>
		            <tags>{$ctx:uri.var.fbTags}</tags>
		            <objectAttachment>{$ctx:uri.var.fbObjectAttachment}</objectAttachment>
		            <targeting>{$ctx:uri.var.fbTargeting}</targeting>
		            <feedTargeting>{$ctx:uri.var.fbFeedTargeting}</feedTargeting>
		            <published>{$ctx:uri.var.fbPublished}</published>
		            <scheduledPublishTime>{$ctx:uri.var.fbScheduledPublishTime}</scheduledPublishTime>
		            <backdatedTime>{$ctx:uri.var.fbBackdatedTime}</backdatedTime>
		            <backdatedTimeGranularity>{$ctx:uri.var.fbBackdatedTimeGranularity}</backdatedTimeGranularity>
		        </facebook.publishPagePost>
				<!-- Getting the created page post id -->
				<property name="fbPostId" expression="json-eval($.id)" />
				
				<property name="idParam" expression="fn:concat('{&quot;post_id&quot;:&quot;',get-property('fbPostId'),'&quot;}')" />
				
				<!-- START: Checking availability of created post id construct the custom messages -->
				<filter source="boolean(get-property('fbPostId'))" regex="true">
					<then>
					
						<property name="status" value="Success" />
						<property name="message" value="Facebook page post was successfully created." />
						
					</then>
					<else>
						
						<property name="messageType" value="application/json" scope="axis2"/>
						<property name="idParam" value="null" />
						<property name="status" value="Error" />
						<property name="message" expression="json-eval($.)" />
						
					</else>
				</filter>
				<!-- END: Checking availability of created post id -->
				
            </then>
		</filter>
		<!-- END: Checking facebook access token is available -->
    </sequence>
</template>
Sample Proxy for Retrieving Product Details from the Shopify API
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="shopify_productMarketing"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
    <target>
      <inSequence onError="faultHandlerSeq">
	  
			<!-- Shopify related properties -->
			<property name="shopifyApiUrl" expression="json-eval($.shopifyApiUrl)" />
			<property name="shopifyAccessToken" expression="json-eval($.shopifyAccessToken)" />
			<property name="format" value="json"/>
			<property name="shopifyProductIDArray" expression="json-eval($.shopifyProductIDArray[*])" />
			<property name="shopifyFields" value="title,body_html,vendor,variants,image" />
			<!-- Mailchimp related properties -->
			<property name="mcApiUrl" expression="json-eval($.mcApiUrl)"/>
			<property name="mcApiKey" expression="json-eval($.mcApiKey)"/>
            <property name="mcType" value="regular"/>
            <property name="mcListId" expression="json-eval($.mcListId)"/>
            <property name="mcSubject" expression="json-eval($.mcSubject)"/>
            <property name="mcFromEmail" expression="json-eval($.mcFromEmail)"/>
            <property name="mcFromName" expression="json-eval($.mcFromName)"/>
            <property name="mcToName" expression="json-eval($.mcToName)"/>
            <property name="mcTemplateId" expression="json-eval($.mcTemplateId)"/>
            <property name="mcRefferMore" expression="json-eval($.mcRefferMore)"/>
            <property name="mcSegmentOptions" expression="json-eval($.mcSegmentOptions)"/>
            <property name="mcTypeOptions" expression="json-eval($.mcTypeOptions)"/>
            <!-- Facebook related properties -->
			<property name="fbApiUrl" expression="json-eval($.fbApiUrl)" />
			<property name="fbAccessToken" expression="json-eval($.fbAccessToken)" />
			<property name="fbPageId" expression="json-eval($.fbPageId)" />
			<property name="fbPicture" expression="json-eval($.fbPicture)" />
			<property name="fbName" expression="json-eval($.fbName)" />
			<property name="fbCaption" expression="json-eval($.fbCaption)" />
			<property name="fbDescription" expression="json-eval($.fbDescription)" />
			<property name="fbActions" expression="json-eval($.fbActions)" />
			<property name="fbPlace" expression="json-eval($.fbPlace)" />
			<property name="fbTags" expression="json-eval($.fbTags)" />
			<property name="fbObjectAttachment" expression="json-eval($.fbObjectAttachment)" />
			<property name="fbTargeting" expression="json-eval($.fbTargeting)" />
			<property name="fbFeedTargeting" expression="json-eval($.fbFeedTargeting)" />
			<property name="fbPublished" expression="json-eval($.fbPublished)" />
			<property name="fbScheduledPublishTime" expression="json-eval($.fbScheduledPublishTime)" />
			<property name="fbBackdatedTime" expression="json-eval($.fbBackdatedTime)" />
			<property name="fbBackdatedTimeGranularity" expression="json-eval($.fbBackdatedTimeGranularity)" />
			<!-- General properties -->
			<property name="productIndex" value="0" scope="operation"/>
			<property name="responseString" value="" scope="operation"/>
			<property name="mcTemplateBody" value="" scope="operation"/>
			<property name="idParam" value="" />
			<!-- START: Checking whether user has provided both shopify access token and mailchimp api key -->
			<filter source="(boolean(get-property('shopifyAccessToken')) and boolean(get-property('mcApiKey')))" regex="false">
				<then>
				
					<property name="message" value="Please provide both shopify access token and mailchimp api key." />
					
					<!-- Calling the response handler template to give custom error message when user not provided both shopify access token and mailchimp api key -->
					<call-template target="responseHandlerTemplate">
						<with-param name="activity" value="shopify_accessTokenAvailabilityCheck" />
						<with-param name="status" value="Error" />
						<with-param name="message" value="{$ctx:message}" />
					</call-template>
					
					<loopback/>
					
				</then>
				<else>
					
					<!-- START: Checking whether user has provided a created mailchimp template ID -->
					<filter source="boolean(get-property('mcTemplateId'))" regex="false">
						<then>
						
							<property name="message" value="Please provide a created template ID." />
							
							<!-- Calling the response handler template to give custom error message when user not provided a template ID from request -->
							<call-template target="responseHandlerTemplate">
								<with-param name="activity" value="mailchimp_createAndSendCampaign" />
								<with-param name="status" value="Error" />
								<with-param name="message" value="{$ctx:message}" />
							</call-template>
							
							<loopback/>
							
						</then>
						<else>
						
							<!-- Script mediator to check user has provided a valid product ID array provided with at least one product ID from request -->
							<script language="js">
								<![CDATA[
									try {
									
										var shopifyProductIDArray = eval("("+ mc.getProperty("shopifyProductIDArray") +")");
										
										if(shopifyProductIDArray.length > 0){		
											mc.setProperty("isProductArray", true);
										} else{
											mc.setProperty("isProductArray", false);
										}
								
									} catch (err) {
										mc.setProperty("isProductArray", false);
									}
								]]>
							</script>
						
							<!-- START: Checking user has provided a valid product ID array provided with at least one product ID from request -->
							<filter source="get-property('isProductArray')" regex="false">
								<then>
								
									<property name="message" value="Please provide valid non empty product ID array." />
							
									<!-- Calling the response handler template to give custom error message when valid non empty product ID array not provided from request -->
									<call-template target="responseHandlerTemplate">
										<with-param name="activity" value="shopify_getProductById" />
										<with-param name="status" value="Error" />
										<with-param name="message" value="{$ctx:message}" />
									</call-template>
									
									<loopback/>
									
								</then>
								<else>
								
									<property name="productCount" expression="count(//shopifyProductIDArray)" scope="operation"/>
									<property name="idParam" expression="fn:concat('{ProductIDs:',get-property('shopifyProductIDArray'),'}')" />
									
									<!-- START: Iterate product ID array and get product details for each and every product by passing product ID -->
									<iterate continueParent="true" id="productsIdIterator" preservePayload="true" expression="//shopifyProductIDArray" sequential="true">
							            <target>
							               <sequence>
										   
							                 	<property name="productId" expression="//shopifyProductIDArray/text()" />
							                 	<property name="messageType" value="application/json" scope="axis2"/>
							                 	<!-- Shopify getProductById method call -->
							                 	<shopify.init>
									            	<apiUrl>{$ctx:shopifyApiUrl}</apiUrl>
									            	<accessToken>{$ctx:shopifyAccessToken}</accessToken>
													<format>{$ctx:format}</format>
									        	</shopify.init>
												<shopify.getProductById>
													<productId>{$ctx:productId}</productId>
													<fields>{$ctx:shopifyFields}</fields>
												</shopify.getProductById>
												<property name="shopifyGetProductByIdStatusCode" expression="$axis2:HTTP_SC" />
												<!-- START: Checking the http status code for getProductById method to proceed -->
												<filter xpath="get-property('shopifyGetProductByIdStatusCode') != 200">
													<then>
													
														<!-- Error in unsuccessful getProductById -->
														<property name="message" expression="//errors" />
														<property name="message" expression="fn:concat('Error: ', get-property('message'))" />
														<!-- Response generator for getProductById error response -->
														<call-template target="responseHandlerTemplate">
															<with-param name="activity" value="shopify_getProductById" />
															<with-param name="status" value="Error" />
															<with-param name="message" value="{$ctx:message}" />
														</call-template>
														
														<loopback />
														
													</then>
												</filter>
												<!-- END: Checking of http status code -->
												<!-- Remove shopify response header information -->
												<header name="Content-Type" action="remove" scope="transport" />
												<header name="Content-Encoding" action="remove" scope="transport" />
												<!-- Getting required product details into individual properties to create a campaign in mailchimp -->
												<property  name="productTitle" expression="json-eval($.product.title)"/>
												<property  name="productDescription" expression="json-eval($.product.body_html)"/>
												<property  name="productVendor" expression="json-eval($.product.vendor)"/>
												<property  name="productImage" expression="json-eval($.product.image.src)"/>
												<property  name="productVariants" expression="json-eval($.product.variants)"/>
												<!-- This creates a draft campaign html template for each and every products and its variants with all the product and variants details -->
												<script language="js">
													<![CDATA[     
													
														var templateBody = "";
														var productImage = mc.getProperty('productImage');
														var productTitle = mc.getProperty('productTitle');
														var productDescription = mc.getProperty('productDescription');
														var productVendor = mc.getProperty('productVendor');
														var variantsObjArray = eval("(" + mc.getProperty('productVariants') + ")");
														templateBody += "<tr><td id='details'><img src='" + productImage + "' alt='No Preview'/></td><td id='details'><div><h2>" + productTitle + "</h2></div><div>" + productDescription + "</div></br><div>Vendor: " + productVendor + "</div>";
														// Check whether variants are available in each product.
														if(variantsObjArray != null){
															templateBody += "<div><h3>Variations</h3></div><div><table id='products' border='1' cellpadding='10'>";
															// Iterate variants object array and get variant details of each and every product to construct draft campaign in mailchimp.
															for(var index = 0; index < variantsObjArray.length; index++){
																templateBody += "<tr><td>" + variantsObjArray[index].title + "</td><td>Rs. " + variantsObjArray[index].price + "</td></tr>";
															}
															templateBody += "</table></div>";
														}
														templateBody += "</td></tr>";
														mc.setProperty('templateBody',templateBody);
															
													]]>
												</script>
												<property  name="mcTemplateBody" expression="fn:concat(get-property('operation','mcTemplateBody'), get-property('templateBody'))" scope="operation"/>
				                    			<!-- Increment the product index -->
							                    <property name="productIndex" expression="get-property('operation','productIndex') + 1" scope="operation"/>
							               </sequence>
							            </target>
						         	</iterate>
									<!-- END: Iterator of product ID array -->
									
									<!-- START: Restrict execution of other API calls until last product ID to iterator performs getting product details -->
						         	<filter xpath="get-property('operation','productCount') = get-property('operation','productIndex')">
							            <then>
							            	<!-- Payload factory to construct options object before create a draft campaign and send it immediately -->
											<payloadFactory media-type="json">
												<format>
													{
														"options": {
															"list_id": "$1",
		        											"subject": "$2",
		        											"from_email": "$3",
		        											"from_name": "$4",
		        											"to_name": "$5",
		        											"template_id":$6
														}
													}       
												</format>
												<args>
													<arg expression="get-property('mcListId')" />
													<arg expression="get-property('mcSubject')" />  
													<arg expression="get-property('mcFromEmail')" />  
													<arg expression="get-property('mcFromName')" />  
													<arg expression="get-property('mcToName')" />  
													<arg expression="get-property('mcTemplateId')" />     
												</args>
											</payloadFactory>
							            	
							            	<!-- Property to provide contents object before create a draft campaign and send it immediately -->
											<property name="mcContent" expression="fn:concat('{&quot;sections&quot;:{&quot;product_info&quot;:&quot;', get-property('operation','mcTemplateBody'), '&quot;,&quot;ref_more&quot;:&quot;&lt;a href=\&quot;', get-property('mcRefferMore'), '\&quot; target=\&quot;_blank\&quot;&gt;Read More...&lt;/a&gt;&quot;}}')"/>
											<property name="mcOptions" expression="json-eval($.options)"/>
											<!-- Call the shopify-publishProductDetailsOnSocialMedia template to create and send draft campaign with shopify products details -->
											<call-template target="shopify-publishProductDetailsOnSocialMedia">
												<!-- parameter values will be passed on to a sequence template -->
												(
												<with-param name="mcApiUrl" value="{$ctx:mcApiUrl}"/> |
												<with-param name="mcApiKey" value="{$ctx:mcApiKey}"/> |
												<with-param name="mcFormat" value="{$ctx:format}"/> |
												<with-param name="mcType" value="{$ctx:mcType}"/> |
												<with-param name="mcOptions" value="{$ctx:mcOptions}"/> |
												<with-param name="mcContent" value="{$ctx:mcContent}"/> |
												<with-param name="mcSegmentOptions" value="{$ctx:mcSegmentOptions}"/> |
												<with-param name="mcTypeOptions" value="{$ctx:mcTypeOptions}"/> |
												) *
											</call-template>
											<!-- If facebook access token is not by user provided give custom error message, otherwise proceed with facebook page post creation call -->
											<filter source="boolean(get-property('fbAccessToken'))" regex="false">
												<then>   
												
													<property name="idParam" value="null" />
													<property name="status" value="Skipped" />
													<property name="message" value="Please provide facebook authentication token." />
													
												</then>
												<else>
													
													<property name="mcApiKey" value="" />
													<!-- Call the shopify-publishProductDetailsOnSocialMedia template to create a page post for market the shopify products in company page -->
													<call-template target="shopify-publishProductDetailsOnSocialMedia">
														<!-- parameter values will be passed on to a sequence template -->
														(
														<with-param name="mcApiKey" value="{$ctx:mcApiKey}"/> |
														<with-param name="fbApiUrl" value="{$ctx:fbApiUrl}"/> |
														<with-param name="fbAccessToken" value="{$ctx:fbAccessToken}"/> |
														<with-param name="fbPageId" value="{$ctx:fbPageId}"/> |
														<with-param name="fbPicture" value="{$ctx:fbPicture}"/> |
														<with-param name="fbName" value="{$ctx:fbName}"/> |
														<with-param name="fbCaption" value="{$ctx:fbCaption}"/> |
														<with-param name="fbDescription" value="{$ctx:fbDescription}"/> |
														<with-param name="fbActions" value="{$ctx:fbActions}"/> |
														<with-param name="fbPlace" value="{$ctx:fbPlace}"/> |
														<with-param name="fbTags" value="{$ctx:fbTags}"/> |
														<with-param name="fbObjectAttachment" value="{$ctx:fbObjectAttachment}"/> |
														<with-param name="fbTargeting" value="{$ctx:fbTargeting}"/> |
														<with-param name="fbFeedTargeting" value="{$ctx:fbFeedTargeting}"/> |
														<with-param name="fbPublished" value="{$ctx:fbPublished}"/> |
														<with-param name="fbScheduledPublishTime" value="{$ctx:fbScheduledPublishTime}"/> |
														<with-param name="fbBackdatedTime" value="{$ctx:fbBackdatedTime}"/> |
														<with-param name="fbBackdatedTimeGranularity" value="{$ctx:fbBackdatedTimeGranularity}"/> |
														) *
													</call-template>
												</else>
											</filter>
											<!-- Calling the response handler template to give detailed message of posting product details in facebook page -->
											<call-template target="responseHandlerTemplate">
												<with-param name="activity" value="facebook_publishPagePost" />
												<with-param name="id" value="{$ctx:idParam}" />
												<with-param name="status" value="{$ctx:status}" />
												<with-param name="message" value="{$ctx:message}" />
											</call-template>
							               <loopback/>
							            </then>
						         	</filter>
									<!-- END: Filter to restrict execution of other API calls -->
								</else>
							</filter>
							<!-- END: Checking valid product IDs array availability -->
						</else>
					</filter>
					<!-- END: Checking template ID availability -->
				</else>
			</filter>
			<!-- END: Checking access token availability -->
			
	  </inSequence>
      <outSequence>
	  
            <property name="messageType" value="application/json" scope="axis2"/>
			
			<payloadFactory media-type="json">
				<format>
					{
						"Response":{
							"process":"shopify_productMarketing",
							"activityResponse":[$1]
						}
					}
				</format>
				<args>
					<arg evaluator="xml" expression="get-property('operation', 'responseString')"/>
				</args>
			</payloadFactory>
			
        <send/>
		
      </outSequence>
    </target>
    <description/>
</proxy>                      
Sample Request for Retrieving Product Details from Shopify API
{
	"shopifyApiUrl":"https://wso2test-2.myshopify.com",
	"shopifyAccessToken":"97c7c760cdb6a8ed800c7fdcb3337dce",
	"shopifyProductIDArray":[
								"400302843",
								"401215367",
								"399673771",
								"400303631",
								"416051679",
								"416054015"
						],
	"mcApiUrl":"https://us9.api.mailchimp.com",
	"mcApiKey":"e9f3f31d72f27c34b09cf787ae4d850e-us9",
	"mcListId":"444b97d8cf",
	"mcSubject":"Product Campaign Subject After Demo",
	"mcFromEmail":"wso2connector.abdera@gmail.com",
	"mcFromName":"Spartans",
	"mcToName":"Abdera",
	"mcTemplateId":169009,
	"mcRefferMore":"https://www.shopify.com/login",
	"fbApiUrl":"https://graph.facebook.com",
	"fbAccessToken":"CAACEdEose0cBALwXbyr9r3jr0W6R8dH81XkXkpvm6BR1ZAwKOpsEFA24XqXXIR1iwuJF8ZCLuXAF2CcaZAUZBZAoOGrgJa9wQgczs7uhXzIgZCMN3HxbZBJZAxm8qY8hxUZCptx0iZA2KnZBkdPXIdq2iijTeo3gq4lY5UnKvqHbzZAPvO3ZBPvzjQxcpxR0SUSlibxihdx3xaV4sDJQRkxfMLoRZC",
	"fbPageId":"1472299629677984"
}