# 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
from marshmallow import Schema, fields, post_load
from .cdr_datetime import DateTime
# Copyright (c) 2017-2020 by QA Cafe.
# All Rights Reserved.
#

"""Module for accessing CDRouter History."""



class History(object):
    """Model for CDRouter History entries.

    :param user_id: (optional) User ID as an int.
    :param created: (optional) Entry creation time as `DateTime`.
    :param resource: (optional) Resource type as string.
    :param id: (optional) Resource ID as an int.
    :param name: (optional) Resource name as string.
    :param action: (optional) Action name as string.
    :param description: (optional) Resource description as string.
    """
    def __init__(self, **kwargs):
        self.user_id = kwargs.get('user_id', None)
        self.created = kwargs.get('created', None)
        self.resource = kwargs.get('resource', None)
        self.id = kwargs.get('id', None)
        self.name = kwargs.get('name', None)
        self.action = kwargs.get('action', None)
        self.description = kwargs.get('description', None)

class HistorySchema(Schema):
    user_id = fields.Int(as_string=True)

# 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/history.py
import collections
from marshmallow import Schema, fields, post_load
from .cdr_datetime import DateTime

# Copyright (c) 2017-2020 by QA Cafe.
# All Rights Reserved.
#

"""Module for accessing CDRouter History."""



class History(object):
    """Model for CDRouter History entries.

    :param user_id: (optional) User ID as an int.
    :param created: (optional) Entry creation time as `DateTime`.
    :param resource: (optional) Resource type as string.
    :param id: (optional) Resource ID as an int.
    :param name: (optional) Resource name as string.
    :param action: (optional) Action name as string.
    :param description: (optional) Resource description as string.
    """
    def __init__(self, **kwargs):
        self.user_id = kwargs.get('user_id', None)
        self.created = kwargs.get('created', None)
        self.resource = kwargs.get('resource', None)
        self.id = kwargs.get('id', None)
        self.name = kwargs.get('name', None)
        self.action = kwargs.get('action', None)
        self.description = kwargs.get('description', None)

class HistorySchema(Schema):
    user_id = fields.Int(as_string=True)

    created = DateTime()