How to create callback function which returns all posts with specific data?

Found! This function returns the specified fields for each post.

function get_all ( $params ){

     $posts = get_posts( array(
            'offset'      => 0,
            'post_status' => 'publish'
    ) );


    if ( empty( $posts ) ) {
        return null;
    }

    $posts_data = array();

    foreach( $posts as $post ) {

        $posts_data[] = (object) array( 
            'id' => $post->ID, 
            'date'      => $post->post_date,
            'date_gmt'  => $post->post_date_gmt,
            'modified'  => $post->post_modified,
            'title'     => $post->post_title,
            'content'   => $post->post_content,
            'category'  => get_the_category_by_ID($post->post_category[0]),
            'link'      => get_permalink($post),
        );
    }

    return $posts_data;
}