fix fetching sub-resources

master
Marek Isalski 2 years ago
parent 2e1c368f53
commit e0ab8168e9

@ -281,6 +281,15 @@ class Customer(APIObject):
for c in self._api.getMany(LinkedUser.makeUrl(parent=self)):
yield LinkedUser(self._api, data=c)
def limits(self):
return Limits(self._api, self._api.get(Limits.makeUrl(parent=self))
def callcharging(self):
return CallCharging(self._api, self._api.get(CallCharging.makeUrl(parent=self))
def permissions(self):
return Permissions(self._api, self._api.get(Permissions.makeUrl(parent=self))
def create(self, parent=None, **kwargs):
if parent:
raise ValueError("Customer cannot have a parent")
@ -378,45 +387,45 @@ class OutgoingCallerId(APIObject):
TYPE = "outgoingcallerid"
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):
class CreditStatus(APIObject):
URLPART = "creditstatus"
TYPE = "creditstatus"
class CustomerPricing(CustomerAPIObject):
class Pricing(APIObject):
URLPART = "pricing"
TYPE = "customerpricing"
class Limits(CustomerAPIObject):
class Limits(APIObject):
URLPART = "limits"
TYPE = "customerlimits"
class CallCharging(CustomerAPIObject):
class CallCharging(APIObject):
URLPART = "callcharging"
TYPE = "customercallcharging"
class Permissions(CustomerAPIObject):
class Permissions(APIObject):
URLPART = "permissions"
TYPE = "customerpermissions"
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 LinkedUser(CustomerAPIObject):
URLPART = "linkedusers"
TYPE = "linkeduser"

Loading…
Cancel
Save