Giter Site home page Giter Site logo

tourcms's Introduction

tourcms

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

Build Status

Install

pip install tourcms

Usage

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

conn = tourcms.Connection(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 dict or raw where raw will return the raw XML from the API and dict will return a dictionary of the result. Dict requires xmltodict to be installed.

Working with your connection in Raw mode

    # Instantiate the connection
    import os
    from tourcms import Connection

    conn = Connection(0, os.getenv('TOURCMS_PRIVATE_KEY'))

    # Check we're working
    conn.api_rate_limit_status(channel_id)
    => "<?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(channel_id)
    => ""<?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 Dictionary mode

Requires xmltodict to be installed

pip install xmltodict
    # Instantiate the connection
    conn = Connection(0, os.getenv('TOURCMS_PRIVATE_KEY'), "dict")

    # Check we're working
    conn.api_rate_limit_status(channel_id)
    => OrderedDict([(u'request', u'GET /api/rate_limit_status.xml?'), (u'error', u'OK'), (u'remaining_hits', u'1999'), (u'hourly_limit', u'2000')])
    obj["hourly_limit"]
    => 2000   

Passing parameters

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

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

List of functions in tourcms.Connection

  • api_rate_limit_status
  • list_channels
  • show_channel
  • search_tours
  • search_hotels_range
  • search_hotels_specific
  • list_tours
  • list_tour_images
  • show_tour
  • show_tour_departures
  • show_tour_freesale
  • show_supplier

Dependencies

None. xmltodict optional. Tested with Python 2.6, 2.7 & 3.3.

Copyright

Copyright (c) 2012 Jonathan Harrington. See LICENSE.txt for further details.

tourcms's People

Contributors

prio avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

tourcms's Issues

HTTP Error 401: Not Authorized

Thank you for your work! But need little help with it.

'urllib.error.HTTPError: HTTP Error 401: Not Authorized'

same key and id test good in node and js.

Looks something wrong with this 10 years old library...... maybe something wrong with python 3.10?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.