﻿TTHIBServices = {
    TTWSHotel: {
        description: "Service provides information about hotels.",
        methods: {
            getDescriptionForHotel: {
                description: "Gets hotel description.",
                params: {
                    iffCode: { type: "int", description: "Hotel IFF code.", example: "123456" },
                    time: { type: "DateTime", description: "Date for which the description is required.", example: "2009-12-31T22:59:59.999Z" },
                    tourOperator: { type: "String", description: "Get only description from the specific tour operator.", example: "COS" },
                    allowAltDescription: { type: "bool", description: "Should alternative descriptions be allowed?", example: "true" },
                    tourOperatorSetFilter: { type: "string", description: "Use this parameter if you want exclude certain tour operators form the results. If you want to specify more than one tour operator the codes have to be separated with the semicolon.", example: "COS;TCH" }
                }
            },
            getShortDescriptionForHotel: {
                description: "Gets short hotel description for teasers.",
                params: {
                    iffCode: { type: "int", description: "Hotel IFF code.", example: "123456" },
                    time: { type: "DateTime", description: "Date for which the description is required.", example: "2009-12-31T22:59:59.999Z" },
                    tourOperator: { type: "String", description: "Get only description from the specific tour operator.", example: "COS" },
                    allowAltDescription: { type: "bool", description: "Should alternative descriptions be allowed?", example: "true" },
                    tourOperatorSetFilter: { type: "string", description: "Use this parameter if you want exclude certain tour operators form the results. If you want to specify more than one tour operator the codes have to be separated with the semicolon.", example: "COS;TCH" }
                }
            },
            getShortDescriptionsForHotel: {
                description: "Gets list of short hotel descriptions for teasers.",
                params: {
                    iffCode: { type: "string", description: "Hotel IFF codes separated with pipe.", example: "123456|345246|456345" },
                    time: { type: "DateTime", description: "Date for which the description is required. Used if the date should be the same for all hotels.", example: "2009-12-31T22:59:59.999Z" },
                    times: { type: "string", description: "Dates for which the description is required separated with pipe. If you want to get descriptions for the same date for all hotels please use parameter 'time'.", example: "2009-12-31T22:59:59.999Z|2009-12-31T22:59:59.999Z|2009-12-31T22:59:59.999Z" },
                    tourOperator: { type: "String", description: "Get only description from the specific tour operator.", example: "COS" },
                    allowAltDescription: { type: "string", description: "Should alternative descriptions be allowed?", example: "true" },
                    tourOperatorSetFilter: { type: "string", description: "Use this parameter if you want exclude certain tour operators form the results. If you want to specify more than one tour operator the codes have to be separated with the semicolon.", example: "COS;TCH" }
                }
            },
            getHotelAttributes: {
                description: "Gets hotel attributes.",
                params: {
                    iffCode: { type: "string", description: "Hotel IFF code.", example: "123456" }
                }
            }
        }
    },
    TTWSHotelRating: {
        description: "Service provides information about travellers' evaluation of the hotel.",
        methods: {
            doesHotelRatingExist: {
                description: "Specifies whether hotel ratings exist.",
                params: {
                    language: { type: "string", description: "Hotel ratings language. Available values: 'DE' or 'EN'", example: "'EN'" },
                    iffCode: { type: "int", description: "Hotel IFF code.", example: "123456" }
                }
            },
            getHotelRatingStatistic: {
                description: "Returns summarized figures and statistics on reviews of a hotel.",
                params: {
                    language: { type: "string", description: "Hotel ratings language. Available values: 'DE' or 'EN'", example: "'EN'" },
                    iffCode: { type: "int", description: "Hotel IFF code.", example: "123456" }
                }
            },
            getHotelRatingsStatisticWithDetails: {
                description: "Returns summarized figures and statistics on reviews of a hotel with subcategories.",
                params: {
                    language: { type: "string", description: "Hotel ratings language. Available values: 'DE' or 'EN'", example: "'EN'" },
                    iffCode: { type: "int", description: "Hotel IFF code.", example: "123456" }
                }
            },
            getHotelRatings: {
                description: "Returns a list of the hotel reviews.",
                params: {
                    language: { type: "string", description: "Hotel ratings language. Available values: 'DE' or 'EN'", example: "'EN'" },
                    iffCode: { type: "int", description: "Hotel IFF code.", example: "123456" },
                    sort: { type: "string", description: "Pipe separated sort options. Following options are available: <ul><li>newestRating : The latest review first (default).</li><li>ageYoung : Ascending order by traveller age.</li><li>ageOld : Descending order by traveller age.</li><li>ratingOverAllBest : Best rated first.</li><li>ratingOverAllWorst: Worst rated first.</li><li>travelTimeJanToDec: Sort by months. First votes from January. (reviews in recent year are shown in the same month first)</li><li>travelTimeDecToJan: Sort by months. First votes in December. (reviews in recent year are shown in the same month first)</li><li>recommendation : Ratings with recommendation first.</li><li>noRecommendation : Ratings with no recommendation first.</li></ul>", example: "ageYoung|newestRating" },
                    rangeFrom: { type: "int", description: "Used to for paging. Index of the first returned review.", example: "0" },
                    rangeTo: { type: "int", description: "Used to for paging. Index of the last returned review.", example: "9" }
                }
            },
            getHotelRatingsWithDetails: {
                description: "Returns a list of the detailed hotel reviews.",
                params: {
                    language: { type: "string", description: "Hotel ratings language. Available values: 'DE' or 'EN'", example: "'EN'" },
                    iffCode: { type: "int", description: "Hotel IFF code.", example: "123456" },
                    sort: { type: "string", description: "Pipe separated sort options. Following options are available: <ul><li>newestRating : The latest review first (default).</li><li>ageYoung : Ascending order by traveller age.</li><li>ageOld : Descending order by traveller age.</li><li>ratingOverAllBest : Best rated first.</li><li>ratingOverAllWorst: Worst rated first.</li><li>travelTimeJanToDec: Sort by months. First votes from January. (reviews in recent year are shown in the same month first)</li><li>travelTimeDecToJan: Sort by months. First votes in December. (reviews in recent year are shown in the same month first)</li><li>recommendation : Ratings with recommendation first.</li><li>noRecommendation : Ratings with no recommendation first.</li></ul>", example: "ageYoung|newestRating" },
                    rangeFrom: { type: "int", description: "Used to for paging. Index of the first returned review.", example: "0" },
                    rangeTo: { type: "int", description: "Used to for paging. Index of the last returned review.", example: "9" }
                }
            },
            getPicturesFromTravellers: {
                description: "Get a list of pictures submitted by travellers.",
                params: {
                    language: { type: "string", description: "Hotel ratings language. Available values: 'DE' or 'EN'", example: "'EN'" },
                    iffCode: { type: "int", description: "Hotel IFF code.", example: "123456" }
                }
            }
        }
    },
    TTWSAlmanach: {
        description: "Service provides information about region.",
        methods: {
            getNavigationRegion: {
                description: "Gets list of available information for the region.",
                params: {
                    regionRefId: { type: "string", description: "Region ID.", example: "999_10_DE2" },
                    iffCode: { type: "int", description: "Hotel IFF code. It's more efficient to use \"regionRefId\" instead.", example: "123456" }
                }
            },
            /*getRegionInfo: {
            description: "Gets full region information. It's the same as alling all the methods below. It's more efficient to request the information using methods below.",
            params: {
            language: { type: "string", description: "Region information language. Available values: 'DE' or 'EN'", example: "'EN'" },
            regionRefId: { type: "string", description: "Region ID.", example: "999_10_DE2" },
            iffCode: { type: "int", description: "Hotel IFF code. It's more efficient to use \"regionRefId\" instead.", example: "123456" }
            }
            },*/
            getRegionGeneralInfo: {
                description: "Gets general information about the region.",
                params: {
                    regionRefId: { type: "string", description: "Region ID.", example: "999_10_DE2" },
                    iffCode: { type: "int", description: "Hotel IFF code. It's more efficient to use \"regionRefId\" instead.", example: "123456" }
                }
            },
            getRegionFoodAndDrink: {
                description: "Gets information about food and dring in the region.",
                params: {
                    regionRefId: { type: "string", description: "Region ID.", example: "999_10_DE2" },
                    iffCode: { type: "int", description: "Hotel IFF code. It's more efficient to use \"regionRefId\" instead.", example: "123456" }
                }
            },
            getRegionActivities: {
                description: "Gets list of available information for the region.",
                params: {
                    regionRefId: { type: "string", description: "Region ID.", example: "999_10_DE2" },
                    iffCode: { type: "int", description: "Hotel IFF code. It's more efficient to use \"regionRefId\" instead.", example: "123456" }
                }
            },
            getRegionOutAndAbout: {
                description: "Gets information about social attractions in the region.",
                params: {
                    regionRefId: { type: "string", description: "Region ID.", example: "999_10_DE2" },
                    iffCode: { type: "int", description: "Hotel IFF code. It's more efficient to use \"regionRefId\" instead.", example: "123456" }
                }
            },
            getRegionCountryAndPeople: {
                description: "Gets information about country and people.",
                params: {
                    regionRefId: { type: "string", description: "Region ID.", example: "999_10_DE2" },
                    iffCode: { type: "int", description: "Hotel IFF code. It's more efficient to use \"regionRefId\" instead.", example: "123456" }
                }
            },
            getRegionFactsAndFigures: {
                description: "Gets facts and figures about the region.",
                params: {
                    regionRefId: { type: "string", description: "Region ID.", example: "999_10_DE2" },
                    iffCode: { type: "int", description: "Hotel IFF code. It's more efficient to use \"regionRefId\" instead.", example: "123456" }
                }
            },
            getRegionSlideShow: {
                description: "Gets list of pictures representing the region.",
                params: {
                    regionRefId: { type: "string", description: "Region ID.", example: "999_10_DE2" },
                    iffCode: { type: "int", description: "Hotel IFF code. It's more efficient to use \"regionRefId\" instead.", example: "123456" }
                }
            },
            getEmbassy: {
                description: "Returns information about embassy.",
                params: {
                    regionRefId: { type: "string", description: "Region ID.", example: "999_10_DE2" },
                    iffCode: { type: "int", description: "Hotel IFF code. It's more efficient to use \"regionRefId\" instead.", example: "123456" }
                }
            },
            getMap: {
                description: "Returns region map.",
                params: {
                    iffCode: { type: "int", description: "Hotel IFF code. It's more efficient to use \"regionRefId\" instead.", example: "123456" }
                }
            }
        }
    },
    TTWSPOI: {
        description: "Service provides information points of interest near to the hotel.",
        methods: {
            getPOIs: {
                description: "Returns list of points of interests.",
                params: {
                    iffCode: { type: "int", description: "Hotel IFF code. It's more efficient to use \"regionRefId\" instead.", example: "123456" },
                    poiType: { type: "string", description: "Pipe separated types of POI. supported values:<ul><li>'H': hotel (german: 'Hotel')</li><li>'S': beach (german: 'Strände')</li><li>'L': landscape (german: 'Landschaften')</li><li>'SW': sight (german: 'Sehenswürdigkeiten')</li><li>'O': village (german: 'Orte')</li><li>'P': promenade (german: 'Promenaden')</li><li>'Y': marina (german: 'Yachthäfen')</li><li>'T': tourism (german: 'Touristik')</li><li>'F': amusementPark (german: 'Freizeitparks')</li><li>'A': sport (german: 'Sport')</li><li>'K': church (german: 'Kirchen')</li><li>'E': shoppingMile (german: 'Einkaufsmeilen')</li><li>'R': restaurant (german: 'Restaurants')</li><li>'N': nightlife (german: 'Nachtleben')</li><li>'V': traffic (german: 'Verkehr')</li><li>'PE': people (german: 'Personen')</li><li>'FE': celebration (german: 'Feste')</li><li>'IMP': impression (german: 'Impressionen')</li></ul>", example: "F|A|R|T|S" }
                }
            },
            getPOIDetail: {
                description: "Returns details of the point of interests.",
                params: {
                    iffCode: { type: "int", description: "Hotel IFF code.", example: "123456" },
                    poiRefID: { type: "string", description: "POI ID. Returned by the method getPOIs.", example: "100_20_A70" }
                }
            }
        }
    },
    TTWSWeather: {
        description: "Service provides information about weather.",
        methods: {
            /*
            getWeather: {
            description: "Returns all weather information. For better performance it's better to use other methods of the service.",
            params: {
            iffCode: { type: "int", description: "Hotel IFF code.", example: "123456" }
            }
            },
            */
            getClimaData: {
                description: "Returns General information about local weather - max and min temperatures of the air and water, days of rain etc.",
                params: {
                    iffCode: { type: "int", description: "Hotel IFF code.", example: "123456" }
                }
            },
            getWeatherForecast: {
                description: "Returns 5 days weather forecast for the region.",
                params: {
                    iffCode: { type: "int", description: "Hotel IFF code.", example: "123456" }
                }
            }
        }
    }
    /*
    TTWSEvent: {},
    TTWSAirport: {},
    TTWSWintersport: {},
    TTWSGeneral: {}
    */
};

TTHIBService.showHelp = function(context) {
    for (service in TTHIBServices) {
        $(context).append("<div onclick=\"$('#" + service + "_methods').toggle('slow');\" style='cursor:pointer;'>" + service + "</div>");
        $(context).append("<div id='" + service + "_methods'></div>");
        var methodsContainer = $("#" + service + "_methods");
        methodsContainer.hide();
        for (method in TTHIBServices[service].methods) {
            var paramsString = "";
            for (paramName in TTHIBServices[service].methods[method].params)
                paramsString += paramName + ", ";

            $(methodsContainer).append("<div onclick=\"$('#" + service + "_" + method + "_params').toggle('slow');\" style='cursor:pointer;'>&nbsp;&nbsp;<b>" + method + "</b>(" + paramsString.substring(0, paramsString.length - 2) + ")</div>");
            $(methodsContainer).append("&nbsp;&nbsp;&nbsp;&nbsp;<span style='color:blue;'>" + TTHIBServices[service].methods[method].description + "</span>");
            $(methodsContainer).append("<div id='" + service + "_" + method + "_params'></div>");
            var paramsContainer = $("#" + service + "_" + method + "_params");
            paramsContainer.hide();

            $(paramsContainer).append("&nbsp;&nbsp;&nbsp;&nbsp;<span style='color:red;'>callback</span>: Callback function where the results will be returned.<br/>");
            for (paramName in TTHIBServices[service].methods[method].params) {
                var p = TTHIBServices[service].methods[method].params[paramName];
                $(paramsContainer).append("&nbsp;&nbsp;&nbsp;&nbsp;<span style='color:red;'>" + paramName + "</span>: " + p.description + "<br/>");
                $(paramsContainer).append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Type: " + p.type + "<br/>");
                $(paramsContainer).append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Example: " + p.example + "<br/>");
            }
        }

    }
};

function _printJBindObject(template, obj) {
    var objectString = "<table border=1>";
    objectString += "<tr><td colspan=2 style='background:grey'>Object</td></tr>";
    objectString += "<tr><td style='background:grey'>Property</td><td style='background:grey'>Value</td><tr>";
    for (property in obj)
        objectString += '<tr><td valign="top"><b>' + property + '</b></td><td>' + (typeof (obj[property]) == 'object' ? $.fn.bindTo.printObject('', obj[property]) : obj[property]) + '</td></tr>';
    objectString += "</table>";
    template = template + objectString;

    return template;
};

$.fn.bindTo.printObject = _printJBindObject;