>,query?:null|array,body?:null|string|array,http_errors?:null|bool} $options Request options * @return array{code:string,headers:array>,content:string} [default=[]] Result code, headers and content as array, content is json * @throws \UnexpectedValueException on missing body data when body data is needed */ abstract public function request(string $type, string $url, array $options = []): array; /** * Makes an request to the target url via curl: GET * Returns result as string (json) * * @param string $url The URL being requested, * including domain and protocol * @param array{auth?:null|array{0:string,1:string,2:string},headers?:null|array>,query?:null|array,body?:null|string|array,http_errors?:null|bool} $options Options to set * @return array{code:string,headers:array>,content:string} [default=[]] Result code, headers and content as array, content is json */ public function get(string $url, array $options = []): array { return $this->request( "get", $url, $options, ); } /** * Makes an request to the target url via curl: POST * Returns result as string (json) * * @param string $url The URL being requested, * including domain and protocol * @param array{auth?:null|array{0:string,1:string,2:string},headers?:null|array>,query?:null|array,body?:null|string|array,http_errors?:null|bool} $options Options to set * @return array{code:string,headers:array>,content:string} Result code, headers and content as array, content is json */ public function post(string $url, array $options): array { return $this->request( "post", $url, $options, ); } /** * Makes an request to the target url via curl: PUT * Returns result as string (json) * * @param string $url The URL being requested, * including domain and protocol * @param array{auth?:null|array{0:string,1:string,2:string},headers?:null|array>,query?:null|array,body?:null|string|array,http_errors?:null|bool} $options Options to set * @return array{code:string,headers:array>,content:string} Result code, headers and content as array, content is json */ public function put(string $url, array $options): array { return $this->request( "put", $url, $options, ); } /** * Makes an request to the target url via curl: PATCH * Returns result as string (json) * * @param string $url The URL being requested, * including domain and protocol * @param array{auth?:null|array{0:string,1:string,2:string},headers?:null|array>,query?:null|array,body?:null|string|array,http_errors?:null|bool} $options Options to set * @return array{code:string,headers:array>,content:string} Result code, headers and content as array, content is json */ public function patch(string $url, array $options): array { return $this->request( "patch", $url, $options, ); } /** * Makes an request to the target url via curl: DELETE * Returns result as string (json) * Note that DELETE body is optional * * @param string $url The URL being requested, * including domain and protocol * @param array{auth?:null|array{0:string,1:string,2:string},headers?:null|array>,query?:null|array,body?:null|string|array,http_errors?:null|bool} $options Options to set * @return array{code:string,headers:array>,content:string} [default=[]] Result code, headers and content as array, content is json */ public function delete(string $url, array $options = []): array { return $this->request( "delete", $url, $options, ); } } // __END__