Skip to content
This repository has been archived by the owner on Mar 5, 2024. It is now read-only.

Commit

Permalink
Implement associating customers with service desk
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexP11223 committed Feb 1, 2021
1 parent 28e9208 commit ea02907
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 7 deletions.
16 changes: 13 additions & 3 deletions src/ServiceDesk/ServiceDeskService.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function getServiceDesks(): PaginatedQueryInterface
/**
* @inheritDoc
*/
public function getCustomers(string $serviceDeskId, string $query = null): PaginatedQueryInterface
public function getCustomers($serviceDeskId, string $query = null): PaginatedQueryInterface
{
$this->allowExperimentalApi();

Expand All @@ -70,11 +70,21 @@ public function getCustomers(string $serviceDeskId, string $query = null): Pagin
});
}

/**
* @inheritDoc
*/
public function addCustomers($serviceDeskId, array $accountIds): void
{
$data = json_encode(['accountIds' => $accountIds]);

$this->exec($this->serviceDeskUri($serviceDeskId) . '/customer', $data);
}

/**
* @inheritDoc
*/
public function getRequestTypes(
string $serviceDeskId,
$serviceDeskId,
int $groupId = null,
string $searchQuery = null,
array $expand = null
Expand All @@ -99,7 +109,7 @@ public function getRequestTypes(
});
}

protected function serviceDeskUri(string $serviceDeskId): string {
protected function serviceDeskUri($serviceDeskId): string {
return $this->uri . "/$serviceDeskId";
}
}
18 changes: 14 additions & 4 deletions src/ServiceDesk/ServiceDeskServiceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,29 @@ public function getServiceDesks(): PaginatedQueryInterface;

/**
* Returns a paginated query object allowing to retrieve the customers with the specified query.
* @param string $serviceDeskId The ID of the service desk the customer list are to be returned from.
* @param string|int $serviceDeskId The ID of the service desk the customer list are to be returned from.
* This can alternatively be a project identifier. https://developer.atlassian.com/cloud/jira/service-desk/rest/intro/#request-language
* @param string|null $query The string used to filter the customer list.
* The parameter is matched against customers' displayName, name, or email.
* For example, searching for "John", "Jo", or "Smith" will match a user with display name "John Smith".
* @return PaginatedQueryInterface<UserInterface>
* @link https://developer.atlassian.com/cloud/jira/service-desk/rest/api-group-servicedesk/#api-rest-servicedeskapi-servicedesk-servicedeskid-customer-get
*/
public function getCustomers(string $serviceDeskId, string $query = null): PaginatedQueryInterface;
public function getCustomers($serviceDeskId, string $query = null): PaginatedQueryInterface;

/**
* Adds one or more customers to a service desk.
* If any of the passed customers are associated with the service desk, no changes will be made for those customers.
* @param string|int $serviceDeskId The ID of the service desk the customer list are to be returned from.
* This can alternatively be a project identifier. https://developer.atlassian.com/cloud/jira/service-desk/rest/intro/#request-language
* @param string[] $accountIds List of user account IDs, to add to the service desk.
* @link https://developer.atlassian.com/cloud/jira/service-desk/rest/api-group-servicedesk/#api-rest-servicedeskapi-servicedesk-servicedeskid-customer-post
*/
public function addCustomers($serviceDeskId, array $accountIds): void;

/**
* Returns a paginated query object allowing to retrieve all customer request types from a service desk.
* @param string $serviceDeskId The ID of the service desk the request types are to be returned from.
* @param string|int $serviceDeskId The ID of the service desk the request types are to be returned from.
* This can alternatively be a project identifier. https://developer.atlassian.com/cloud/jira/service-desk/rest/intro/#request-language
* @param int|null $groupId Filters results to those in a customer request type group.
* @param string|null $searchQuery The string used to filter the request types.
Expand All @@ -45,7 +55,7 @@ public function getCustomers(string $serviceDeskId, string $query = null): Pagin
* @link https://developer.atlassian.com/cloud/jira/service-desk/rest/api-group-servicedesk/#api-rest-servicedeskapi-servicedesk-servicedeskid-requesttype-get
*/
public function getRequestTypes(
string $serviceDeskId,
$serviceDeskId,
int $groupId = null,
string $searchQuery = null,
array $expand = null
Expand Down
9 changes: 9 additions & 0 deletions tests/ServiceDesk/ServiceDeskServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ public function testFindCustomers(UserInterface $userToFind)
self::assertEquals($userToFind->getEmailAddress(), $user->getEmailAddress());
}

/**
* @depends testGetCustomers
* @doesNotPerformAssertions
*/
public function testAddCustomers(UserInterface $user)
{
$this->sut->addCustomers($this->serviceDeskId, [$user->getAccountId()]);
}

public function testGetRequestTypes()
{
$query = $this->sut->getRequestTypes($this->serviceDeskId, null, null, ['field']);
Expand Down

0 comments on commit ea02907

Please sign in to comment.