def total(self):
     if self._total_count is None:
         raise FacebookUnavailablePropertyException(
             "Couldn't retrieve the object total count for that type "
             "of request.",
         )
     return self._total_count
Exemple #2
0
    def load(self):
        if self._response is None:
            raise FacebookUnavailablePropertyException(
                "Couldn't retrieve the response for this request")

        params = copy.deepcopy(self._params)
        if self._response.error():
            raise self._response.error()
        elif self._api_type == "EDGE" and self._method == "GET":
            response = self._response.json()
            cursor = Cursor(
                target_objects_class=self._target_class,
                params=params,
                fields=self._fields,
                include_summary=self._include_summary,
                api=self._api,
                node_id=self._node_id,
                endpoint=self._endpoint,
            )

            if 'paging' in response and 'next' in response['paging']:
                cursor._path = response['paging']['next']
            else:
                cursor._finished_iteration = True

            if (cursor._include_summary and 'summary' in response
                    and 'total_count' in response['summary']):
                cursor._total_count = response['summary']['total_count']

            cursor._queue = cursor.build_objects_from_response(response)
            return cursor
        elif self._response_parser:
            return self._response_parser.parse_single(self._response.json())
        else:
            return self._response.json()