import config
#Server Name/URL
#SERVER_NAME = 'locahost:80'

# Let's just use the local mongod instance. Edit as needed.

# Please note that MONGO_HOST and MONGO_PORT could very well be left
# out as they already default to a bare bones local 'mongod' instance.
MONGO_URI = config.mongo_uri
DATE_FORMAT = '%Y-%m-%dT%H:%M:%S.%fZ'
IF_MATCH = False
ENFORCE_IF_MATCH = False

# Enable reads (GET), inserts (POST) and DELETE for resources/collections
# (if you omit this line, the API will default to ['GET'] and provide
# read-only access to the endpoint).
RESOURCE_METHODS = ['GET', 'POST', 'DELETE']

# Enable reads (GET), edits (PATCH), replacements (PUT) and deletes of
# individual items  (defaults to read-only item access).
ITEM_METHODS = ['GET', 'PATCH', 'PUT', 'DELETE']

schema_file_trash = {
    # Schema definition, based on Cerberus grammar. Check the Cerberus project
    # (https://github.com/nicolaiarocci/cerberus) for details.
    'id': {
        'type': 'string'
    },
    'user': {
        'type': 'string'
    },
    'timestamp': {
        'type': 'integer'
    },
    'location': {
        'type': 'string'
    },
    'type': {
        'type': 'string'
    },
    'mime': {
        'type': 'string'
    }
}

schema_activity = {
    # Schema definition, based on Cerberus grammar. Check the Cerberus project
    # (https://github.com/nicolaiarocci/cerberus) for details.
    'activity_id': {
        'type': 'integer'
    },
    'timestamp': {
        'type': 'integer'
    },
    'priority': {
        'type': 'integer'
    },
    'type': {
        'type': 'string'
    },
    'user': {
        'type': 'string'
    },
    'affecteduser': {
        'type': 'string'
    },
    'app': {
        'type': 'string'
    },
    'subject': {
        'type': 'string'
    },
    'subjectparams': {
        'type': 'string'
    },
    'message': {
        'type': 'string'
    },
    'messageparams': {
        'type': 'string'
    },
    'file': {
        'type': 'string'
    },
    'link': {
        'type': 'string'
    },

}

#schema user profile
schema_user_profile = {
    # Schema definition, based on Cerberus grammar. Check the Cerberus project
    # (https://github.com/nicolaiarocci/cerberus) for details.
    'user_name': {
        'type': 'string',
    'nullable': True
    },
    'photo': {
        'type': 'string',
    'nullable': True
    },
    'full_name': {
        'type': 'string',
    'nullable': True
    },
    'date_of_birth': {
        'type': 'datetime',
    'nullable': True
    },
    'mobile': {
        'type': 'string',
    'nullable': True
    },
    'gender': {
        'type': 'string',
    'nullable': True
    },
    'phone': {
        'type': 'string',
    'nullable': True
    },
    'email_id': {
        'type': 'string',
    'nullable': True
    },
    'user_from': {
        'type': 'string',
    'nullable': True
    },
    'state': {
        'type': 'string',
    'nullable': True
    },
    'district': {
        'type': 'string',
    'nullable': True
    },
    'city': {
        'type': 'string',
    'nullable': True
    },
    'additional_info': {
        'type': 'list',
    'nullable': True
    },
    'created_on': {
        'type': 'datetime',
    'nullable': True
    },
    'modified_on': {
        'type': 'datetime',
        'nullable': True
    },
    'transaction_id': {
        'type': 'string',
        'nullable': True
    },
    'source': {
        'type': 'string',
        'nullable': True
    },
    'UID_Token': {
        'type': 'string',
        'nullable': True
    },
    'lastlogin': {
        'type': 'datetime',
        'nullable': True
    },
    'fpkey': {
        'type': 'string',
        'nullable': True
    },
    'fptoken': {
        'type': 'string',
        'nullable': True
    },

}

#schema generate pin
schema_digilocker_pin = {
    # Schema definition, based on Cerberus grammar. Check the Cerberus project
    # (https://github.com/nicolaiarocci/cerberus) for details.
    'user_name': {
        'type': 'string'
    },
    'pin': {
        'type': 'string'
    },
    'transaction_id': {
        'type': 'string'
    },
    'created_on': {
        'type': 'datetime',
        'nullable': True
    },
    'modified_on': {
        'type': 'datetime',
        'nullable': True
    },

}


#schema multiple_banks
schema_multiple_banks = {
    # Schema definition, based on Cerberus grammar. Check the Cerberus project
    # (https://github.com/nicolaiarocci/cerberus) for details.
    'userid': {
        'type': 'string'
    },
    'org_name': {
        'type': 'string'
    },
    'org_id': {
        'type': 'string'
    },
    'uid': {
        'type': 'string'
    },
    'bankuser_response_code': {
        'type': 'string'
    },
    'created_on': {
        'type': 'datetime',
        'nullable': True
    },
    'modified_on': {
        'type': 'datetime',
        'nullable': True
    },
    'log_transacttion_id': {
        'type': 'string'
    },



}

#schema  bank oc_preferences
schema_oc_preferences = {
    # Schema definition, based on Cerberus grammar. Check the Cerberus project
    # (https://github.com/nicolaiarocci/cerberus) for details.
    'userid': {
        'type': 'string'
    },
    'org_name': {
        'type': 'string'
    },
    'bankuser_response_code': {
        'type': 'string'
    },
    'org_id': {
        'type': 'string'
    },
    'uid': {
        'type': 'string'
    },
    'ts': {
        'type': 'string'
    },
    'txn': {
        'type': 'string'
    },
    'hmac': {
        'type': 'string'
    },
    'api_url': {
        'type': 'string'
    },
    'app_key': {
        'type': 'string'
    },
    'bank_popup': {
        'type': 'string'
    },
    'bank_callback': {
        'type': 'string'
    },
    'bank_activity': {
        'type': 'string'
    },
    'orgId': {
        'type': 'string',
        'nullable': True
    },
    'action': {
        'type': 'string',
        'nullable': True
    },
    'created_on': {
        'type': 'datetime',
        'nullable': True
    },
    'modified_on': {
        'type': 'datetime',
        'nullable': True
    },
    'log_transacttion_id': {
        'type': 'string'
    },

}

schema_auth_token = {
    # Schema definition, based on Cerberus grammar. Check the Cerberus project
    # (https://github.com/nicolaiarocci/cerberus) for details.
    'username': {
        'type': 'string'
    },
    'token': {
        'type': 'string'
    },
    'created_on': {
        'type': 'datetime',
        'nullable': True
    },

}


oc_files_trash = {
    # 'title' tag used in item links. Defaults to the resource title minus
    # the final, plural 's' (works fine in most cases but not for 'people')
    'item_title': 'Files Trash',

    # by default the standard item entry point is defined as
    # '/people/<ObjectId>'. We leave it untouched, and we also enable an
    # additional read-only entry point. This way consumers can also perform
    # GET requests at '/people/<lastname>'.
    # 'additional_lookup': {
        # 'url': 'regex("[\w]+")',
        # 'field': 'RROLL'
    # },

    # We choose to override global cache-control directives for this resource.
    'cache_control': 'max-age=10,must-revalidate',
    'cache_expires': 10,

    # most global settings can be overridden at resource level
    'resource_methods': ['GET', 'POST'],

    'item_methods': ['GET', 'DELETE'],


    'schema': schema_file_trash
}

oc_activity = {
    # 'title' tag used in item links. Defaults to the resource title minus
    # the final, plural 's' (works fine in most cases but not for 'people')
    'item_title': 'OC Activities',

    # by default the standard item entry point is defined as
    # '/people/<ObjectId>'. We leave it untouched, and we also enable an
    # additional read-only entry point. This way consumers can also perform
    # GET requests at '/people/<lastname>'.
    #'additional_lookup': {
        #'url': 'regex("[\w]+")',
        #'field': 'RROLL'
    #},

    # We choose to override global cache-control directives for this resource.
    'cache_control': 'max-age=10,must-revalidate',
    'cache_expires': 10,

    # most global settings can be overridden at resource level
    'resource_methods': ['GET', 'POST'],

    'item_methods': ['GET', 'DELETE'],


    'schema': schema_activity
}

user_profile = {
    # 'title' tag used in item links. Defaults to the resource title minus
    # the final, plural 's' (works fine in most cases but not for 'people')
    'item_title': 'KYC DATA',

    # by default the standard item entry point is defined as
    # '/people/<ObjectId>'. We leave it untouched, and we also enable an
    # additional read-only entry point. This way consumers can also perform
    # GET requests at '/people/<lastname>'.
    #'additional_lookup': {
        #'url': 'regex("[\w]+")',
        #'field': 'RROLL'
    #},

    # We choose to override global cache-control directives for this resource.
    'cache_control': 'max-age=10,must-revalidate',
    'cache_expires': 10,

    # most global settings can be overridden at resource level
    'resource_methods': ['GET', 'POST'],

    'item_methods': ['GET', 'PATCH'],


    'schema': schema_user_profile
}

digilocker_pin = {
    # 'title' tag used in item links. Defaults to the resource title minus
    # the final, plural 's' (works fine in most cases but not for 'people')
    'item_title': 'KYC DATA',

    # by default the standard item entry point is defined as
    # '/people/<ObjectId>'. We leave it untouched, and we also enable an
    # additional read-only entry point. This way consumers can also perform
    # GET requests at '/people/<lastname>'.
    #'additional_lookup': {
        #'url': 'regex("[\w]+")',
        #'field': 'RROLL'
    #},

    # We choose to override global cache-control directives for this resource.
    'cache_control': 'max-age=10,must-revalidate',
    'cache_expires': 10,

    # most global settings can be overridden at resource level
    'resource_methods': ['GET', 'POST'],

    'item_methods': ['GET', 'PATCH'],


    'schema': schema_digilocker_pin
}

multiple_banks = {
    # 'title' tag used in item links. Defaults to the resource title minus
    # the final, plural 's' (works fine in most cases but not for 'people')
    'item_title': 'KYC DATA',

    # by default the standard item entry point is defined as
    # '/people/<ObjectId>'. We leave it untouched, and we also enable an
    # additional read-only entry point. This way consumers can also perform
    # GET requests at '/people/<lastname>'.
    #'additional_lookup': {
        #'url': 'regex("[\w]+")',
        #'field': 'RROLL'
    #},

    # We choose to override global cache-control directives for this resource.
    'cache_control': 'max-age=10,must-revalidate',
    'cache_expires': 10,

    # most global settings can be overridden at resource level
    'resource_methods': ['GET', 'POST'],

    'item_methods': ['GET', 'PATCH'],


    'schema': schema_multiple_banks
}

oc_preferences = {
    # 'title' tag used in item links. Defaults to the resource title minus
    # the final, plural 's' (works fine in most cases but not for 'people')
    'item_title': 'KYC DATA',

    # by default the standard item entry point is defined as
    # '/people/<ObjectId>'. We leave it untouched, and we also enable an
    # additional read-only entry point. This way consumers can also perform
    # GET requests at '/people/<lastname>'.
    #'additional_lookup': {
        #'url': 'regex("[\w]+")',
        #'field': 'RROLL'
    #},

    # We choose to override global cache-control directives for this resource.
    'cache_control': 'max-age=10,must-revalidate',
    'cache_expires': 10,

    # most global settings can be overridden at resource level
    'resource_methods': ['GET', 'POST'],

    'item_methods': ['GET', 'PATCH'],


    'schema': schema_oc_preferences
}


auth_token = {
    # 'title' tag used in item links. Defaults to the resource title minus
    # the final, plural 's' (works fine in most cases but not for 'people')
    'item_title': 'Auth Token',

    # by default the standard item entry point is defined as
    # '/people/<ObjectId>'. We leave it untouched, and we also enable an
    # additional read-only entry point. This way consumers can also perform
    # GET requests at '/people/<lastname>'.
    'additional_lookup': {
        'url': 'regex("[\w]+")',
        'field': 'username'
    },

    # We choose to override global cache-control directives for this resource.
    'cache_control': 'max-age=10,must-revalidate',
    'cache_expires': 10,

    # most global settings can be overridden at resource level
    'resource_methods': ['GET', 'POST','DELETE'],

    'item_methods': ['GET', 'PATCH','DELETE'],
    'id_field' : 'username',
    'item_lookup_field': "username",
    'item_url': r'regex("[\w]+")',


    'schema': schema_auth_token
}

################FOR ACCOUNTS SERVICES###########################3

schema_users = {
    'digilockerid': {
        'type': 'string'
    },'mobile_no': {
        'type': 'string',
        'nullable': True
    },'uid': {
        'type': 'string',
        'nullable': True
    },'user_alias': {
        'type': 'string',
        'nullable': True
    },'user_id': {
        'type': 'string',
        'nullable': True
    },'password': {
        'type': 'string',
        'nullable': True
    },'pin': {
        'type': 'string',
        'nullable': True
    },'user_type': {
        'type': 'string'
    },'uid_token': {
        'type': 'string',
        'nullable': True
    },'uid_token_hash': {
        'type': 'string',
        'nullable': True
    },'user_enc_key': {
        'type': 'string',
        'nullable': True
    },'device_id': {
        'type': 'string',
        'nullable': True
    },'is_deleted': {
        'type': 'boolean',
        'nullable': True
    },'deleted_on': {
        'type': 'datetime',
        'nullable': True
    },'created_by': {
        'type': 'string',
        'nullable': True
    },'created_on': {
        'type': 'datetime',
        'nullable': True
    },'modified_on': {
        'type': 'datetime',
        'nullable': True
    },'email_id': {
        'type': 'string',
        'nullable': True
    },'security_question_id': {
        'type': 'string',
        'nullable': True
    },'refkey': {
        'type': 'string',
        'nullable': True
    },'option1': {
        'type': 'string',
        'nullable': True
    },'option2': {
        'type': 'string',
        'nullable': True
    },'option3': {
        'type': 'string',
        'nullable': True
    },'health_id': {
        'type': 'string',
        'nullable': True
    },'data_directory_type': {
        'type': 'string',
        'nullable': True
    },'drive_migration': {
        'type': 'string',
        'nullable': True
    },'email_id_verified': {
        'type': 'integer',
        'nullable': True
    },'drive_migration_time': {
        'type': 'datetime',
        'nullable': True
    }
}


schema_users_profile = {
    'digilockerid': {
        'type': 'string'
    },'created_by': {
        'type': 'string',
        'nullable': True
    },'relation': {
        'type': 'string',
        'nullable': True
    },'name': {
        'type': 'string',
        'nullable': True
    },'date_of_birth': {
        'type': 'datetime',
        'nullable': True
    },'gender': {
        'type': 'string',
        'nullable': True
    },'state': {
        'type': 'string',
        'nullable': True
    },'district': {
        'type': 'string',
        'nullable': True
    },'city': {
        'type': 'string',
        'nullable': True
    },'photo': {
        'type': 'string',
        'nullable': True
    },'user_from': {
        'type': 'string',
        'nullable': True
    },'account_type': {
        'type': 'string',
        'nullable': True
    }, 'converted_on': {
        'type': 'datetime',
        'nullable': True
    }, 'converted_by': {
        'type': 'string',
        'nullable': True
    },'uploaded_doc_path': {
        'type': 'string',
        'nullable': True
    },'health_doc_path': {
        'type': 'string',
        'nullable': True
    },'issued_doc_path': {
        'type': 'string',
        'nullable': True
    },'created_on': {
        'type': 'datetime',
        'nullable': True
    },'modified_on': {
        'type': 'datetime',
        'nullable': True
    },'option1': {
        'type': 'string',
        'nullable': True
    },'option2': {
        'type': 'string',
        'nullable': True
    },'option3': {
        'type': 'string',
        'nullable': True
    },'email_subscription': {
        'type': 'boolean',
        'nullable': True,
        'default': 1
    }

}

schema_security_answers = {
    'digilockerid': {
        'type': 'string'
    },'question_id': {
        'type': 'string',
        'nullable': True
    },'answer': {
        'type': 'string',
        'nullable': True
    },'created_on': {
        'type': 'datetime',
        'nullable': True
    },'modified_on': {
        'type': 'datetime',
        'nullable': True
    },'option1': {
        'type': 'datetime',
        'nullable': True
    },'option2': {
        'type': 'datetime',
        'nullable': True
    }
}

users = {
    'item_title': 'Accounts Users',

    'additional_lookup': {
        'url': 'regex("[\w]+")',
        'field': 'digilockerid'
    },

    'cache_control': 'max-age=10,must-revalidate',
    'cache_expires': 10,
    'resource_methods': ['GET', 'POST','DELETE'],
    'item_methods': ['GET', 'PATCH','DELETE'],

    'id_field' : 'digilockerid',
    'item_lookup_field': "digilockerid",
    'item_url': r'regex("[\w]+")',

    'schema': schema_users
}

users_profile = {
    'item_title': 'Users Profile',

    'additional_lookup': {
        'url': 'regex("[\w]+")',
        'field': 'digilockerid'
    },

    'cache_control': 'max-age=10,must-revalidate',
    'cache_expires': 10,
    'resource_methods': ['GET', 'POST','DELETE'],
    'item_methods': ['GET', 'PATCH','DELETE'],

    'id_field' : 'digilockerid',
    'item_lookup_field': "digilockerid",
    'item_url': r'regex("[\w]+")',
    
    'schema': schema_users_profile
}

security_answers = {
    'item_title': 'Users Security Answers',

    'additional_lookup': {
        'url': 'regex("[\w]+")',
        'field': 'digilockerid'
    },

    'cache_control': 'max-age=10,must-revalidate',
    'cache_expires': 10,
    'resource_methods': ['GET', 'POST','DELETE'],
    'item_methods': ['GET', 'PATCH','DELETE'],

    'id_field' : 'digilockerid',
    'item_lookup_field': "digilockerid",
    'item_url': r'regex("[\w]+")',

    'schema': schema_security_answers
}

# account nominee schema details @ 7122 on 02-Oct-2020
schema_account_nominee = {
    'username': {
        'type': 'string'
    },
    'name': {
        'type': 'string',
        'nullable': True
    },
    'nominee_id': {
        'type': 'string',
        'nullable': True
    },
    'dob': {
        'type': 'datetime',
        'nullable': True
    },
    'gender': {
        'type': 'string',
        'nullable': True
    },
    'relation': {
        'type': 'string',
        'nullable': True
    },
    'uid': {
        'type': 'string',
        'nullable': True
    },
    'uid_token': {
        'type': 'string',
        'nullable': True
    },
    'mobileno': {
        'type': 'string',
        'nullable': True
    },
    'email': {
        'type': 'string',
        'nullable': True
    },
    'photo': {
        'type': 'string',
        'nullable': True
    },
    'created_on': {
        'type': 'datetime',
        'nullable': True
    },
    'modified_on': {
        'type': 'datetime',
        'nullable': True
    },
    'is_deleted': {
        'type': 'string',
        'nullable': True
    },
    'deleted_on': {
        'type': 'datetime',
        'nullable': True
    }

}

account_nominee = {
    'item_title': 'Account Nominee',
    'cache_control': 'max-age=10,must-revalidate',
    'cache_expires': 10,
    'resource_methods': ['GET', 'POST','DELETE'],
    'item_methods': ['GET', 'PATCH','DELETE'],
    'schema': schema_account_nominee
}


schema_users_signup_attempts_log = {
    'transactionid': {
        'type': 'string'
    },
    'name': {
        'type': 'string',
        'nullable': True
    },
    'dob': {
        'type': 'datetime',
        'nullable': True
    },
    'gender': {
        'type': 'string',
        'nullable': True
    },
    'mobile': {
        'type': 'string',
        'nullable': True
    },
    'uid': {
        'type': 'string',
        'nullable': True
    },
    'pin': {
        'type': 'string',
        'nullable': True
    },
    'uid_token': {
        'type': 'string',
        'nullable': True
    },
    'email': {
        'type': 'string',
        'nullable': True
    },
    'source': {
        'type': 'string',
        'nullable': True
    },
    'data_directory_type': {
        'type': 'string',
        'nullable': True
    },
    'user_type': {
        'type': 'string',
        'nullable': True
    },
    'last_updated_on': {
        'type': 'datetime',
        'nullable': True
    }

}

users_signup_attempts_log = {
    'item_title': 'User Attempts Log',
    'cache_control': 'max-age=10,must-revalidate',
    'cache_expires': 10,
    'resource_methods': ['GET', 'POST','DELETE'],
    'item_methods': ['GET', 'PATCH','DELETE'],
    'schema': schema_users_signup_attempts_log
}

# users address added on @13-01-2021
schema_user_address = {
    'digilockerid': {
        'type': 'string'
    },'device_id': {
        'type': 'string',
        'nullable': True
    },'address1': {
        'type': 'string',
        'nullable': True
    },'address2': {
        'type': 'string',
        'nullable': True
    },'address3': {
        'type': 'string',
        'nullable': True
    },'state': {
        'type': 'string',
        'nullable': True
    },'district': {
        'type': 'string',
        'nullable': True
    },'pincode': {
        'type': 'string',
        'nullable': True
    },'coordinates': {
        'type': 'string',
        'nullable': True
    },'created_on': {
        'type': 'datetime',
        'nullable': True
    },'modified_on': {
        'type': 'datetime',
        'nullable': True
    },'option1': {
        'type': 'datetime',
        'nullable': True
    },'option2': {
        'type': 'datetime',
        'nullable': True
    }

}

user_address = {
    'item_title': 'User Address',
    'cache_control': 'max-age=10,must-revalidate',
    'cache_expires': 10,
    'resource_methods': ['GET', 'POST','DELETE'],
    'item_methods': ['GET', 'PATCH','DELETE'],
    'schema': schema_user_address
}


schema_account_extension = {
    'digilockerid': {
        'type': 'string'
    },
    'uid_hash': {
        'type': 'string'
    },
    'uid_token': {
        'type': 'string'
    },
    'modified_on': {
        'type': 'datetime',
        'nullable': True
    },

}

account_extension = {
    'item_title': 'User Extension',
    'cache_control': 'max-age=10,must-revalidate',
    'cache_expires': 10,
    'resource_methods': ['GET', 'POST','DELETE'],
    'item_methods': ['GET', 'PATCH','DELETE'],
    'schema': schema_account_extension
}


DOMAIN = {'oc_files_trash': oc_files_trash,
    'oc_activity': oc_activity,
    'user_profile': user_profile,
    'digilocker_pin':digilocker_pin,
    'multiple_banks':multiple_banks,
    'oc_preferences':oc_preferences,
    'auth_token':auth_token,
    'users': users,
    'users_profile' : users_profile,
    'security_answers' : security_answers,
    'account_nominee' : account_nominee,
    'users_signup_attempts_log' : users_signup_attempts_log,
    'user_address' : user_address,
    'account_extension': account_extension

}