Code Monkey home page Code Monkey logo

python-five9's Introduction

License: MIT | PyPi Package | PyPi Versions

Build Status | Test Coverage | Code Climate

Python Five9

This library allows you to interact with the Five9 Settings and Statistics Web Services using Python.

Installation

Installation is easiest using Pip and PyPi:

pip install five9

If you would like to contribute, or prefer Git:

git clone https://github.com/LasLabs/python-five9.git
cd python-five9
pip install -r requirements.txt
pip install .

Usage

Connect

from five9 import Five9

client = Five9('user', 'password')

Configuration Web Services

Documentation:

Example - Get All Skills:

client.configuration.getSkills()
# Returns
[{
    'description': None,
    'id': 266184L,
    'messageOfTheDay': None,
    'name': 'TestSkill',
    'routeVoiceMails': False
}]

Example - Create a contact field to track modified time:

client.configuration.createContactField({
    'name': 'modified_at',
    'displayAs': 'Invisible',
    'mapTo': 'LastModifiedDateTime',
    'type': 'DATE_TIME',
    'system': True,
})

Example - Search for a contact by first and last name and get a list of ``dict``s representing the result:

criteria = client.create_criteria({
    'first_name': 'Test',
    'last_name': 'User',
})
result = client.configuration.getContactRecords(criteria)
# The above result is basically unusable. Parse into a list of dicts::
client.parse_response(result['fields'], result['records'])

Example - Update a contact using their first and last name as the search keys:

contact = {
    'first_name': 'Test',
    'last_name': 'User',
    'city': 'Las Vegas',
    'state': 'NV',
    'number1': '1234567890',
}
mapping = client.create_mapping(contact, keys=['first_name', 'last_name'])
client.configuration.updateCrmRecord(
    record={'fields': mapping['fields']},
    crmUpdateSettings={
        'fieldsMapping': mapping['field_mappings'],
        'skipHeaderLine': True,
        'crmAddMode': 'DONT_ADD',
        'crmUpdateMode': 'UPDATE_SOLE_MATCHES',
    }
)

Statistics Web Services

Documentation:

A supervisor session is required in order to perform most actions provided in the Supervisor Web Service. Due to this, a session is implicitly created before the supervisor is used.

The session is created with the following defaults. You can change the parameters by changing the proper instance variable on the Five9 object:

Five9 Parameter Instance Variable Default
forceLogoutSession force_logout_session True
rollingPeriod rolling_period Minutes30
statisticsRange statistics_range CurrentWeek
shiftStart shift_start_hour 8
timeZone time_zone_offset -7

Example Use:

# Setup a session - required for most things
client.supervisor.getUserLimits()
# Returns
{
    'mobileLimit': 0L,
    'mobileLoggedin': 0L,
    'supervisorLimit': 1L,
    'supervisorsLoggedin': 1L
}

Known Issues / Roadmap

  • The supervisor session options should be represented in a class and documented, instead of the mostly undocumented free-form dictionary mapped to instance variables.

Credits

Images

Contributors

Maintainer

LasLabs Inc.

This module is maintained by LasLabs Inc.

python-five9's People

Contributors

lasley avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

python-five9's Issues

getting TransportError error in one of the report when running this five9_client.configuration.getReportResult(identifier)

TransportError: Server returned response (200) with invalid XML: Invalid XML content received (Premature end of data in tag data line 1, line 1, column 92595).
Content: b'<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">env:Header/env:Body<ns2:getReportResultResponse xmlns:ns2="http://service.admin.ws.five9.com/">

DATEDATE AND HOURDAY OF MONTHDAY OF WEEK ................................ so on

Get specific columns from statistics api

Using this to pull ACD Status data:
result = client.supervisor.getStatistics('ACDStatus')

The result returns 14 columns and i only need 2 columns. The way the docs read I thought I could do something like this but the result is always 14 columns:
result = client.supervisor.getStatistics('ACDStatus', ['Skill Name', 'Agents Logged In'])

Is there a way to just grab the data from the specified columns?

Invalid XML error

I keep getting this error when I try to call any of the methods on the client:

  File "app.py", line 6, in <module>
    print client.supervisor.getUserLimits()
  File "/Users/araza/pyfive9/env/lib/python2.7/site-packages/five9/five9.py", line 58, in supervisor
    supervisor,
  File "/Users/araza/pyfive9/env/lib/python2.7/site-packages/five9/five9.py", line 221, in __create_supervisor_session
    supervisor.setSessionParameters(session_params)
  File "/Users/araza/pyfive9/env/lib/python2.7/site-packages/zeep/proxy.py", line 42, in __call__
    self._op_name, args, kwargs)
  File "/Users/araza/pyfive9/env/lib/python2.7/site-packages/zeep/wsdl/bindings/soap.py", line 126, in send
    return self.process_reply(client, operation_obj, response)
  File "/Users/araza/pyfive9/env/lib/python2.7/site-packages/zeep/wsdl/bindings/soap.py", line 170, in process_reply
    content=response.content)
zeep.exceptions.TransportError: Server returned response (401) with invalid XML: Invalid XML content received (Opening and ending tag mismatch: HR line 1 and body, line 1, column 1038).
Content: '<html><head><title>JBoss Web/7.5.3.Final - JBWEB000064: Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>JBWEB000065: HTTP Status 401 - </h1><HR size="1" noshade="noshade"><p><b>JBWEB000309: type</b> JBWEB000067: Status report</p><p><b>JBWEB000068: message</b> <u></u></p><p><b>JBWEB000069: description</b> <u>JBWEB000121: This request requires HTTP authentication.</u></p><HR size="1" noshade="noshade"><h3>JBoss Web/7.5.3.Final</h3></body></html>'

Any one had any luck using this?

Five9 Python Library Failing to Connect to www.ws-i.org

While using the Five9 Python library to call the Five9 API. The API call is failing trying to connect to www.ws-i.org.

Error Message -
requests.exceptions.ConnectionError: HTTPConnectionPool(host='ws-i.org', port=80): Max retries exceeded with url: /profiles/basic/1.1/swaref.xsd (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x00000152AAA8D0C0>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it'))

Cannot Import Five9

I'm stuck on the very first step. I installed using pip. As soon as I try to run from five9 import Five9, I get the following error:
image

'cannot import name five9'

Please help. If I can get this to work, good things will happen for me at my job.

Is there a way to download WAV files?

I want to be able to download wav files that are listed under the Recordings section of a report. In the report output from the SDK, under the Recordings section, I get a string with the duration of the recording and not the recording itself (eg: 06:33:49(0:35)). Is there a way to actually get the wav files for the recordings? I see a method named addPromptWavInline, but it's request and response parameters are not very well documented. Thanks in advance.

createOutboundCampaign returns error

When running class AdminWebService.createOutboundCampaign as follows:

client.configuration.createOutboundCampaign({'name': 'Test'})

I get the following error:

zeep.exceptions.Fault: "prompt for queue timeout" is required, but is "null"

I've tested with various variables, including prompt, maxQueueTime, callWrapup, dialNumberOnTimeout. Unfortunately none of these seem to be the variable that Five9 is looking for.

I'm unable to find this missing value in any documentation related to this project or Five9's documentation - at this point I'm stumped how to get around it.

Suggestion for large XML

I put in a fix to handle large XML, else you get a "Invalid XML content received... huge text node" with the current lxml library. I overrode Class(Five9). I don't think it has consequences except buffer overflow attacks from Five9 (CVE-2008-4226).

class Five9_BigXML(Five9):
     def _get_authenticated_client(self, wsdl):
        """Return an authenticated SOAP client.

        Returns:
            zeep.Client: Authenticated API client.
        """
        return zeep.Client(
            wsdl % quote(self.username),
            transport=zeep.Transport(
                session=self._get_authenticated_session(),
            ),
            settings=zeep.Settings(xml_huge_tree=True)
        )

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.