.. _call_survey:
===========
Call Survey
===========
.. contents::
   :local:
   :depth: 3
Overview
--------
This web service allows the app to post the call quality survey based on the quality parameter selected by the user.
Parameters
----------
Parameter templates for Call Survey can use any variables from :ref:`global-params` and :ref:`account-params`
scopes. There are three service-specific parameters defined for call survey.
``callId``
~~~~~~~~~~
    Contains the unique identifier for the call, whose survey report is being posted.
``stars``
~~~~~~~~~
    Contains the quality parameter ranging from 1-5, 1 being the lowest and 5 as best quality.
``customMessage``
~~~~~~~~~~~~~~~~~
    Contains the message from the user about improvement or suggestion.
Configuration
-------------
The following preference keys are relevant for call survey configuration:
``callSurveyUrl``
~~~~~~~~~~~~~~~~~
    Contains the URL, including URL scheme, of the web service, possibly also with query string.
    Example:
    .. code-block:: xml
        https://example.com/callSurvey
``callSurveyMethod``
~~~~~~~~~~~~~~~~~~~~
    Contains the HTTP Method (Get/Post). Call Survey web service uses POST as the Method.
    Example:
    .. code-block:: xml
        POST
``callSurveyPostData``
~~~~~~~~~~~~~~~~~~~~~~
    Call Survey webservice require the call quality information, the Post Data includes call Identifier, Call Quality Param and Custom Message for Improvement
    Example ( for  application/x-www-form-urlencoded):
    .. code-block:: xml
        callId=%callId%&stars=%stars%&customMessage=%customMessage%
``callSurveyContentType``
~~~~~~~~~~~~~~~~~~~~~~~~~
    Specifies the value of Content-Type header to be sent in the request. If not specified, the app will default to
    ``application/x-www-form-urlencoded``
``callSurveyCustomHeaders``
~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Specify custom headers to be added into request.
``callSurveyAuthUsername``
~~~~~~~~~~~~~~~~~~~~~~~~~~
    If the Service is accessible from behind the proxy, you can configure the user name for the Call Survey Service via configuring callSurveyAuthUsername.
    Example:
    .. code-block:: xml
        %AuthUserName%
``callSurveyAuthPassword``
~~~~~~~~~~~~~~~~~~~~~~~~~~
    If the Service is accessible from behind the proxy, you can configure the password for the Call Survey Service via configuring callSurveyAuthPassword.
    Example:
    .. code-block:: xml
        %AuthUserName%
``callSurveyTimeout``
~~~~~~~~~~~~~~~~~~~~~~~~~~
    The default timeout for the Service is 30seconds, but if you want to configure you custom timeout you can do so by setting the value in seconds for callSurveyTimeout.
    Example:
    .. code-block:: xml
        20
Response
--------
    The response will be considered successful if the HTTP response code is 2xx. Any responses which have other
    response code, or whose body can't be parsed, are erroneous response.
Examples
--------
POST method
~~~~~~~~~~~
request:
 .. code-block:: http
    POST /callSurvey/?callId=234242342342&stars=5&customMessage=Thanks HTTP/1.1
    Host: example.com
    Connection: close
    Cache-Control: max-age=0
    User-Agent: CloudSoftphone/1.5.6
response:
 .. code-block:: http
    HTTP/1.1 200 OK
    Date: Sun, 15 Mar 2015 00:46:17 GMT
    Server: Apache/2.4.7 (Ubuntu)
    Vary: Accept-Encoding
    Content-Encoding: gzip
    Content-Length: 183
    Keep-Alive: timeout=5, max=100
    Connection: Keep-Alive
    Content-Type: text/xml