from datetime import datetime


def news_parser(news_json: dict):
    """
    Given a news JSON item from the unaltered API Response, it retains specific information and creates a JSON formatted
    dictionary containing data needed by the DynamoDB table. Variable names for the dictionary are in camelCase.

    :param news_json: Unaltered JSON item from UBCO news API Response
    :return: JSON formatted item for DynamoDB storage
    """
    parsed_news = {
        "newsId": str(news_json.get("post-id", "Null")),
        "title": news_json.get("title", "Null"),
        "link": news_json.get("id", "Null"),
        "summary": news_json.get("summary", "Null"),
        "mediaThumbnail": news_json.get("media_thumbnail", []),
        "categories": [category["term"] for category in news_json["tags"]],
        "dateModified": str(datetime.strptime(news_json["published"].split(",")[1][1:-6], "%d %b %Y %H:%M:%S"))
    }
    return parsed_news