Retrieve HTTP resources, return related objects (with pagination)

def _retrieve_resources(self, url, class_, full):
        '''Retrieve HTTP resources, return related objects (with pagination)'''
        objects_to_return = []
        response = self.session.get(url)
        if response.status_code == 200:
            result = response.json()
            resources = result['results']
            objects_to_return.extend([class_(session=self.session, **resource)
                                      for resource in resources])
            while full and result['next'] is not None:
                response = self.session.get(result['next'])
                if response.status_code == 200:
                    result = response.json()
                    resources = result['results']
                    objects_to_return.extend([class_(session=self.session,
                                                     **resource)
                                              for resource in resources])
                else:
                    raise RuntimeError("Failed downloading data with status {}"
                            ". The response was: '{}'"
                            .format(response.status_code, response.text))
            return objects_to_return
        else:
            raise RuntimeError("Failed downloading data with status {}"
                    ". The response was: '{}'"
                    .format(response.status_code, response.text))