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/.

Reservation Handling in Planyo

The second use case in the Planyo business scenario is reservation handling. This page describes the relevant tasks and the operations you use in the Planyo connector and the other ESB connectors. 

Overview

The flow for reservation handling is illustrated in the following diagram. The ESB connectors for Nexmo will be used to connect to each service. 

  1. Check the availability of the resource using the checkResourceAvailability operation in the Planyo API.
  2. If the resource is available, create the reservation in the Planyo API using the createReservation operation and send the reservation details to the client using the sendMessage operation in the Nexmo API. 
  3. Using the getReservationById operation retrieve the details of the reservation from the Planyo API. 
Planyo operations
Nexmo operations

Prerequisites

In order to send the SMS, it is required to add the mobile number provided in the planyoMobileNumber property to the list of 'Test Phone Numbers' in the Nexmo account. You can add the number using https://dashboard.nexmo.com/private/settings#test. The resources to be reserved should be added in your Planyo account as an offline process.

Observations

The delivered message gets trimmed in certain phones and Nexmo alters the message by adding certain special characters, etc.

Samples
Sample Template for checking availability of the resource using the Planyo API and if the resource is available, making the reservation in the Planyo API and sending the reservation details to the client using the Nexmo API
<?xml version="1.0" encoding="UTF-8"?>
<!--
   Copyright (c) 2005-2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
   WSO2 Inc. licenses this file to you under the Apache License,
   Version 2.0 (the "License"); you may not use this file except
   in compliance with the License.
   You may obtain a copy of the License at
   http://www.apache.org/licenses/LICENSE-2.0
   Unless required by applicable law or agreed to in writing,
   software distributed under the License is distributed on an
   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   KIND, either express or implied.  See the License for the
   specific language governing permissions and limitations
   under the License.
-->
<!-- This template checks availability of the resource using the Planyo API. If the resource is available, makes the reservation 
   in the Planyo API and sends the reservation details to client using the Nexmo API. -->
<template name="planyo-createReservationsAndSendMessages" xmlns="http://ws.apache.org/ns/synapse">
   <!-- Planyo parameters -->
   <parameter name="planyoAPIUrl" description="Planyo API Url." />
   <parameter name="planyoAPIKey" description="Planyo API key for authentication." />
   <parameter name="planyoAddress" description="The Address of the Planyo user" />
   <parameter name="planyoCity" description="The city of the Planyo user." />
   <parameter name="planyoZip" description="The zip code of the Planyo user." />
   <parameter name="planyoState" description="The state of the Planyo user." />
   <parameter name="planyoCountry" description="A two letter Country code of the Planyo user according to ISO 3166-1 alpha-2 format." />
   <parameter name="planyoResourceId" description="The unique identifier of the resource." />
   <parameter name="planyoStartTime" description="The beginning of rental duration." />
   <parameter name="planyoEndTime" description="The end of rental duration." />
   <parameter name="planyoFirstName" description="The First name of the Planyo user." />
   <parameter name="planyoLastName" description="The last name of the Planyo user." />
   <parameter name="planyoQuantity" description="The number of units to be reserved." />
   <parameter name="planyoEmail" description="The email address of the Planyo user." />
   <parameter name="planyoMobilePrefix" description="The Planyo User's Mobile number's Country code (e.g. 1 for USA and Canada)." />
   <parameter name="planyoMobileNumber" description="The Mobile Number of the Planyo user without the country code." />
   <parameter name="planyoPhonePrefix" description="The Planyo user's Phone's Country code (e.g. 1 for USA and Canada)." />
   <parameter name="planyoPhoneNumber" description="The Phone Number of the Planyo user without the country code." />
   <!-- Nexmo parameters -->
   <parameter name="nexmoAPIUrl" description="Nexmo API Url." />
   <parameter name="nexmoAPIKey" description="Nexmo API Key for authentication." />
   <parameter name="nexmoApiSecret" description="Nexmo API Secret for authentication." />
   <parameter name="nexmoSender" description="Address of the sender." />
   <parameter name="nexmoContactNumber" description="Mobile number of the reciepient in internationl format." />
   <sequence>
      <!-- Planyo properties -->
      <property name="uri.var.planyoAPIUrl" value="http://api.planyo.com" />
      <property name="uri.var.planyoAPIKey" expression="$func:planyoAPIKey" />
      <property name="uri.var.planyoAddress" expression="$func:planyoAddress" />
      <property name="uri.var.planyoCity" expression="$func:planyoCity" />
      <property name="uri.var.planyoZip" expression="$func:planyoZip" />
      <property name="uri.var.planyoState" expression="$func:planyoState" />
      <property name="uri.var.planyoCountry" expression="$func:planyoCountry" />
      <property name="uri.var.planyoResourceId" expression="$func:planyoResourceId" />
      <property name="uri.var.planyoStartTime" expression="$func:planyoStartTime" />
      <property name="uri.var.planyoEndTime" expression="$func:planyoEndTime" />
      <property name="uri.var.planyoFirstName" expression="$func:planyoFirstName" />
      <property name="uri.var.planyoLastName" expression="$func:planyoLastName" />
      <property name="uri.var.planyoQuantity" expression="$func:planyoQuantity" />
      <property name="uri.var.planyoEmail" expression="$func:planyoEmail" />
      <property name="uri.var.planyoMobilePrefix" expression="$func:planyoMobilePrefix" />
      <property name="uri.var.planyoMobileNumber" expression="$func:planyoMobileNumber" />
      <property name="uri.var.planyoPhonePrefix" expression="$func:planyoPhonePrefix" />
      <property name="uri.var.planyoPhoneNumber" expression="$func:planyoPhoneNumber" />
      <property name="uri.var.planyoIsAdminMode" value="true" />
      <!-- Nexmo Properties -->
      <property name="uri.var.nexmoAPIUrl" value="https://rest.nexmo.com" />
      <property name="uri.var.nexmoAPIKey" expression="$func:nexmoAPIKey" />
      <property name="uri.var.nexmoApiSecret" expression="$func:nexmoApiSecret" />
      <property name="uri.var.nexmoSender" expression="$func:nexmoSender" />
      <property name="uri.var.nexmoContactNumber" expression="$func:nexmoContactNumber" />
      <property name="uri.var.nexmoResponseType" value="json" />
      <!-- Checks whether the resource is available, if not returns an error response, otherwise proceed to make reservation -->
      <planyo.init>
         <apiUrl>{$ctx:uri.var.planyoAPIUrl}</apiUrl>
         <apiKey>{$ctx:uri.var.planyoAPIKey}</apiKey>
      </planyo.init>
      <planyo.checkResourceAvailability>
         <startTime>{$ctx:uri.var.planyoStartTime}</startTime>
         <resourceId>{$ctx:uri.var.planyoResourceId}</resourceId>
         <quantity>{$ctx:uri.var.planyoQuantity}</quantity>
         <endTime>{$ctx:uri.var.planyoEndTime}</endTime>
      </planyo.checkResourceAvailability>
      <!-- Checks whether the checkResourceAvailability method is executed successfully, if so checks resource availability 
         for the given time period. If resource is available continue to make reservation , otherwise returns an error response. -->
      <property name="uri.var.responseCode" expression="json-eval($.response_code)" />
      <filter xpath="get-property('uri.var.responseCode') = 0">
         <else>
            <property name="uri.var.message" expression="json-eval($.response_message)" />
            <property name="uri.var.id" expression="fn:concat('planyoResourceId:' ,get-property('uri.var.planyoResourceId'))" />
            <property name="uri.var.status" value="Error" />
            <property name="uri.var.activity" value="planyo_checkResourceAvailability" />
            <property name="uri.var.message"
               expression="fn:concat('Could not check the availability of the resource. ',get-property('uri.var.message'))" />
            <!-- Generate response for error in check resource availability -->
            <call-template target="responseHandlerTemplate">
               <with-param name="id" value="{$ctx:uri.var.id}" />
               <with-param name="status" value="{$ctx:uri.var.status}" />
               <with-param name="activity" value="{$ctx:uri.var.activity}" />
               <with-param name="message" value="{$ctx:uri.var.message}" />
            </call-template>
         </else>
         <then>
            <property name="uri.var.isAvailable" expression="json-eval($.data.is_available)" />
            <property name="uri.var.message" expression="json-eval($.response_message)" />
            <filter source="get-property('uri.var.isAvailable')" regex="true">
               <else>
                  <property name="uri.var.message" expression="json-eval($.response_message)" />
                  <property name="uri.var.id" expression="fn:concat('planyoResourceId:' ,get-property('uri.var.planyoResourceId'))" />
                  <property name="uri.var.status" value="Error" />
                  <property name="uri.var.activity" value="planyo_checkResourceAvailability" />
                  <property name="uri.var.message" value="Resource is not available for the given time period" />
                  <!-- Generate response for error in check resource availability -->
                  <call-template target="responseHandlerTemplate">
                     <with-param name="id" value="{$ctx:uri.var.id}" />
                     <with-param name="status" value="{$ctx:uri.var.status}" />
                     <with-param name="activity" value="{$ctx:uri.var.activity}" />
                     <with-param name="message" value="{$ctx:uri.var.message}" />
                  </call-template>
               </else>
               <then>
                  <!-- Create reservation -->
                  <planyo.init>
                     <apiUrl>{$ctx:uri.var.planyoAPIUrl}</apiUrl>
                     <apiKey>{$ctx:uri.var.planyoAPIKey}</apiKey>
                  </planyo.init>
                  <planyo.createReservation>
                     <resourceId>{$ctx:uri.var.planyoResourceId}</resourceId>
                     <startTime>{$ctx:uri.var.planyoStartTime}</startTime>
                     <endTime>{$ctx:uri.var.planyoEndTime}</endTime>
                     <quantity>{$ctx:uri.var.planyoQuantity}</quantity>
                     <email>{$ctx:uri.var.planyoEmail}</email>
                     <firstName>{$ctx:uri.var.planyoFirstName}</firstName>
                     <lastName>{$ctx:uri.var.planyoLastName}</lastName>
                     <address>{$ctx:uri.var.planyoAddress}</address>
                     <city>{$ctx:uri.var.planyoCity}</city>
                     <zip>{$ctx:uri.var.planyoZip}</zip>
                     <state>{$ctx:uri.var.planyoState}</state>
                     <country>{$ctx:uri.var.planyoCountry}</country>
                     <phonePrefix>{$ctx:uri.var.planyoPhonePrefix}</phonePrefix>
                     <phoneNumber>{$ctx:uri.var.planyoPhoneNumber}</phoneNumber>
                     <mobilePrefix>{$ctx:uri.var.planyoMobilePrefix}</mobilePrefix>
                     <mobileNumber>{$ctx:uri.var.planyoMobileNumber}</mobileNumber>
                     <isAdminMode>{$ctx:uri.var.planyoIsAdminMode}</isAdminMode>
                  </planyo.createReservation>
                  <!-- Checks whether the reservation has been made successfully, if not returns an error response, otherwise 
                     proceed to send message -->
                  <property name="uri.var.responseCode" expression="json-eval($.response_code)" />
                  <filter xpath="get-property('uri.var.responseCode') != 0">
                     <then>
                        <property name="uri.var.id"
                           expression="fn:concat('planyoResourceId:' ,get-property('uri.var.planyoResourceId'))" />
                        <property name="uri.var.status" value="Error" />
                        <property name="uri.var.activity" value="planyo_makeReservation" />
                        <property name="uri.var.message" expression="json-eval($.response_message)" />
                        <property name="uri.var.message"
                           expression="fn:concat('Could not make the reservation for user ',get-property('uri.var.planyoEmail'),'. ',get-property('uri.var.message'))" />
                        <!-- Generate response for error in make reservation -->
                        <call-template target="responseHandlerTemplate">
                           <with-param name="id" value="{$ctx:uri.var.id}" />
                           <with-param name="activity" value="{$ctx:uri.var.activity}" />
                           <with-param name="status" value="{$ctx:uri.var.status}" />
                           <with-param name="message" value="{$ctx:uri.var.message}" />
                        </call-template>
                     </then>
                     <else>
                        <property name="uri.var.reservationId" expression="json-eval($.data.reservation_id)" />
                        <property name="uri.var.id"
                           expression="fn:concat('planyoResourceId:', get-property('uri.var.planyoResourceId'), ',planyoReservationId:', get-property('uri.var.reservationId'))" />
                        <property name="uri.var.status" value="Success" />
                        <property name="uri.var.activity" value="planyo_makeReservation" />
                        <property name="uri.var.message"
                           expression="fn:concat('Successfully made the reservation for user, Email:',get-property('uri.var.planyoEmail'))" />
                        <!-- Generate response for make reservation -->
                        <call-template target="responseHandlerTemplate">
                           <with-param name="id" value="{$ctx:uri.var.id}" />
                           <with-param name="activity" value="planyo_makeReservation" />
                           <with-param name="status" value="Success" />
                           <with-param name="message" value="{$ctx:uri.var.message}" />
                        </call-template>
                        <!-- Continue to send message only if the Nexmo API Key has been provided. Allowing user to choose 
                           whether to send the message -->
                        <filter source="boolean(get-property('uri.var.nexmoAPIKey'))" regex="true">
                           <else>
                              <property name="uri.var.userName"
                                 expression="fn:concat(get-property('uri.var.planyoFirstName'),' ',get-property('uri.var.planyoLastName'))" />
                              <property name="uri.var.id"
                                 expression="fn:concat('planyoResourceId:', get-property('uri.var.planyoResourceId'), ',planyoReservationId:', get-property('uri.var.reservationId'))" />
                              <property name="uri.var.status" value="Skipped" />
                              <property name="uri.var.activity" value="nexmo_sendMessages" />
                              <property name="uri.var.message"
                                 expression="fn:concat('The Nexmo API Key is not provided. Hence the reservation details message not sent to the user ',get-property('uri.var.userName'))" />
                           </else>
                           <then>
                              <!-- Getting the user-text related to the reservation to build the message text to be sent -->
                              <planyo.init>
                                 <apiUrl>{$ctx:uri.var.planyoAPIUrl}</apiUrl>
                                 <apiKey>{$ctx:uri.var.planyoAPIKey}</apiKey>
                              </planyo.init>
                              <planyo.getReservationById>
                                 <reservationId>{$ctx:uri.var.reservationId}</reservationId>
                              </planyo.getReservationById>
                              <!-- Checks whether the get reservation data has been succeeded, if so continue to send message -->
                              <property name="
                           uri.var.responseCode " expression="json-eval($.response_code)" />
                              <filter xpath="get-property('uri.var.responseCode') = 0">
                                 <else>
                                    <property name="uri.var.id"
                                       expression="fn:concat('planyoResourceId:', get-property('uri.var.planyoResourceId'), ',planyoReservationId:', get-property('uri.var.reservationId'))" />
                                    <property name="uri.var.status" value="Success" />
                                    <property name="uri.var.activity" value="planyo_makeReservation" />
                                    <property name="uri.var.message"
                                       expression="fn:concat('Could not retrieve the reservation details for newly created reservation. This reservation has been entered and now needs to be accepted by the administrator. Please note if you are a new user Your reservation will be valid only after your email address has been verified. Check your mailbox and follow the directions in the email that was just sent to you. Check your spam folder if you do not receive the email within a few minutes')" />
                                 </else>
                                 <then>
                                    <property name="uri.var.userText" expression="json-eval($.data.user_text)" />
                                    <property name="uri.var.nexmoMessageText"
                                       expression="fn:concat('Hi',' ',get-property('uri.var.planyoFirstName'),', your Planyo reservation Id is',' ',get-property('uri.var.reservationId'),'.',get-property('uri.var.userText'),' Please note if you are a new user Your reservation will be valid only after your email address has been verified. Check your mailbox and follow the directions in the email that was just sent to you. Check your spam folder if you do not receive the email within a few minutes. Thanks.')" />
                                    <property name="uri.var.messageType" value="application/json" scope="axis2" />
                                    <!-- Sending message to the user -->
                                    <nexmo.init>
                                       <responseType>{$ctx:uri.var.nexmoResponseType}</responseType>
                                       <apiUrl>{$ctx:uri.var.nexmoAPIUrl}</apiUrl>
                                       <apiSecret>{$ctx:uri.var.nexmoApiSecret}</apiSecret>
                                       <apiKey>{$ctx:uri.var.nexmoAPIKey}</apiKey>
                                    </nexmo.init>
                                    <nexmo.sendMessage>
                                       <to>{$ctx:uri.var.nexmoContactNumber}</to>
                                       <text>{$ctx:uri.var.nexmoMessageText}</text>
                                       <from>{$ctx:uri.var.nexmoSender}</from>
                                    </nexmo.sendMessage>
                                    <!-- Checks whether the message has been successfully sent to the user, if not returns 
                                       an error response, otherwise returns a success response -->
                                    <property name="uri.var.messageStatus" expression="json-eval($.messages[0].status)" />
                                    <filter xpath="get-property('uri.var.messageStatus') = 0">
                                       <else>
                                          <property name="uri.var.errorText" expression="json-eval($.messages[0].error-text)" />
                                          <property name="uri.var.userName"
                                             expression="fn:concat(get-property('uri.var.planyoFirstName'),' ',get-property('uri.var.planyoLastName'))" />
                                          <property name="uri.var.id"
                                             expression="fn:concat('planyoResourceId:', get-property('uri.var.planyoResourceId'), ',planyoReservationId:', get-property('uri.var.reservationId'))" />
                                          <property name="uri.var.status" value="Error" />
                                          <property name="uri.var.activity" value="nexmo_sendMessages" />
                                          <property name="uri.var.message"
                                             expression="fn:concat('Error in sending message to user ',get-property('uri.var.userName'),',',get-property('uri.var.errorText'))" />
                                       </else>
                                       <then>
                                          <property name="uri.var.messageId" expression="json-eval($.messages.[0].message-id)" />
                                          <property name="uri.var.id"
                                             expression="fn:concat('planyoResourceId:', get-property('uri.var.planyoResourceId'), ',planyoReservationId:', get-property('uri.var.reservationId'), ',nexmoMessageId:', get-property('uri.var.messageId'))" />
                                          <property name="uri.var.status" value="Success" />
                                          <property name="uri.var.activity" value="nexmo_sendMessages" />
                                          <property name="uri.var.message"
                                             expression="fn:concat('Reservation details successfully sent to contact number',' ', get-property('uri.var.nexmoContactNumber'))" />
                                       </then>
                                    </filter>
                                    <!-- END: Nexmo send message response check -->
                                 </then>
                              </filter>
                              <!-- END: Planyo get reservation data response check -->
                           </then>
                        </filter>
                        <!-- END: Nexmo API Key availability check -->
                        <!-- Generate response for Nexmo message sending -->
                        <call-template target="responseHandlerTemplate">
                           <with-param name="id" value="{$ctx:uri.var.id}" />
                           <with-param name="status" value="{$ctx:uri.var.status}" />
                           <with-param name="activity" value="{$ctx:uri.var.activity}" />
                           <with-param name="message" value="{$ctx:uri.var.message}" />
                        </call-template>
                     </else>
                  </filter>
                  <!-- END: Planyo create reservation response check -->
               </then>
            </filter>
         </then>
      </filter>
      <!-- END: Planyo resource availability response check -->
   </sequence>
</template>
Sample Proxy for checking the availability for a given resource using the Planyo API and if the resource is available, making the reservation in Planyo API and sending the reservation details to the client via a Nexmo SMS
<?xml version="1.0" encoding="UTF-8"?>
<!--
   Copyright (c) 2005-2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
   WSO2 Inc. licenses this file to you under the Apache License,
   Version 2.0 (the "License"); you may not use this file except
   in compliance with the License.
   You may obtain a copy of the License at
   http://www.apache.org/licenses/LICENSE-2.0
   Unless required by applicable law or agreed to in writing,
   software distributed under the License is distributed on an
   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   KIND, either express or implied.  See the License for the
   specific language governing permissions and limitations
   under the License.
-->
<proxy xmlns="http://ws.apache.org/ns/synapse" name="planyo_createReservations" transports="https,http"
   statistics="disable" trace="disable" startOnLoad="true">
   <target>
      <inSequence onError="faultHandlerSeq">
         <!-- Planyo properties -->
         <property name="planyoAPIKey" expression="json-eval($.planyoAPIKey)" />
         <!-- Nexmo properties -->
         <property name="nexmoAPIKey" expression="json-eval($.nexmoAPIKey)" />
         <property name="nexmoApiSecret" expression="json-eval($.nexmoApiSecret)" />
         <property name="nexmoSender" expression="json-eval($.nexmoSender)" />
         <property name="messageType" value="application/xml" scope="axis2" />
         <!-- Common properties -->
         <property name="reseravtionIndex" value="0" scope="operation" />
         <property name="reservationDetails" expression="json-eval($.reservationDetails)" />
         <!-- Checks whether the reservationDetails is empty. If so, returns an error response, otherwise proceed to create 
            reservation -->
         <property name="reservationCount" expression="count(//reservationDetails[string-length(node()) > 0])"
            scope="operation" />
         <filter xpath="get-property('operation', 'reservationCount') = 0">
            <then>
               <property name="emptyID" value="{}" />
               <call-template target="responseHandlerTemplate">
                  <with-param name="id" value="{$ctx:emptyID}" />
                  <with-param name="status" value="Error" />
                  <with-param name="activity" value="planyo_makeReservationAndSendSMS" />
                  <with-param name="message"
                     value="Please provide valid values for reservationDetails parameter to make reservation" />
               </call-template>
               <loopback />
            </then>
         </filter>
         <!-- Iterates over reservationDetails to extract information and proceed with make reservation -->
         <iterate id="reservationIterator" expression="//reservationDetails[string-length(node()) > 0]"
            sequential="true">
            <target>
               <sequence>
                  <property name="planyoResourceId" expression="//reservationDetails/planyoResourceId" />
                  <property name="planyoStartTime" expression="//reservationDetails/planyoStartTime" />
                  <property name="planyoEndTime" expression="//reservationDetails/planyoEndTime" />
                  <property name="planyoFirstName" expression="//reservationDetails/planyoFirstName" />
                  <property name="planyoLastName" expression="//reservationDetails/planyoLastName" />
                  <property name="planyoAddress" expression="//reservationDetails/planyoAddress" />
                  <property name="planyoCity" expression="//reservationDetails/planyoCity" />
                  <property name="planyoZip" expression="//reservationDetails/planyoZip" />
                  <property name="planyoState" expression="//reservationDetails/planyoState" />
                  <property name="planyoCountry" expression="//reservationDetails/planyoCountry" />
                  <property name="planyoQuantity" expression="//reservationDetails/planyoQuantity" />
                  <property name="planyoEmail" expression="//reservationDetails/planyoEmail" />
                  <property name="planyoMobilePrefix" expression="//reservationDetails/planyoMobilePrefix" />
                  <property name="planyoMobileNumber" expression="//reservationDetails/planyoMobileNumber" />
                  <property name="planyoPhonePrefix" expression="//reservationDetails/planyoPhonePrefix" />
                  <property name="planyoPhoneNumber" expression="//reservationDetails/planyoPhoneNumber" />
                  <property name="nexmoContactNumber"
                     expression="fn:concat(get-property('planyoMobilePrefix'), get-property('planyoMobileNumber'))" />
                  <call-template target="planyo-createReservationsAndSendMessages">
                     <!-- parameter values will be passed on to a sequence template -->
                     (
                     <with-param name="planyoAPIKey" value="{$ctx:planyoAPIKey}" />
                     |
                     <with-param name="planyoAddress" value="{$ctx:planyoAddress}" />
                     |
                     <with-param name="planyoCity" value="{$ctx:planyoCity}" />
                     |
                     <with-param name="planyoZip" value="{$ctx:planyoZip}" />
                     |
                     <with-param name="planyoState" value="{$ctx:planyoState}" />
                     |
                     <with-param name="planyoCountry" value="{$ctx:planyoCountry}" />
                     |
                     <with-param name="nexmoAPIKey" value="{$ctx:nexmoAPIKey}" />
                     |
                     <with-param name="nexmoApiSecret" value="{$ctx:nexmoApiSecret}" />
                     |
                     <with-param name="nexmoSender" value="{$ctx:nexmoSender}" />
                     |
                     <with-param name="planyoResourceId" value="{$ctx:planyoResourceId}" />
                     |
                     <with-param name="planyoStartTime" value="{$ctx:planyoStartTime}" />
                     |
                     <with-param name="planyoEndTime" value="{$ctx:planyoEndTime}" />
                     |
                     <with-param name="planyoFirstName" value="{$ctx:planyoFirstName}" />
                     |
                     <with-param name="planyoLastName" value="{$ctx:planyoLastName}" />
                     |
                     <with-param name="planyoQuantity" value="{$ctx:planyoQuantity}" />
                     |
                     <with-param name="planyoEmail" value="{$ctx:planyoEmail}" />
                     |
                     <with-param name="planyoMobilePrefix" value="{$ctx:planyoMobilePrefix}" />
                     |
                     <with-param name="planyoPhoneNumber" value="{$ctx:planyoPhoneNumber}" />
                     |
                     <with-param name="planyoPhonePrefix" value="{$ctx:planyoPhonePrefix}" />
                     |
                     <with-param name="planyoMobileNumber" value="{$ctx:planyoMobileNumber}" />
                     |
                     <with-param name="nexmoContactNumber" value="{$ctx:nexmoContactNumber}" />
                     |
                     )*
                  </call-template>
                  <property name="reseravtionIndex" expression="get-property('operation','reseravtionIndex') + 1"
                     scope="operation" />
               </sequence>
            </target>
         </iterate>
         <filter xpath="get-property('operation', 'reseravtionIndex') = get-property('operation', 'reservationCount')">
            <then>
               <loopback />
            </then>
         </filter>
      </inSequence>
      <outSequence>
         <!-- Generate the chained response of all the API calls in createReservationAndSendMessage -->
         <property name="messageType" value="application/json" scope="axis2" />
         <payloadFactory media-type="json">
            <format>
               {
               "Response":{
               "process":"planyo_makeReservationAndSendSMS",
               "activityResponse":[$1]
               }
               }
            </format>
            <args>
               <arg evaluator="xml" expression="get-property('operation', 'responseString')" />
            </args>
         </payloadFactory>
         <send />
      </outSequence>
   </target>
   <description />
</proxy>               
Sample Request for checking the availability for a given resource using the Planyo API and if the resource is available, making the reservation in Planyo API and sending the reservation details to the client via a Nexmo SMS
{
    "planyoAPIKey": "45fd0acfee3f0388aeb8e7823179d21d",
    "nexmoAPIKey": "0f5d0ba2",
    "nexmoApiSecret": "58fc67ba",
    "nexmoSender": "Disna",
    "reservationDetails": [
        {
            "planyoResourceId": "41453",
            "planyoStartTime": "2015-05-01",
            "planyoEndTime": "2015-05-02",
            "planyoQuantity": "1",
            "planyoEmail": "apptestsforplanyo@gmail.com",
            "planyoFirstName": "Daisy",
            "planyoLastName": "Dias",
            "planyoMobilePrefix": "94",
            "planyoMobileNumber": "773013702",
            "planyoAddress": "111,test,test",
            "planyoCity": "city",
            "planyoZip": "10600",
            "planyoState": "STATE",
            "planyoCountry": "SL",
            "planyoPhonePrefix": "1",
            "planyoPhoneNumber": "114600200"
        },
        {
            "planyoResourceId": "41453",
            "planyoStartTime": "2015-05-03",
            "planyoEndTime": "2015-05-04",
            "planyoQuantity": "1",
            "planyoEmail": "apptestsforplanyo@gmail.com",
            "planyoFirstName": "Rayan",
            "planyoLastName": "De Silva",
            "planyoMobilePrefix": "94",
            "planyoMobileNumber": "774029300"
        }
    ]
}

Mandatory and Optional Parameters

Mandatory parameters : planyoAPIKey, reservationDetails

Reservation details will be sent to the Client only if the 'nexmoAPIKey' has been provided. If so, planyoMobilePrefix, planyoMobileNumber, nexmoApiSecret and nexmoSender properties are mandatory.

Note

 The following are the parameter descriptions:

  • planyoAPIKey: The API key of the Planyo account
  • nexmoAPIKey: The API Key of the Nexmo account
  • nexmoApiSecret: The API secret of the Nexmo account
  • nexmoSender: The address of the message sender 
  • reservationDetails: Array of JSON objects containing details to create reservations. JSON objects contains the following parameters:
    • planyoResourceId: The Planyo resource identifier
    • planyoStartTime: The beginning of rental duration for the reservation
    • planyoEndTime: The end of rental duration for the reservation
    • planyoQuantity: The number of units to be reserved
    • planyoEmail: The e-mail address of the Planyo user
    • planyoFirstName: The first name of the Planyo user 
    • planyoLastName: The last name of the Planyo user
    • planyoMobilePrefix: The Planyo user's phone's country code
    • planyoMobileNumber: The Planyo user's phone number without the country code

Â