# Path: salesforce/api.py
# DEFAULT_API_VERSION = '29.0'
# 
# Path: salesforce/util.py
# def getUniqueElementValueFromXmlString(xmlString, elementName):
#     """
#     Extracts an element value from an XML string.
# 
#     For example, invoking
#     getUniqueElementValueFromXmlString(
#         '<?xml version="1.0" encoding="UTF-8"?><foo>bar</foo>', 'foo')
#     should return the value 'bar'.
#     """
#     xmlStringAsDom = xml.dom.minidom.parseString(xmlString)
#     elementsByName = xmlStringAsDom.getElementsByTagName(elementName)
#     elementValue = None
#     if len(elementsByName) > 0:
#         elementValue = elementsByName[0].toxml().replace(
#             '<' + elementName + '>', '').replace('</' + elementName + '>', '')
#     return unescape(elementValue)
# 
# Path: salesforce/util.py
# class SalesforceError(Exception):
#     """Base Salesforce API exception"""
# 
#     message = u'Unknown error occurred for {url}. Response content: {content}'
# 
#     def __init__(self, url, status, resource_name, content):
#         # TODO exceptions don't seem to be using parent constructors at all.
#         # this should be fixed.
#         # pylint: disable=super-init-not-called
#         self.url = url
#         self.status = status
#         self.resource_name = resource_name
#         self.content = content
# 
#     def __str__(self):
#         return self.message.format(url=self.url, content=self.content)
# 
#     def __unicode__(self):
#         return self.__str__()


from .api import DEFAULT_API_VERSION
from .util import getUniqueElementValueFromXmlString
from .util import SalesforceError
    from html import escape
    from cgi import escape
    from SalesforceXyTools import requests
    import requests
                </urn:CallOptions>
            </soapenv:Header>
            <soapenv:Body>
                <urn:login>
                    <urn:username>{username}</urn:username>
                    <urn:password>{password}</urn:password>
                </urn:login>
            </soapenv:Body>
        </soapenv:Envelope>""".format(
            username=username, password=password, client_id=client_id)
    else:
        except_code = 'INVALID AUTH'
        except_msg = (
            'You must submit either a security token or organizationId for '
            'authentication'
        )
        raise SalesforceAuthenticationFailed(except_code, except_msg)

    login_soap_request_headers = {
        'content-type': 'text/xml',
        'charset': 'UTF-8',
        'SOAPAction': 'login'
    }
    response = (session or requests).post(
        soap_url, login_soap_request_body, headers=login_soap_request_headers,verify=False, 
        proxies=proxies)

    if response.status_code != 200:
        except_code = getUniqueElementValueFromXmlString(
            response.content, 'sf:exceptionCode')

# Path: salesforce/api.py
# DEFAULT_API_VERSION = '29.0'
# 
# Path: salesforce/util.py
# def getUniqueElementValueFromXmlString(xmlString, elementName):
#     """
#     Extracts an element value from an XML string.
# 
#     For example, invoking
#     getUniqueElementValueFromXmlString(
#         '<?xml version="1.0" encoding="UTF-8"?><foo>bar</foo>', 'foo')
#     should return the value 'bar'.
#     """
#     xmlStringAsDom = xml.dom.minidom.parseString(xmlString)
#     elementsByName = xmlStringAsDom.getElementsByTagName(elementName)
#     elementValue = None
#     if len(elementsByName) > 0:
#         elementValue = elementsByName[0].toxml().replace(
#             '<' + elementName + '>', '').replace('</' + elementName + '>', '')
#     return unescape(elementValue)
# 
# Path: salesforce/util.py
# class SalesforceError(Exception):
#     """Base Salesforce API exception"""
# 
#     message = u'Unknown error occurred for {url}. Response content: {content}'
# 
#     def __init__(self, url, status, resource_name, content):
#         # TODO exceptions don't seem to be using parent constructors at all.
#         # this should be fixed.
#         # pylint: disable=super-init-not-called
#         self.url = url
#         self.status = status
#         self.resource_name = resource_name
#         self.content = content
# 
#     def __str__(self):
#         return self.message.format(url=self.url, content=self.content)
# 
#     def __unicode__(self):
#         return self.__str__()


# Path: salesforce/login.py
from .api import DEFAULT_API_VERSION
from .util import getUniqueElementValueFromXmlString
from .util import SalesforceError
    from html import escape
    from cgi import escape
    from SalesforceXyTools import requests
    import requests

                </urn:CallOptions>
            </soapenv:Header>
            <soapenv:Body>
                <urn:login>
                    <urn:username>{username}</urn:username>
                    <urn:password>{password}</urn:password>
                </urn:login>
            </soapenv:Body>
        </soapenv:Envelope>""".format(
            username=username, password=password, client_id=client_id)
    else:
        except_code = 'INVALID AUTH'
        except_msg = (
            'You must submit either a security token or organizationId for '
            'authentication'
        )
        raise SalesforceAuthenticationFailed(except_code, except_msg)

    login_soap_request_headers = {
        'content-type': 'text/xml',
        'charset': 'UTF-8',
        'SOAPAction': 'login'
    }
    response = (session or requests).post(
        soap_url, login_soap_request_body, headers=login_soap_request_headers,verify=False, 
        proxies=proxies)

    if response.status_code != 200:
        except_code = getUniqueElementValueFromXmlString(
            response.content, 'sf:exceptionCode')

        except_msg = getUniqueElementValueFromXmlString(