tourcms

A simple wrapper for connecting to TourCMS Marketplace API. This wrapper mirrors the TourCMS PHP library.

Install

    gem install tourcms

Usage

Using the library is as simple as creating a TourCMS::Connection object:

    conn = TourCMS::Connection.new(marketplace_id, private_key, result_type)

Your Marketplace ID and Private Key can be found in the TourCMS Partner Portal. The result type can be one of hash or raw where raw will return the raw XML from the API and hash will return a Ruby Hash of the result.

Working with your connection in Raw mode

    # Instantiate the connection
    conn = TourCMS::Connection.new("12345", "mydeepsecret", "raw")
    # Check we're working
    conn.api_rate_limit_status
    => "<?xml version="1.0" encoding="utf-8" ?><response><request>GET /api/rate_limit_status.xml</request>
            <error>OK</error><remaining_hits>1999</remaining_hits><hourly_limit>2000</hourly_limit></response>"
    # List the channels we have access to
    conn.list_channels
    => ""<?xml version="1.0" encoding="utf-8" ?><response><request>GET /p/channels/list.xml</request>
            <error>OK</error><channel>(...)</channel><channel>(...)</channel><channel>(...)</channel></response>"
    # Show a particular channel
    conn.show_channel(1234567)
    => ""<?xml version="1.0" encoding="utf-8" ?><response><request>GET /p/channels/list.xml</request>
            <error>OK</error><channel>(...)</channel></response>"

Working with your connection in Hash mode

    # Instantiate the connection
    conn = TourCMS::Connection.new("12345", "mydeepsecret", "hash")
    # Check we're working
    obj = conn.api_rate_limit_status
    => {:request=>"GET /api/rate_limit_status.xml", :remaining_hits=>1999, :error=>"OK", :hourly_limit=>2000}       
    obj[:hourly_limit]
    => 2000
    # List the channels we have access to
    obj = conn.list_channels
    => {Hash of all connected TourCMS channels and their properties}
    # See how many TourCMS channels you're connected to.
    obj[:channel].count
    => 100 
    obj[:channel].first[:channel_name]
    => "My Adventure Tour Operator"
    # Show a particular channel
    obj = conn.show_channel(1234567)
    obj[:channel][:channel_id]
    => "1234567"
    # Search for all tours in GB
    obj = conn.search_tours(:country => "GB")
    obj[:tour].first[:tour_name]
    => "Canyoning"

Passing parameters

Many TourCMS methods accept parameters. Most methods take a hash of parameters like so:

    obj = conn.search_tours({:country => "GB", :lang => "en"})

List of functions in TourCMS::Connection

Dependencies

This gem depends on ActiveSupport 3.0.0+

Contributing to tourcms

Copyright © 2011 Flextrip. See LICENSE.txt for further details.