Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Api/Custom.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 11 additions & 0 deletions tests/Api/CustomTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down