isBlocking = $state; return $this; } public function nonBlocking(): AppHttp { if ( $this->isBlocking ) { $this->isBlocking = false; } return $this; } public function __call( string $name, array $arguments ) { $apiKey = Options::getAppToken(); if ( empty( $apiKey ) ) { return new WP_Error( 'no_api_key', 'There is no API key set.' ); } if ( 'get' === $name && isset( $arguments[1] ) ) { $arguments[0] .= '?' . http_build_query( $arguments[1] ); } return wp_remote_request( ACRKit::getAppUrl() . $arguments[0], array( 'method' => strtoupper( $name ), 'body' => ( isset( $arguments[1] ) && 'get' !== $name ) ? wp_json_encode( $arguments[1] ) : null, 'blocking' => $this->isBlocking, 'headers' => array( 'Accept' => 'application/json', 'Content-Type' => 'application/json; charset=utf-8', 'Authorization' => 'Bearer ' . $apiKey, 'X-Forwarded-For' => Helper::getIpAddress(), ), ) ); } }