diff --git a/framework/core/src/Api/Client.php b/framework/core/src/Api/Client.php new file mode 100644 index 000000000..6ef31b6d5 --- /dev/null +++ b/framework/core/src/Api/Client.php @@ -0,0 +1,36 @@ +container = $container; + $this->actor = $actor; + } + + /** + * Execute the given API action class, pass the input and return its response. + * + * @param string $actionClass + * @param array $input + * @return object + */ + public function send($actionClass, array $input = []) + { + /** @var \Flarum\Api\Actions\JsonApiAction $action */ + $action = $this->container->make($actionClass); + + $response = $action->handle(new Request($input, $this->actor)); + + return json_decode($response->getBody()); + } +}