from .base import Base


class List(Base):
    current = None

    def __init__(self, result, object_type):
        Base.__init__(self, result)
        self.object_type = object_type

    def get_object_name(self):
        return self.object_type.__name__.lower() + 's'

    def __iter__(self):
        """Implement iterator logic."""
        self.current = None
        return self

    def __next__(self):
        """Implement iterator logic."""
        if self.current is None:
            self.current = 0
        else:
            self.current += 1
        try:
            item = self['_embedded'][self.get_object_name()][self.current]
            return self.object_type(item)
        except IndexError:
            raise StopIteration

    @property
    def count(self):
        if 'count' not in self:
            return None
        return int(self['count'])

    def get_offset(self):
        if 'offset' not in self:
            return None
        return self['offset']

from .base import Base


class List(Base):
    current = None

    def __init__(self, result, object_type):
        Base.__init__(self, result)
        self.object_type = object_type

    def get_object_name(self):
        return self.object_type.__name__.lower() + 's'

    def __iter__(self):
        """Implement iterator logic."""
        self.current = None
        return self

    def __next__(self):
        """Implement iterator logic."""
        if self.current is None:
            self.current = 0
        else:
            self.current += 1
        try:
            item = self['_embedded'][self.get_object_name()][self.current]
            return self.object_type(item)
        except IndexError:
            raise StopIteration

    next = __next__  # support python2 iterator interface

    @property
    def count(self):
        if 'count' not in self:
            return None
        return int(self['count'])

    def get_offset(self):
        if 'offset' not in self:
            return None
        return self['offset']

Add proxy method for python2 iterator support
Add proxy method for python2 iterator support
