diff --git a/src/Api/Custom.php b/src/Api/Custom.php index 7be4cab..76b2acc 100644 --- a/src/Api/Custom.php +++ b/src/Api/Custom.php @@ -35,7 +35,9 @@ public function __construct(string $endpoint, Magento $magento) public function __call($method, $args) { if (in_array($method, self::HTTP_METHODS)) { - $args[0] = $this->endpoint.ltrim($args[0], '/'); + $args[0] = (isset($args[0])) + ? $this->endpoint.ltrim($args[0], '/') + : rtrim($this->endpoint, '/'); } return call_user_func_array([$this, $method], $args); diff --git a/tests/Api/CustomTest.php b/tests/Api/CustomTest.php index 4aed363..9279b1e 100644 --- a/tests/Api/CustomTest.php +++ b/tests/Api/CustomTest.php @@ -18,6 +18,17 @@ public function test_can_get_custom_endpoint() $this->assertTrue($customApi->ok()); } + public function test_can_get_singular_custom_endpoint() + { + Http::fake([ + '*rest/all/V1/foo' => Http::response([], 200), + ]); + + $customApi = MagentoFacade::api('foo')->get(); + + $this->assertTrue($customApi->ok()); + } + public function test_can_post_custom_endpoint() { Http::fake([