# Path: src/pycrunchbase/resource/utils.py
# def safe_int(int_like):
#     try:
#         return int(int_like)
#     except TypeError:
#         return None


import six
from .utils import safe_int
from .pageitem import PageItem
from .relationship import Relationship

    The data that is used to initialize a Page looks like this::

        "data": {
            "paging": {
                "items_per_page": 1000,
                "current_page": 1,
                "number_of_pages": 1,
                "next_page_url": null,
                "prev_page_url": null,
                "total_items": 1,
                "sort_order": "custom"
            },
            "items": [
             {
                "properties": {
                    "path": "organization/example",
                    "name": "Example",
                    "updated_at": 1423666090,
                    "created_at": 1371717055,
                 },
                 "type": "Organization",
                 "uuid": "uuid"
             }
            ]
        }
    """
    def __init__(self, name, data):
        self.name = name
        paging = data.get('paging')

# Path: src/pycrunchbase/resource/utils.py
# def safe_int(int_like):
#     try:
#         return int(int_like)
#     except TypeError:
#         return None


# Path: src/pycrunchbase/resource/page.py
import six
from .utils import safe_int
from .pageitem import PageItem
from .relationship import Relationship


    The data that is used to initialize a Page looks like this::

        "data": {
            "paging": {
                "items_per_page": 1000,
                "current_page": 1,
                "number_of_pages": 1,
                "next_page_url": null,
                "prev_page_url": null,
                "total_items": 1,
                "sort_order": "custom"
            },
            "items": [
             {
                "properties": {
                    "path": "organization/example",
                    "name": "Example",
                    "updated_at": 1423666090,
                    "created_at": 1371717055,
                 },
                 "type": "Organization",
                 "uuid": "uuid"
             }
            ]
        }
    """
    def __init__(self, name, data):
        self.name = name
        paging = data.get('paging')

        self.total_items = safe_int(paging.get('total_items')) or 0