Skip to content

Commit ef78d97

Browse files
authored
Merge pull request #2 from knocklabs/cb-fix-objects-channel-data
fix: objects channel data
2 parents 0fcb792 + 25cfe13 commit ef78d97

File tree

8 files changed

+17
-6
lines changed

8 files changed

+17
-6
lines changed

src/Api/AbstractApi.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
use function array_filter;
66
use function array_merge;
77
use function count;
8+
89
use Http\Client\Exception;
910
use Knock\KnockSdk\Client;
1011
use Knock\KnockSdk\HttpClient\Message\ResponseMediator;
1112
use Knock\KnockSdk\HttpClient\Utils\JsonArray;
1213
use Knock\KnockSdk\HttpClient\Utils\QueryStringBuilder;
1314
use Psr\Http\Message\ResponseInterface;
15+
1416
use function sprintf;
1517

1618
abstract class AbstractApi

src/Api/Objects.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public function setPreferences(
152152
*/
153153
public function getChannelData(string $collection, string $objectId, string $channelId, array $headers = []): array
154154
{
155-
$url = $this->url('/object/%s/%s/channel_data/%s', $collection, $objectId, $channelId);
155+
$url = $this->url('/objects/%s/%s/channel_data/%s', $collection, $objectId, $channelId);
156156

157157
return $this->getRequest($url, [], $headers);
158158
}
@@ -173,7 +173,7 @@ public function setChannelData(
173173
array $body,
174174
array $headers = []
175175
): array {
176-
$url = $this->url('/object/%s/%s/channel_data/%s', $collection, $objectId, $channelId);
176+
$url = $this->url('/objects/%s/%s/channel_data/%s', $collection, $objectId, $channelId);
177177

178178
return $this->putRequest($url, $body, $headers);
179179
}
@@ -192,7 +192,7 @@ public function unsetChannelData(
192192
string $channelId,
193193
array $headers = []
194194
) {
195-
$url = $this->url('/object/%s/%s/channel_data/%s', $collection, $objectId, $channelId);
195+
$url = $this->url('/objects/%s/%s/channel_data/%s', $collection, $objectId, $channelId);
196196

197197
return $this->deleteRequest($url, [], $headers);
198198
}

src/HttpClient/Message/ResponseMediator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Knock\KnockSdk\HttpClient\Message;
44

55
use function is_array;
6+
67
use Knock\KnockSdk\Exception\RuntimeException;
78
use Knock\KnockSdk\HttpClient\Utils\JsonArray;
89
use Psr\Http\Message\ResponseInterface;

src/HttpClient/Utils/JsonArray.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@
44

55
use function json_decode;
66
use function json_encode;
7+
78
use const JSON_ERROR_NONE;
9+
810
use function json_last_error;
911
use function json_last_error_msg;
12+
1013
use Knock\KnockSdk\Exception\RuntimeException;
14+
1115
use function sprintf;
1216

1317
final class JsonArray

src/HttpClient/Utils/QueryStringBuilder.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
namespace Knock\KnockSdk\HttpClient\Utils;
44

55
use function count;
6+
67
use League\Uri\Components\Query;
8+
79
use function sprintf;
810

911
final class QueryStringBuilder

tests/Unit/Api/ApiTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Tests\Unit\Api;
44

55
use function array_merge;
6+
67
use Knock\KnockSdk\Client;
78
use Knock\KnockSdk\HttpClient\Builder;
89
use PHPUnit\Framework\MockObject\MockObject;

tests/Unit/Api/ObjectsTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public function will_get_object_channel_data()
171171
$objects = $this->getApiMock();
172172
$objects->expects($this->once())
173173
->method('getRequest')
174-
->with(sprintf('/object/%s/%s/channel_data/%s', $collection, $objectId, $channelId))
174+
->with(sprintf('/objects/%s/%s/channel_data/%s', $collection, $objectId, $channelId))
175175
->will($this->returnValue($expected));
176176

177177
$this->assertEquals($expected, $objects->getChannelData($collection, $objectId, $channelId));
@@ -189,7 +189,7 @@ public function will_set_object_channel_data()
189189
$objects = $this->getApiMock();
190190
$objects->expects($this->once())
191191
->method('putRequest')
192-
->with(sprintf('/object/%s/%s/channel_data/%s', $collection, $objectId, $channelId))
192+
->with(sprintf('/objects/%s/%s/channel_data/%s', $collection, $objectId, $channelId))
193193
->will($this->returnValue($expected));
194194

195195
$this->assertEquals($expected, $objects->setChannelData($collection, $objectId, $channelId, []));
@@ -207,7 +207,7 @@ public function will_unset_object_channel_data()
207207
$objects = $this->getApiMock();
208208
$objects->expects($this->once())
209209
->method('deleteRequest')
210-
->with(sprintf('/object/%s/%s/channel_data/%s', $collection, $objectId, $channelId))
210+
->with(sprintf('/objects/%s/%s/channel_data/%s', $collection, $objectId, $channelId))
211211
->will($this->returnValue($expected));
212212

213213
$this->assertEquals($expected, $objects->unsetChannelData($collection, $objectId, $channelId));

tests/Unit/HttpClient/Utils/QueryStringBuilderTest.php

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

55
use Knock\KnockSdk\HttpClient\Utils\QueryStringBuilder;
66
use PHPUnit\Framework\TestCase;
7+
78
use function sprintf;
89

910
class QueryStringBuilderTest extends TestCase

0 commit comments

Comments
 (0)