# Path: cdrouter/cdr_datetime.py
# class DateTime(fields.DateTime):
#     def __init__(self, format=None, **kwargs):
#         super(DateTime, self).__init__(format=format, **kwargs)
#         
#     def _serialize(self, value, attr, obj):
#         try:
#             return super(DateTime, self)._serialize(value, attr, obj)
#         except ValidationError:
#             return datetime.min
# 
#     def _deserialize(self, value, attr, data):
#         try:
#             return super(DateTime, self)._deserialize(value, attr, data)
#         except ValidationError:
#             return datetime.min


import collections
import io
import os.path
from functools import partial
from requests_toolbelt.downloadutils import stream
from marshmallow import Schema, fields, post_load
from .cdr_datetime import DateTime
#



class Attachment(object):
    """Model for CDRouter Attachments.

    :param id: (optional) Attachment ID as an int.
    :param name: (optional) Name as string.
    :param description: (optional) Description as string.
    :param created: (optional) Creation time as `DateTime`.
    :param updated: (optional) Last-updated time as `DateTime`.
    :param size: (optional) Attachment size as an int.
    :param path: (optional) Filepath to attachment as string.
    :param device_id: (optional) Device ID as an int.
    """
    def __init__(self, **kwargs):
        self.id = kwargs.get('id', None)
        self.name = kwargs.get('name', None)
        self.description = kwargs.get('description', None)
        self.created = kwargs.get('created', None)
        self.updated = kwargs.get('updated', None)
        self.size = kwargs.get('size', None)
        self.path = kwargs.get('path', None)
        self.device_id = kwargs.get('device_id', None)

class AttachmentSchema(Schema):
    id = fields.Int(as_string=True)
    name = fields.Str()
    description = fields.Str()

# Path: cdrouter/cdr_datetime.py
# class DateTime(fields.DateTime):
#     def __init__(self, format=None, **kwargs):
#         super(DateTime, self).__init__(format=format, **kwargs)
#         
#     def _serialize(self, value, attr, obj):
#         try:
#             return super(DateTime, self)._serialize(value, attr, obj)
#         except ValidationError:
#             return datetime.min
# 
#     def _deserialize(self, value, attr, data):
#         try:
#             return super(DateTime, self)._deserialize(value, attr, data)
#         except ValidationError:
#             return datetime.min


# Path: cdrouter/attachments.py
import collections
import io
import os.path
from functools import partial
from requests_toolbelt.downloadutils import stream
from marshmallow import Schema, fields, post_load
from .cdr_datetime import DateTime

#



class Attachment(object):
    """Model for CDRouter Attachments.

    :param id: (optional) Attachment ID as an int.
    :param name: (optional) Name as string.
    :param description: (optional) Description as string.
    :param created: (optional) Creation time as `DateTime`.
    :param updated: (optional) Last-updated time as `DateTime`.
    :param size: (optional) Attachment size as an int.
    :param path: (optional) Filepath to attachment as string.
    :param device_id: (optional) Device ID as an int.
    """
    def __init__(self, **kwargs):
        self.id = kwargs.get('id', None)
        self.name = kwargs.get('name', None)
        self.description = kwargs.get('description', None)
        self.created = kwargs.get('created', None)
        self.updated = kwargs.get('updated', None)
        self.size = kwargs.get('size', None)
        self.path = kwargs.get('path', None)
        self.device_id = kwargs.get('device_id', None)

class AttachmentSchema(Schema):
    id = fields.Int(as_string=True)
    name = fields.Str()
    description = fields.Str()

    created = DateTime()