Skip to content

Commit 8d1b3b4

Browse files
authored
Bugfix/organisation get errors (#75)
* Removed organization URI prefix as already added by context * Fixed links decoding to match Jira get organization response
1 parent fbbc4a9 commit 8d1b3b4

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/ServiceDesk/Organisation/OrganisationService.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
class OrganisationService
1717
{
1818
private ServiceDeskClient $client;
19-
private string $uri = '/servicedeskapi/organization';
19+
private string $uri = '/organization';
2020
private LoggerInterface $logger;
2121
private JsonMapper $jsonMapper;
2222

@@ -198,7 +198,7 @@ private function createGetCustomersUrl(int $organisationId, int $startIndex, int
198198
private function createOrganisation(string $data): Organisation
199199
{
200200
return $this->jsonMapper->map(
201-
json_decode($data, false, 512, JSON_THROW_ON_ERROR),
201+
json_decode($data, true, 512, JSON_THROW_ON_ERROR),
202202
new Organisation()
203203
);
204204
}

tests/ServiceDesk/Organisation/OrganisationServiceTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
class OrganisationServiceTest extends TestCase
1616
{
17-
private string $uri = '/servicedeskapi/organization';
17+
private string $uri = '/organization';
1818

1919
public function testCreate(): void
2020
{
@@ -73,6 +73,7 @@ public function testGet(): void
7373
$item = [
7474
'id' => $id,
7575
'name' => 'Test organisation',
76+
'_links' => ['self' => 'http://example.com/rest/servicedeskapi/organization/' . $id],
7677
];
7778
$url = 'https://example.com/organisation/get';
7879

@@ -205,6 +206,8 @@ public function testDeleteOrganisation(): void
205206
private function createClient(): MockObject|ServiceDeskClient
206207
{
207208
$mapper = new JsonMapper();
209+
// Turned off as per ServiceDeskClient.
210+
$mapper->bEnforceMapType = false;
208211

209212
$client = $this->createMock(ServiceDeskClient::class);
210213
$client->method('getMapper')->willReturn($mapper);

0 commit comments

Comments
 (0)