fix creation of sub-resources

master
Marek Isalski 2 years ago
parent 142a757ffa
commit 2e1c368f53

@ -378,44 +378,49 @@ class OutgoingCallerId(APIObject):
TYPE = "outgoingcallerid" TYPE = "outgoingcallerid"
class CreditStatus(APIObject): class CustomerAPIObject(APIObject):
MANDATORY_FIELDS = ()
def create(self, parent, **kwargs):
if self._data:
self._data.update(**kwargs)
else:
self._data = kwargs
for k in self.__class__.MANDATORY_FIELDS:
if k not in self._data:
raise ValueError('missing mandatory field "%s"' % k)
return self._create(parent=parent, data=self._data)
class CreditStatus(CustomerAPIObject):
URLPART = "creditstatus" URLPART = "creditstatus"
TYPE = "creditstatus" TYPE = "creditstatus"
class CustomerPricing(APIObject): class CustomerPricing(CustomerAPIObject):
URLPART = "pricing" URLPART = "pricing"
TYPE = "customerpricing" TYPE = "customerpricing"
class Limits(APIObject): class Limits(CustomerAPIObject):
URLPART = "limits" URLPART = "limits"
TYPE = "customerlimits" TYPE = "customerlimits"
class CallCharging(APIObject): class CallCharging(CustomerAPIObject):
URLPART = "callcharging" URLPART = "callcharging"
TYPE = "customercallcharging" TYPE = "customercallcharging"
class Permissions(APIObject): class Permissions(CustomerAPIObject):
URLPART = "permissions" URLPART = "permissions"
TYPE = "customerpermissions" TYPE = "customerpermissions"
class LinkedUser(APIObject): class LinkedUser(CustomerAPIObject):
URLPART = "linkedusers" URLPART = "linkedusers"
TYPE = "linkeduser" TYPE = "linkeduser"
MANDATORY_FIELDS = ("activateUrl", "email", "recordingAccess", "owner", "enabled")
def create(self, parent, **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)
return self._create(parent=parent, data=self._data)
class Sms(APIObject): class Sms(APIObject):

Loading…
Cancel
Save