Skip to content

Commit 9b61f65

Browse files
committed
Merge branch 'main' into fix/widget-template-api-endpoints-incorrect
Conflicts: RELEASE_NOTES.md
2 parents ec8e292 + 44a9277 commit 9b61f65

File tree

5 files changed

+34
-3
lines changed

5 files changed

+34
-3
lines changed

RELEASE_NOTES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@
55

66
### Fixed Issues
77

8+
- Fixed 404 errors on scripts api (#55), thanks to @kishan93
9+
- Fixed issue where subscribers API was not accessible
810
- Fixed issue where Widget Template endpoints were incorrect
911

src/BigCommerce/Api/Customers/CustomersApi.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace BigCommerce\ApiV3\Api\Customers;
44

55
use BigCommerce\ApiV3\Api\Generic\DeleteInIdList;
6+
use BigCommerce\ApiV3\Api\Subscribers\SubscribersApi;
67
use BigCommerce\ApiV3\ResponseModels\Customer\CustomersResponse;
78
use BigCommerce\ApiV3\ResourceModels\Customer\Customer;
89
use UnexpectedValueException;
@@ -84,4 +85,14 @@ public function consent(): CustomerConsentApi
8485

8586
return new CustomerConsentApi($this->getClient(), null, $this->getResourceId());
8687
}
88+
89+
public function subscriber(int $id): SubscribersApi
90+
{
91+
return new SubscribersApi($this->getClient(), $id, $this->getParentResourceId());
92+
}
93+
94+
public function subscribers(): SubscribersApi
95+
{
96+
return new SubscribersApi($this->getClient(), null, $this->getParentResourceId());
97+
}
8798
}

src/BigCommerce/Api/Subscribers/SubscribersApi.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
class SubscribersApi extends ResourceApi
1010
{
1111
private const RESOURCE_NAME = 'subscribers';
12-
private const SUBSCRIBER_ENDPOINT = 'customers/subscribers';
13-
private const SUBSCRIBERS_ENDPOINT = 'customers/subscribers/%d';
12+
private const SUBSCRIBERS_ENDPOINT = 'customers/subscribers';
13+
private const SUBSCRIBER_ENDPOINT = 'customers/subscribers/%d';
1414

1515
protected function singleResourceEndpoint(): string
1616
{

tests/BigCommerce/Api/Subscribers/SubscribersApiTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ public function testCanGetSubscriber(): void
1313

1414
public function testCanGetSubscribers(): void
1515
{
16-
$this->markTestIncomplete();
16+
$this->setReturnData('no-data-paginated.json');
17+
18+
$this->getApi()->customers()->subscribers()->getAll()->getSubscribers();
19+
$this->assertEquals('customers/subscribers', $this->getLastRequest()->getUri()->getPath());
1720
}
1821
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"data": [],
3+
"meta": {
4+
"pagination": {
5+
"total": 0,
6+
"count": 0,
7+
"per_page": 50,
8+
"current_page": 1,
9+
"total_pages": 0,
10+
"links": {
11+
"current": "?page=1&limit=50"
12+
}
13+
}
14+
}
15+
}

0 commit comments

Comments
 (0)