Package tlib :: Package base :: Module HttpHelper :: Class HttpHelper
[hide private]
[frames] | no frames]

Class HttpHelper

source code

   object --+    
            |    
Helper.Helper --+
                |
               HttpHelper

Helper class for sending requests of HTTP with GET and POST

Instance Methods [hide private]
 
__init__(self, request_type, api_url, login_cred={}, client_cred={}, request_header={})
Args : request_type (str) : Takes POST or GET as type of HTTP requests api_url (str) : The url to the base of the API call (everything but the call itself) login_cred (dict) : Optionally takes a username and password if the HTTP takes authentication
source code
 
getResponse(self, constructed_url)
Sends the api call and returns the response
source code
 
getHTTPResponse(self, call, data)
constructs and sends the api call and returns the response
source code
 
createUrl(self, data, theurl)
Helper function to create url in either path or parameter api methods
source code
 
getAuth(self, theurl)
Creates the authentication for accessing api
source code
 
decodeHtmlString(self, string)
translates html entities into a readable string
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  login_cred = {}
Auth for HTTP access.
  client_cred = {}
Auth for client credentials.
  api_url = None
  api_param = None
  request_type = None
  responseFormat = None

Inherited from Helper.Helper: logger

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, request_type, api_url, login_cred={}, client_cred={}, request_header={})
(Constructor)

source code 

Args : request_type (str) : Takes POST or GET as type of HTTP requests api_url (str) : The url to the base of the API call (everything but the call itself) login_cred (dict) : Optionally takes a username and password if the HTTP takes authentication

Returns : null

Raises : null

Overrides: object.__init__

getResponse(self, constructed_url)

source code 

Sends the api call and returns the response

Args : constructed_url: (str) url and parameters to send

Returns : the_page: (json) response body from the api call code: (int) response code from the HTTP response error: (string) error response if api call returns error

Raises : urllib2.HTTPError,urllib2.URLError

getHTTPResponse(self, call, data)

source code 

constructs and sends the api call and returns the response

Args : call: (str) Name of the api service you are calling data: (list) The parameters you will be providing the api service

Returns : null

Raises : null

createUrl(self, data, theurl)

source code 

Helper function to create url in either path or parameter api methods

Args : data: (str) values sent to api query theurl: (str) the http path to the api method

Returns : null

Raises : null

getAuth(self, theurl)

source code 

Creates the authentication for accessing api

Args : theurl: (str) the http path to the api method

Returns : null

Raises :null

decodeHtmlString(self, string)

source code 

translates html entities into a readable string

Args : string: (str) an html entity

Returns : unescaped: (str) returns a readable string

Raises :null


Class Variable Details [hide private]

login_cred

Auth for HTTP access. type(dict) : {'username':'x','password':'y'}

Value:
{}

client_cred

Auth for client credentials. to be added to header.

Value:
{}