diff --git a/mailpoet/lib/Automation/API/Endpoint.php b/mailpoet/lib/Automation/API/Endpoint.php new file mode 100644 index 0000000000..db2e771f01 --- /dev/null +++ b/mailpoet/lib/Automation/API/Endpoint.php @@ -0,0 +1,25 @@ +methodNotAllowed(); + } + + public function post(Request $request): Response { + return $this->methodNotAllowed(); + } + + public function put(Request $request): Response { + return $this->methodNotAllowed(); + } + + public function delete(Request $request): Response { + return $this->methodNotAllowed(); + } + + private function methodNotAllowed(): ErrorResponse { + return new ErrorResponse(405, 'Method not allowed', 'mailpoet_automation_method_not_allowed'); + } +} diff --git a/mailpoet/lib/Automation/API/Request.php b/mailpoet/lib/Automation/API/Request.php new file mode 100644 index 0000000000..8263a4e016 --- /dev/null +++ b/mailpoet/lib/Automation/API/Request.php @@ -0,0 +1,45 @@ +wpRequest = $wpRequest; + } + + public function getHeader(string $key): ?string { + return $this->wpRequest->get_header($key); + } + + public function getUrlParams(): array { + return $this->wpRequest->get_url_params(); + } + + public function getUrlParam(string $name): ?string { + return $this->getUrlParams()[$name] ?? null; + } + + public function getQueryParams(): array { + return $this->wpRequest->get_query_params(); + } + + public function getQueryParam(string $name): ?string { + return $this->getQueryParams()[$name] ?? null; + } + + public function getBody(): array { + return $this->wpRequest->get_json_params() ?? []; + } + + public function getRawBody(): string { + return $this->wpRequest->get_body(); + } +} diff --git a/mailpoet/lib/Automation/API/Response.php b/mailpoet/lib/Automation/API/Response.php new file mode 100644 index 0000000000..b8cfa9370e --- /dev/null +++ b/mailpoet/lib/Automation/API/Response.php @@ -0,0 +1,14 @@ + $data], $status); + } +}