from app.models.pin import Pin


def pin_serialize(pin: list) -> Pin:
    return Pin(**{
        "id": str(pin["_id"]),
        "title": pin["title"],
        "description": pin["description"],
        "location": pin["location"],
        "complete_address": pin["complete_address"],
        "files": pin["files"],
        "user_id": pin["user_id"],
        "date": pin.get("date"),
        "is_poi": pin.get("is_poi", False)
    })

def pins_serialize(pins: list) -> list:
    serialized_pins: list = []
    for pin in pins:
        serialized_pins.append(pin_serialize(pin))
        
    return serialized_pins