Skip to content

Commit 8468d0e

Browse files
authored
Merge pull request #58 from aligent/fix/widget-template-api-endpoints-incorrect
Fixed issue where Widget Template endpoints were incorrect
2 parents 44a9277 + 9b61f65 commit 8468d0e

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

RELEASE_NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@
77

88
- Fixed 404 errors on scripts api (#55), thanks to @kishan93
99
- Fixed issue where subscribers API was not accessible
10+
- Fixed issue where Widget Template endpoints were incorrect
1011

src/BigCommerce/Api/Widgets/WidgetTemplateApi.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
class WidgetTemplateApi extends UuidCompleteResourceApi
1111
{
12-
private const TEMPLATE_ENDPOINT = 'content/widget-templates';
13-
private const TEMPLATES_ENDPOINT = 'content/widget-templates/%s';
12+
private const TEMPLATE_ENDPOINT = 'content/widget-templates/%s';
13+
private const TEMPLATES_ENDPOINT = 'content/widget-templates';
1414

1515
public function multipleResourceUrl(): string
1616
{

tests/BigCommerce/Api/Widgets/WidgetTemplateApiTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ class WidgetTemplateApiTest extends BigCommerceApiTest
99
public function testCanGetTemplate(): void
1010
{
1111
$this->setReturnData('content__widget_templates__get.json');
12+
$id = 'c48b131a-ae9d-4767-b5d6-63d9e43bcf75';
1213

13-
$template = $this->getApi()->widgets()->template('c48b131a-ae9d-4767-b5d6-63d9e43bcf75')->get()->getTemplate();
14+
$template = $this->getApi()->widgets()->template($id)->get()->getTemplate();
1415
$this->assertEquals('Header Images', $template->name);
16+
$this->assertEquals("content/widget-templates/$id", $this->getLastRequestPath());
1517
}
1618

1719
public function testCanGetTemplates(): void
@@ -21,5 +23,6 @@ public function testCanGetTemplates(): void
2123
$templates = $this->getApi()->widgets()->templates()->getAll()->getTemplates();
2224
$this->assertCount(12, $templates);
2325
$this->assertEquals('{{{html}}}', $templates[2]->template);
26+
$this->assertEquals("content/widget-templates", $this->getLastRequestPath());
2427
}
2528
}

tests/BigCommerce/BigCommerceApiTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,9 @@ public function getLastRequest(): Request
6060
{
6161
return end($this->container)['request'];
6262
}
63+
64+
public function getLastRequestPath(): string
65+
{
66+
return $this->getLastRequest()->getUri()->getPath();
67+
}
6368
}

0 commit comments

Comments
 (0)