don't get before set

master
Marek Isalski 3 years ago
parent 6fe93923d7
commit d18c3c11d8

@ -159,7 +159,10 @@ class APIObject(object):
raise ValueError(
"%s ID %d already created" % (self.__class__.__name__, self.id)
)
self.data.update(**kwargs)
if self._data:
self._data.update(**kwargs)
else:
self._data = kwargs
if not self._data:
raise ValueError("No data associated with record.")
return self._create(parent=parent,data=self._data)
@ -277,7 +280,10 @@ class Customer(APIObject):
def create(self, parent=None, **kwargs):
if parent:
raise ValueError("Customer cannot have a parent")
self.data.update(**kwargs)
if self._data:
self._data.update(**kwargs)
else:
self._data = kwargs
for k in ("accountType", "company", "firstName", "lastName", "email", "address1", "city", "postcode", "telephone"):
if k not in self._data:
raise ValueError('missing mandatory field "%s"' % k)
@ -330,38 +336,47 @@ class MailboxEndpoint(Endpoint):
class PhoneNumber(APIObject):
URLPART = "phonenumbers"
TYPE = "did"
class Call(APIObject):
URLPART = "calls"
TYPE = "call"
class CallBundle(APIObject):
URLPART = "callbundles"
TYPE = "customerbundle"
class Recording(APIObject):
URLPART = "recordings"
TYPE = "recording"
class PhoneBook(APIObject):
URLPART = "phonebook"
TYPE = "phonebookentry"
class TimeInterval(APIObject):
URLPART = "timeintervals"
TYPE = "XXX"
class Sound(APIObject):
URLPART = "sounds"
TYPE = "music"
class OutgoingCallerId(APIObject):
URLPART = "outgoingcallerids"
TYPE = "outgoingcallerid"
class CreditStatus(APIObject):
URLPART = "creditstatus"
TYPE = "XXX"
class LinkedUser(APIObject):
@ -369,7 +384,10 @@ class LinkedUser(APIObject):
TYPE = "linkeduser"
def create(self, parent, **kwargs):
self.data.update(**kwargs)
if self._data:
self._data.update(**kwargs)
else:
self._data = kwargs
for k in ("activateUrl", "email", "recordingAccess", "owner", "enabled"):
if k not in self._data:
raise ValueError('missing mandatory field "%s"' % k)
@ -378,6 +396,7 @@ class LinkedUser(APIObject):
class Sms(APIObject):
URLPART = "sms"
TYPE = "smsmessage"
# def post(self, to=None, _from=None, body=None):
# data = {"type": "smsmessage", "to": to, "from": _from, "body": body}

Loading…
Cancel
Save