|WP_Error The response from the remote API, or a WP_Error * object if the response is an error. */ public function get_titles( string $content, int $limit, string $persona = 'journalist', string $tone = 'neutral' ) { $body = array( 'output_config' => array( 'persona' => $persona, 'style' => $tone, 'max_items' => $limit, ), 'text' => $content, ); $decoded = $this->post_request( array(), $body ); if ( is_wp_error( $decoded ) ) { return $decoded; } if ( ! property_exists( $decoded, 'result' ) || ! is_array( $decoded->result ) ) { return new WP_Error( 400, __( 'Unable to parse titles from upstream API', 'wp-parsely' ) ); } return $decoded->result; } }