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

Loading…
Cancel
Save