-
Notifications
You must be signed in to change notification settings - Fork 76
/
custom_records.py
73 lines (63 loc) · 1.85 KB
/
custom_records.py
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
from collections import OrderedDict
from .base import ApiBase
import logging
logger = logging.getLogger(__name__)
class CustomRecords(ApiBase):
SIMPLE_FIELDS = [
'allowAttachments',
'allowInlineEditing',
'allowNumberingOverride',
'allowQuickSearch',
'altName',
'autoName',
'created',
'customFieldList',
'customRecordId',
'description',
'disclaimer',
'enablEmailMerge',
'enableNumbering',
'includeName',
'internalId',
'isAvailableOffline',
'isInactive',
'isNumberingUpdateable',
'isOrdered',
'lastModified',
'name',
'numberingCurrentNumber',
'numberingInit',
'numberingMinDigits',
'numberingPrefix',
'numberingSuffix',
'recordName',
'scriptId',
'showCreationDate',
'showCreationDateOnList',
'showId',
'showLastModified',
'showLastModifiedOnList',
'showNotes',
'showOwner',
'showOwnerAllowChange',
'showOwnerOnList',
'translationsList',
'usePermissions',
'nullFieldList',
]
RECORD_REF_FIELDS = [
'customForm',
'owner',
'parent',
'recType',
]
def __init__(self, ns_client):
ApiBase.__init__(self, ns_client=ns_client, type_name='CustomRecord')
def post(self, data) -> OrderedDict:
assert data['externalId'], 'missing external id'
record = self.ns_client.CustomRecord(externalId=data['externalId'])
self.build_simple_fields(self.SIMPLE_FIELDS, data, record)
self.build_record_ref_fields(self.RECORD_REF_FIELDS, data, record)
logger.debug('able to create custom record = %s', record)
res = self.ns_client.upsert(record)
return self._serialize(res)