import logging

from flask import flash
import requests.exceptions

from config import URIBuilder

__author__ = 'hanl'

logging.basicConfig(level=logging.DEBUG)


def get(path="", **kwargs):
    return request('get', path, **kwargs)


def post(path="", **kwargs):
    path = URIBuilder().addPath(path).build()
    if 'headers' in kwargs:
        headers = kwargs['headers']
        headers["Content-Type"] = "application/x-www-form-urlencoded"
    else:
        headers = {"Content-Type": "application/x-www-form-urlencoded"}
    kwargs['headers'] = headers
    return request('post', path, **kwargs)


def request(method, path="", **kwargs):
    path = URIBuilder().addPath(path).build()
    if kwargs and path is not "":
        try:
            response = requests.request(method, path, **kwargs)
        except requests.exceptions.RequestException as e:
            print e
            flash("Connection to API server could not be established", "danger")
            return None
        print "the response %i:%s" % (response.status_code, str(response.content))
        return response
    return None
