<?php
/**
 * @package Hafenstudios\Kurato
 */

namespace Hafenstudios\Kurato\Cockpit;

defined( 'ABSPATH' ) || exit;

/**
 * Produktions-HTTP-Ausgang ueber wp_remote_post.
 */
class WpHttpClient implements HttpClient {

	/**
	 * @param string               $url  Ziel-URL.
	 * @param array<string, mixed> $args wp_remote_post-Argumente.
	 * @return array{status: int, body: string}|\WP_Error
	 */
	public function post( string $url, array $args ) {
		$response = wp_remote_post( $url, $args );
		if ( is_wp_error( $response ) ) {
			return $response;
		}
		return array(
			'status' => (int) wp_remote_retrieve_response_code( $response ),
			'body'   => (string) wp_remote_retrieve_body( $response ),
		);
	}
}
