-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathcontact.py
More file actions
41 lines (33 loc) · 1.49 KB
/
contact.py
File metadata and controls
41 lines (33 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from marshmallow import Schema, fields, post_load, EXCLUDE
from ..resource import Resource
from collections import namedtuple
class Contact(Resource):
"""
https://dev.chartmogul.com/v1.0/reference#contacts
"""
_path = "/contacts{/uuid}"
_root_key = "entries"
_many = namedtuple("Contacts", [_root_key, "has_more", "cursor"])
class _Schema(Schema):
uuid = fields.String()
customer_uuid = fields.String(allow_none=True)
data_source_uuid = fields.String(allow_none=True)
customer_external_id = fields.String(allow_none=True)
first_name = fields.String(allow_none=True)
last_name = fields.String(allow_none=True)
position = fields.Int(allow_none=True)
email = fields.String(allow_none=True)
title = fields.String(allow_none=True)
notes = fields.String(allow_none=True)
phone = fields.String(allow_none=True)
linked_in = fields.String(allow_none=True)
twitter = fields.String(allow_none=True)
# load_default=None ensures this attribute is always present on the Contact
# object even when the API omits the field (e.g. older responses)
external_id = fields.String(allow_none=True, load_default=None)
custom = fields.Dict(allow_none=True)
@post_load
def make(self, data, **kwargs):
return Contact(**data)
_schema = _Schema(unknown=EXCLUDE)
Contact.merge = Contact._method("merge", "post", "/contacts/{into_uuid}/merge/{from_uuid}")