CampaignSerializer

class apirest.campaign_serializers.CampaignSerializer(instance=None, data=None, files=None, context=None, partial=False, many=False, allow_add_remove=False, **kwargs)

Create:

CURL Usage:

curl -u username:password --dump-header - -H "Content-Type:application/json" -X POST --data '{"name": "mycampaign", "description": "", "callerid": "1239876", "startingdate": "2013-06-13 13:13:33", "expirationdate": "2013-06-14 13:13:33", "frequency": "20", "callmaxduration": "50", "maxretry": "3", "intervalretry": "3000", "calltimeout": "45", "aleg_gateway": "/rest-api/gateway/1/", "sms_gateway": "/rest-api/sms-gateway/1/", "content_type": "/rest-api/content-type/49/", "object_id" : "1", "extra_data": "2000", "voicemail": "True", "amd_behavior": "1", "voicemail_audiofile": "1", "dnc": "/rest-api/dnc/1/", "phonebook": "1"}' http://localhost:8000/rest-api/campaigns/

CURL Usage (2nd):

curl -u username:password --dump-header - -H "Content-Type:application/json" -X POST --data '{"name": "mycampaign-a02", "description": "", "callerid": "1239876", "startingdate": "2014-10-21 13:13:33", "expirationdate": "2014-11-14 13:13:33", "frequency": "20", "callmaxduration": "50", "maxretry": "3", "intervalretry": "3000", "calltimeout": "45", "aleg_gateway": "/rest-api/gateway/1/", "sms_gateway": "/rest-api/sms-gateway/1/", "content_type": "/rest-api/content-type/66/", "object_id" : "7", "extra_data": "2000", "phonebook": "1", "status": 4}' http://localhost:8000/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": "2013-06-13T13:13:33", "expirationdate": "2013-06-14T13:13:33", "aleg_gateway": "http://localhost:8000/rest-api/gateway/1/", "user": "http://localhost:8000/rest-api/users/1/", "status": 2, "content_type": "http://localhost:8000/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_maxretry": 0, "completion_intervalretry": 900}

Read:

CURL Usage:

curl -u username:password -H 'Accept: application/json' http://localhost:8000/rest-api/campaigns/

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

Response:

{
    "count": 1,
    "next": null,
    "previous": null,
    "results": [
        {
            "id": 2,
            "campaign_code": "BXTWX",
            "name": "Sample survey campaign",
            "description": "",
            "callerid": "",
            "phonebook": [
                "http://127.0.0.1:8000/rest-api/phonebook/1/"
            ],
            "startingdate": "2011-12-27T14:35:46",
            "expirationdate": "2011-12-28T14:35:46",
            "aleg_gateway": "http://127.0.0.1:8000/rest-api/gateway/1/",
            "user": "http://127.0.0.1:8000/rest-api/users/1/",
            "status": 2,
            "content_type": "http://127.0.0.1:8000/rest-api/content-type/49/",
            "object_id": 1,
            "extra_data": "",
            "dnc": "http://127.0.0.1:8000/rest-api/dnc/1/",
            "voicemail": false,
            "amd_behavior": null,
            "voicemail_audiofile": null,
            "frequency": 10,
            "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_maxretry": 0,
            "completion_intervalretry": 900
        }
    ]
}

Update:

CURL Usage:

curl -u username:password --dump-header - -H "Content-Type: application/json" -X PATCH --data '{"name": "mylittlecampaign243"}' http://localhost:8000/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://localhost:8000/rest-api/phonebook/1/", "http://localhost:8000/rest-api/phonebook/2/"], "startingdate": "2013-06-13T13:13:33", "expirationdate": "2013-06-14T13:13:33", "aleg_gateway": "http://localhost:8000/rest-api/gateway/1/", "user": "http://localhost:8000/rest-api/users/1/", "status": 2, "content_type": "http://localhost:8000/rest-api/content-type/67/", "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_maxretry": 0, "completion_intervalretry": 900}

CURL Usage (Update Campaign Status==Started):

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

Delete:

CURL Usage:

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

Response:

{
    "data": "campaign deleted"
}
get_fields(*args, **kwargs)

filter content_type field

validate(attrs)

Validate campaign form