CampaignSerializer

class apirest.campaign_serializers.CampaignSerializer(instance=None, data=<class rest_framework.fields.empty>, **kwargs)

Create:

CURL Usage:

curl -u username:password --dump-header - -H "Content-Type:application/json" -X POST --data '{"name": "mycampaign01", "description": "", "callerid": "1239876", "startingdate": "2017-01-01 13:13:33", "expirationdate": "2017-06-14 13:13:33", "frequency": "10", "max_aleg":28, "max_xfer":12, "dial_method":2, "agent_dial_rate":1.2, "callmaxduration": "50", "maxretry": "3", "intervalretry": "3000", "calltimeout": "45", "aleg_gateway": "/rest-api/gateway/2/", "sms_gateway": "", "content_type": "/rest-api/content-type/42/", "object_id" : "101", "extra_data": "2000", "voicemail": "True", "amd_behavior": "1", "voicemail_audiofile": "", "dnc": "", "user": "/rest-api/users/1/", "phonebook": ["/rest-api/phonebook/1/"], "daily_start_time": "00:00:00", "daily_stop_time": "23:59:59"}' http://HOSTNAME_IP/rest-api/campaigns/

Response:

HTTP/1.0 201 CREATED
Date: Fri, 14 Jun 2013 09:52:27 GMT
Server: WSGIServer/0.1 Python/2.7.3
Vary: Accept, Accept-Language, Cookie
Content-Type: application/json; charset=utf-8
Content-Language: en-us
Allow: GET, POST, HEAD, OPTIONS

{"id": 1, "campaign_code": "JDQBG", "name": "mycampaign1", "description": "", "callerid": "1239876", "phonebook": ["/rest-api/phonebook/1/", "/rest-api/phonebook/2/"], "startingdate": "2016-01-13T13:13:33", "expirationdate": "2016-01-14T13:13:33", "aleg_gateway": "http://HOSTNAME_IP/rest-api/gateway/1/", "user": "http://<IP-HOST>/rest-api/users/1/", "status": 2, "content_type": "http://<IP-HOST>/rest-api/content-type/49/", "object_id": 1, "extra_data": "2000", "dnc": null, "frequency": 20, "callmaxduration": 50, "maxretry": 3, "intervalretry": 3000, "calltimeout": 45, "daily_start_time": "00:00:00", "daily_stop_time": "23:59:59", "monday": true, "tuesday": true, "wednesday": true, "thursday": true, "friday": true, "saturday": true, "sunday": true, "completion_enabled": true}

Read:

CURL Usage:

curl -u areski:areski -H 'Accept: application/json' http://127.0.0.1:8000/rest-api/campaigns/

curl -u username:password -H 'Accept: application/json' http://HOSTNAME_IP/rest-api/campaigns/%campaign-id%/

Response:

{
    "count": 1,
    "next": null,
    "previous": null,
    "results": [
        {
            "id": 2,
            "campaign_code": "TANCW",
            "name": "TestCampaign",
            "description": null,
            "callerid": "123234242",
            "phonebook": [
                    "http://HOSTNAME_IP/rest-api/phonebook/1/"
            ],
            "startingdate": "2017-02-23T16:17:14+01:00",
            "expirationdate": "2017-02-24T16:17:14+01:00",
            "aleg_gateway": "http://HOSTNAME_IP/rest-api/gateway/1/",
            "user": "http://HOSTNAME_IP/rest-api/users/1/",
            "status": 4,
            "content_type": "http://HOSTNAME_IP/rest-api/content-type/49/",
            "object_id": 1,
            "extra_data": "",
            "dnc": "http://HOSTNAME_IP/rest-api/dnc/1/",
            "voicemail": false,
            "amd_behavior": 1,
            "voicemail_audiofile": null,
            "voicemail_tts": null,
            "frequency": 10,
            "max_aleg": 0,
            "max_xfer": 0,
            "dial_method": 1,
            "agent_dial_rate": "1.00",
            "callmaxduration": 1800,
            "maxretry": 0,
            "intervalretry": 300,
            "calltimeout": 45,
            "daily_start_time": "00:00:00",
            "daily_stop_time": "23:59:59",
            "monday": true,
            "tuesday": true,
            "wednesday": true,
            "thursday": true,
            "friday": true,
            "saturday": true,
            "sunday": true,
            "completion_enabled": false,
            "sms_gateway": "http:\/\/127.0.0.1:8000\/rest-api\/sms-gateway\/2\/",
            "record_bleg": false,
            "record_call": false,
            "timezone_dialing": false,
            "archived": false,
            "tts_language": "en",
            "total_transfer": 0,
            "total_dial": 0,
            "total_redial": 0,
            "total_dnc": 0,
            "total_unauth": 0,
            "unavailable_audiofile": null,
            "route_type": 1,
            "route_audiofile": null,
            "route_tts": null,
            "xfer_gateway": null,
            "xfer_phonenumber": null,
            "has_been_started": false,
            "has_been_duplicated": false,
            "duplicated_from": null
        }
    ]
}

Update:

CURL Usage:

curl -u username:password --dump-header - -H "Content-Type: application/json" -X PATCH --data '{"name": "mylittlecampaign243"}' http://HOSTNAME_IP/rest-api/campaigns/%campaign-id%/

Response:

HTTP/1.0 202 NO CONTENT
Date: Fri, 23 Sep 2011 06:46:12 GMT
Server: WSGIServer/0.1 Python/2.7.1+
Vary: Accept-Language, Cookie
Content-Length: 0
Content-Type: text/html; charset=utf-8
Content-Language: en-us

{"id": 1, "campaign_code": "JDQBG", "name": "mylittlecampaign243", "description": "", "callerid": "1239876", "phonebook": ["http://HOSTNAME_IP/rest-api/phonebook/1/", "http://<IP-HOST>/rest-api/phonebook/2/"], "startingdate": "2016-01-13T13:13:33", "expirationdate": "2016-01-14T13:13:33", "aleg_gateway": "http://<IP-HOST>/rest-api/gateway/1/", "user": "http://<IP-HOST>/rest-api/users/1/", "status": 2, "content_type": "http://<IP-HOST>/rest-api/content-type/67/", "object_id": 1, "extra_data": "2000", "dnc": null, "frequency": 20, "max_aleg":50,"max_xfer":5,"dial_method":2,"agent_dial_rate":3.6, "callmaxduration": 50, "maxretry": 3, "intervalretry": 3000, "calltimeout": 45, "daily_start_time": "00:00:00", "daily_stop_time": "23:59:59", "monday": true, "tuesday": true, "wednesday": true, "thursday": true, "friday": true, "saturday": true, "sunday": true, "completion_enabled": false}

CURL Usage (Update Campaign Status==Started):

curl -u username:password --dump-header - -H "Content-Type: application/json" -X PATCH --data '{"status": 1}' http://HOSTNAME_IP/rest-api/campaigns/%campaign-id%/

Delete:

CURL Usage:

curl -u username:password --dump-header - -H "Content-Type: application/json" -X DELETE  http://HOSTNAME_IP/rest-api/campaign/%campaign_id%/

Response:

{
    "data": "campaign deleted"
}