SubscriberListSerializer

class apirest.subscriber_list_serializers.SubscriberListSerializer(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 '{"contact": "/rest-api/contact/2/", "campaign": "/rest-api/campaigns/170/", "status": 1, "full_name": "Joe", "additional_vars": "{"transfer_number": "0000001"}"}' http://HOSTNAME_IP/rest-api/subscriber-list/

You can also create a subscriber without contact, just remove the contact field in the curl command above.

Example:

curl -u username:password --dump-header - -H "Content-Type:application/json" -X POST --data '{"campaign": "/rest-api/campaigns/236/", "status": 1, "duplicate_contact": "+1750784300", "full_name": "Joe", "additional_vars": "{"transfer_number": "0000001"}"}' http://127.0.0.1:8000/rest-api/subscriber-list/

Response:

HTTP/1.0 201 Created
Content-Language: en
Vary: Accept, Accept-Language, Cookie
Location: http://127.0.0.1:8000/rest-api/subscriber-list/2978082/
Allow: GET, POST, HEAD, OPTIONS
X-Frame-Options: SAMEORIGIN
Content-Type: application/json
Connection: close
Server: Werkzeug/0.12.2 Python/2.7.9
Date: Thu, 09 Nov 2017 12:29:30 GMT

{
    "url": "http:\/\/127.0.0.1:8000\/rest-api\/subscriber-list\/2978082\/",
    "contact": "http:\/\/127.0.0.1:8000\/rest-api\/contact\/4\/",
    "campaign": "http:\/\/127.0.0.1:8000\/rest-api\/campaigns\/170\/",
    "last_attempt": null,
    "count_attempt": 0,
    "status": 1,
    "duplicate_contact": "+34650784355",
    "full_name": "Areski Belaid",
    "gmt_offset": "0.00",
    "tz_code": "WET",
    "additional_vars": {
        "transfer_number": "0000001"
    }
}

Read:

CURL Usage:

curl -u username:password -H 'Accept: application/json' http://HOSTNAME_IP/rest-api/subscriber-list/

Response:

[
    {
        "id": 1,
        "contact": "/rest-api/contact/11/",
        "campaign": "/rest-api/campaigns/3/",
        "last_attempt": null,
        "count_attempt": 0,
        "duplicate_contact": "34235464",
        "status": 1
    },
    {
        "id": 2,
        "contact": "/rest-api/contact/12/",
        "campaign": "/rest-api/campaigns/3/",
        "last_attempt": null,
        "count_attempt": 0,
        "duplicate_contact": "34235464",
        "status": 1
    }
]

Delete:

CURL Usage:

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

Response:

{
    "data": "subscriber deleted"
}