Esempio n. 1
0
    def __getattr__(self, name):
        if RESULTS_MODELS.get(name, None):
            value = self.json_data.get(name, None) or self.json_data.get("results", {}).get(name, None)
            if value:
                return RESULTS_MODELS[name](value)

        try:
            return self.json_data[name]
        except KeyError:
            raise AttributeError('Attribute "%s" was not found in the response' % name)
Esempio n. 2
0
 def _return_as_model(self, item):
     model = RESULTS_MODELS.get(item.keys()[0], None)
     return model(item[item.keys()[0]]) if model and isinstance(item, dict) else item