.. meta:: :description: WuBook docs, API for channel manager, booking engine and pms :keywords: wubook API, channel manager, booking engine .. _jslib: Online Reception: WuBook's Javascript Library ********************************************* Our developers created an easy javascript library to help you integrate the online booking service on your pages. The library is designed to avoid conflicts with third-party libraries. Loading and using the WuBook Library ==================================== Including the library and initializing is trivial. You just need a unique parameter- the lcode param- which is the property identifier. Assuming that your lcode is 1402584731: .. code-block:: html Before reading about the features of the WuBook object, let's understand how the library can be useful to implement UI effects and tools. Again, we assume that whoever would use these calls knows a little bit of javascript coding. Ui Tools (calendars and more) and jQuery framework ================================================== WuBook's library also embeds a customized and hidden jquery and jquery-UI library that doesn't generate any kind of conflict. If you want to use the embedded jQuery framework, you can access it this way: .. code-block:: html If you want, you can also export the jQuery framework on your site. Just initialize the WuBook object with a second (true) argument: .. code-block:: html Now, the embedded version of jquery - otherwise hidden inside the WuBook object- is exported on your site. You access it with the usual, global variable $ (instead of WuBook). Notice that this approach **can** create conflicts with other libraries and frames, like prototype and mootools. The WuBook Object ================= The WuBook javascript object has many interesting features. Here they are: - **WuBook.open()** is used to open the online reception on a new window (online booking) - **WuBook.fount()** allows you to export room prices - **WuBook.sendmail()** allows you to implement a messaging form: customers can send an email to the property - **WuBook.cancel()** allows to cancel a reservation. This way, you can provide the cancellation service directly on the property site - **WuBook.specialOffers()** allows to load property's special offers - **WuBook.design_rwidget()** allows you to include the WuBook Responsive Widget on your site (fully featured and customizable, check later) - **WuBook.design_bwidget()** allows you to include the WuBook Widget on your site as a full width bar (fully featured and customizable, check later) - **WuBook.design_iframe()** allows you to embed the booking system inside the pages of your site, via Iframe - **WuBook.design_pwidget()** allows you to implement on your site the WuBook Package Widget - **WuBook.pkgs()** allows you to load property's holiday packages - **WuBook.pkg_availability()** checks the availability of one package - **WuBook.book_package()** allows you to book a Holiday Package - **WuBook.design_feeds_widget()** allows you to implement the WuBook Feeds Widget - **WuBook.feedbacks()** allows you to retrieve the feedbacks that customers gave to your the property - **WuBook.crossed()** allows you to build a calendar with only the available days From now on, it's assumed that the WuBook Object has been initialized: .. code-block:: html Once you have the WuBook object you can begin to use your functions. .. function:: WuBook.open(params) loads and opens the Online Reception. You can check the full list of possible parameters at the section :doc:`getpost`. :A simple example follows: .. code-block:: html You have also the following additional parameter: wbgoogle (1 or 0). If true, the WuBook Ojbect will automatically handle the mapping between the WuBook Online Reception and the Google Analytics account you're using on your site. The integration with Google services will track Adwords conversions too. .. function:: WuBook.fount(params, cback) exports the prices for the property. Example: .. code-block:: html As you will see, the result is a simple object having 3 keys: error, warnings and results. The last one is a simple object, having "occupancies" as key and "prices" as values. :For instance: .. code-block:: html { "warnings": "", "results": {lcode: {"1": 340.0, "2": 306.0, "4": 1360.0}}, "error": "" } The previous example states that, for the selected dates, single average price is 340, while double is 306 and 4-pax room costs 1360 (averagely per night). To understand the possible parameters, check :ref:`fount`. .. function:: WuBook.sendmail(params, callback) is used to send an email to the property. You just need to collect the following parameters: - cname: the name of the customer (it can be for example First Name + Last Name) - email: the email of the customer - subject: the subject of the email - text: the text of the message These parameters are **mandatory**. There is an optional parameter, lang, which is used to correctly translate the confirmation message we will send the customer when the email will be delivered to the property. So, this is a simple example: .. code-block:: html .. function:: WuBook.cancel(params, cback) is used to cancel a reservation. You can use this call to implement a form on the property site, allowing property customers to cancel their reservations on their pages. It accepts 2 mandatory and 1 optional parameters: - rcode: the reservation code - email: the email used to finalize the reservation that the customer wants to cancel - lang (optional): if you specify the language, we will return translated strings :This is a simple example: .. code-block:: html .. function:: WuBook.specialOffers(cback) is used to retrieve the property's special offers. A full set of data is returned (JSON encoded). Once retrieved, you can enrich the site contents, displaying them and eventually providing a link for each of them for opening the online reception for the appropriate dates. The provided callback function will accept a unique argument: the Special Offers list. :A first example: .. code-block:: html How to handle **special offers**? It's easy. SpecialOffersList is an object containing the following attributes: .. code-block:: html Object description: Object de: "german descr" en: "english descr" es: "" fr: "" gr: "" it: "" nl: "" pt: "" ru: "" name: Object de: "Pasqua Rosa!!" en: "Pasqua Rosa!!" es: "Pasqua Rosa!!" fr: "Pasqua Rosa!!" gr: "Pasqua Rosa!!" it: "Pasqua Rosa!!" nl: "Pasqua Rosa!!" pt: "Pasqua Rosa!!" ru: "Pasqua Rosa!!" periods: Array[1] 0: Array[2] 0: "06/04/2012" 1: "09/04/2012" type: "5.00 %" Now that you have a list of Special Offers, formatted as described, you can enrich the site's content. :This is a simple example (adding contents to the tag with id "special_offers_id"): .. code-block:: html .. function:: WuBook.design_rwidget(element_id, params, cback) is used to build and deploy the responsive widget (booking form) on the website pages. If you want, you can use an Online Code Generator. Otherwise, to use it your way, you need to provide the following parameters: **element_id**: is the id of an HTML-DIV element. The widget will be deployed here. The DIV must contain a backlink to the WuBook site. **params** is an array of parameters, all optional. Here they are: - **Note**: **You don't need this!** The width is not necessary because the widget can adapts itself to the width of external container. - **Note**: **You don't need this!** the heigth is automatically calculated to fit the widget content. - lang: the language, no param means auto-detect (possible languages are en,it,ru,es.... and so on) - failback_lang: just in case lang is not specified and server cannot detect the language: this language will be used. - default_nights: default number of nights added when the dfrom date is selected. - wbgoogle: google analytics enabled (0 or 1). Default is 1. - thn: The Hotels Network analytics enabled (0 or 1). Default is 0. - css: inline css to fully customize the widget (optional). Example: css="a {font-size: 100px}" - openParams: Not mandatory. It is an object, like {eurota: 'code', lang: 'fr'}. These parameters are passed to the Online Booking. Check WuBook.open() for a description of parameters - bordercolor: external border color. Default is #108DBD. - bgcolor: background color. Default is #FFFFFF. - textcolor: fonts color. Default is #2C2C2C. - buttoncolor: "Book" button color. Default is #108DBD. - iconcolor: external border color. Default is #888888. - dcode: Not mandatory; If it provided equal to 1 displays a discount code field. - dcodeval: A string type not mandatory; if provided a discount code field is inserted and precompiled with this value. - leisure: leisure is not mandatory to open the Online Reception. If its value is 0, field is not included in the widget. If 1 the field is included but the choice is not mandatory, if its value is 2 the fields is mandatory: if it is not specified, at the open of Online Reception will be required. - calendarup: If its value is 1, the date selector is opened on the top of the widget instead of the bottom. Default is 0. - cback: optional: cback represents a callback which will be fired once the widget will be designed. :So, this is a simple example, assuming all is inside a The code above will create an iframe with the Online Reception inside the specified element and will open it. It also cares about 3 parameters: dfrom, dto and nigths. If they are specified in the GET query string, WuBook will detect them, opening the online reception inside the iframe for the desired dates. So, if you design the iframe on the page /foo/bar, you can use /foo/bar?dfrom=today&nights=2. .. function:: WuBook.design_pwidget(element_id, params, cback) is used to build and deploy the holiday package widget on the website pages. If you want, you can use an online generator located in the wubook panel. Otherwise, to use it your way, you need to provide the following parameters: **element_id**: is the id of the HTML DIV element. Iframe will be placed here. It contains a backlink to the WuBook site, see the example below. **params** is an array of optional parameters. Here they are: - pkgs: it is an array containing the package's ids. If it is not provided all packages of property will be showed in the widget. - layout: there are two options available, 1 for the orizontal layout (the default if the paramter is not added) and 0 for the vertical. - lang: the language, no param means auto-detect (possible languages are en,it,ru,es.... and so on) - cback: optional: cback represents a callback which will be fired once the widget will be designed. :So, this is a simple example: .. code-block:: html
Booking by Wu
.. function:: WuBook.pkgs(cback) is used to retrieve the property's holiday packages. A full set of data is returned (JSON encoded). With these you can enrich the site contents displaying them, and eventually providing a link for each of them that allows you to open the last step of booking for completion of the purchase. The provided callback function will accept a unique argument: the holiday packages list. :A first example: .. code-block:: html How to handle **holiday packages**? It's easy. pkgsList is an array of objects, any object contains the following attributes: .. code-block:: html Object id: "1" costs: "400.5" dates: Array Object daysweek: "0123456" dfrom: "05/06/2014" dto: "20/06/2014 nights: "2" deposit: "0" titles: Object de: "german title" en: "english title" es: "" fr: "" gr: "" it: "" nl: "" pt: "" ru: "" def : "default title" descriptions: Object de: "german descr" en: "english descr" es: "" fr: "" gr: "" it: "" nl: "" pt: "" ru: "" def : "default descr" occupancy: Array[2] 0: "2" 1: "0" rooms: Array[1] 0: Array[3] 0: "azt" 1: "13" 2: 1 type: "f" Now that you have a list of holiday packages, formatted as described, you can enrich the site's content and use it together with other method of WuBook object, WuBook.pkg_availability() and WuBook.book_package(), for creating a complete user interface. .. **Example Feedback** :Here you'll find an example of the feedback: .. code-block:: html This is a simple way to display your feedbacks, but WuBook gives you a lot of information! :Here is an example of feedback object: feedbacks: Object .. code-block:: html comment: "This is a comment left by a traveler." country: "IT" ctx_avg: Object ctx_id: 1 how: 5.89445485436752 name: "Comfort" Object ctx_id: 3 how: 8.01234448412143 name: "Cleaness" Object ctx_id: 4 how: 6.51234344377612 name: "Meals/Breakfast" date: "05-07-2013 10:33" feed_avg: 6.80198446211258 fname: "aaa" lname: "afads" reply: "" type: "Family with children" type_id: 1 global_avgs: Object averages: Object average: 7.55263157894737 context: 1 Object average: 8.02307692307692 context: 2 Object average: 7.67894736842105 context: 3 Object average: 7.59375623768624 context: 4 feeds_number: 21 .. function:: WuBook.pkg_availability(params, cback) checks the availability of a package. You must specify a package id and an arrival date: .. code-block:: html The pcallback function will be called with a true/false argument, depending on the availability of the package. .. function:: WuBook.book_package(pid, params) opens the Online Reception on the Package section, allowing you to book the package identified by pid. Params is an optional object that can contain the parameter dfrom. If dfrom is specified and the package is available for this date (see also WuBook.pkg_availability() ), it will be possible to book the package on a single step. .. function:: WuBook.design_feeds_widget(tagid, params, cback) is used to export the Feedback WuBook Widget. The widget will be inserted on the Tag identified by id=tagid. The object params can be empty. You can otherwise use it to specify: - a lang, - a layout for widget: 0 stand for vertical, 1 for horizontal, - a css theme: used for online reception opening (when the button "more details" is clicked) for instance: .. code-block:: html .. function:: WuBook.feedbacks(params, callback) retrieves property's feedbacks. The callback function will be called once the feedbacks are loaded. Its first argument is a list of feedbacks. Params is a set of optional argument and can accept the following keys: n and offset. N represents the maximum number of feedbacks you want to retrieve, while offset allows you to implement paging. Both parameters are optional. .. code-block:: html To interpret and display results, check the following tables: **Encoding of Traveler Type values:** - 1: 'Family with children' - 2: 'Couple' - 3: 'Group of friends' - 4: 'Single traveler' - 5: 'Working traveler' **Encoding of Feedback Contexts values:** - 1: 'Comfort' - 2: 'Cleanness' - 3: 'Staff' - 4: 'Meals/Breakfast' :Here is an example of feedback object: .. code-block:: html feedbacks: Object comment: "This is a comment left by a traveler." country: "IT" ctx_avg: Object ctx_id: 1 how: 5.89445485436752 name: "Comfort" Object ctx_id: 3 how: 8.01234448412143 name: "Cleaness" Object ctx_id: 4 how: 6.51234344377612 name: "Meals/Breakfast" date: "05-07-2013 10:33" feed_avg: 6.80198446211258 fname: "aaa" lname: "afads" reply: "" type: "Family with children" type_id: 1 global_avgs: Object averages: Object average: 7.55263157894737 context: 1 Object average: 8.02307692307692 context: 2 Object average: 7.67894736842105 context: 3 Object average: 7.59375623768624 context: 4 feeds_number: 21 error: "" .. function:: WuBook.crossed(params, cback) retrieves property’s availabilities day by day, from today up to 600 days. All rooms are considered. .. code-block:: html Days with a value of 1 are those to be crossed (no availability): .. code-block:: html { "crossed_days_map": { "2021-11-19": 0, "2021-11-10": 0, "2021-11-11": 0, "2021-11-12": 1, "2021-11-13": 1, ... } } We pretty much covered every aspect of it. Good luck!