import logging


def get_likes_list(client, timestamp, limit=50):
    """Get data of 50 likes that were liked after the timstamp from Tumblr API
    Parameters
       ----------
       client : TumblrRestClient object
           Handles the connection with Tumblr API
       timestamp : int
           Data will be fetched of posts that were liked after this timestamp
       limit : int, optional
           Number (maximum) of posts that to be fetched in a batch.

       Returns
       -------
       dict
           A dict containing the liked posts data.
           Or emtpy in case of errors with connection.
    """

    if limit > 50:
        logging.warning(
            f"Provided limit is {limit}. Tumblr defaults limit to 50 for any values over 50."
        )

    try:
        # get the data
        likes_list = client.likes(after=timestamp, limit=50)
        ret_data = likes_list["liked_posts"]
        ret_data.reverse()
        return ret_data

    except Exception as tumblr_api_connection_error:
        logging.error(tumblr_api_connection_error)
        logging.info("Something went wrong with connecting to Tumblr API")

        return {}