import madmpy
import datetime
import json

VERSION = "1.0"
madmpy.set_version(VERSION)

dmp_module = madmpy.load()

madmpy.validate_DMP(f"data/ex8-dmp-minimal-content.json")

title = "DMP Title"
language = dmp_module.LanguageEnum.eng
dataset = dmp_module.Dataset(
    dataset_id=dmp_module.DatasetIdentifier(
        identifier="https://doi.org/10.25504/FAIRsharing.r3vtvx",
        type=dmp_module.dmp_dataset_id_type.DOI,
    ),
    description="Dataset description example",
    personal_data="no",
    sensitive_data="no",
    technical_resource=[dmp_module.TechnicalResource(name="Technical resource")],
    title="Dataset title",
)

contact = dmp_module.Contact(
    name="name",
    contact_id=dmp_module.ContactIdentifier(
        identifier="https://orcid.org/0000-0001-2345-6789",
        type=dmp_module.contact_id_type.ORCID,
    ),
    mbox="name@email.com",
)

dmp_id = dmp_module.DMPIdentifier(
    identifier="https://n2t.net/ark:/123456/xyz123?info", 
    type=dmp_module.dmp_dataset_id_type.ARK)

DMP = dmp_module.DMP(
    dataset=[dataset],
    language=language,
    title=title,
    contact=contact,
    dmp_id=dmp_id,
    ethical_issues_exist=dmp_module.YesNoUnknown.NO,
    created= datetime.datetime.now().replace(microsecond=0),
    modified= datetime.datetime.now().replace(microsecond=0),
)

json_output = madmpy.export_DMP_json(DMP)
print(json_output)

with open("output.json", "w", encoding="utf-8") as file:
    json.dump(json_output, file, ensure_ascii=False, indent=4)

madmpy.validate_DMP("output.json")
