Skip to content

Commit

Permalink
add internal methods for requests to ExApps by appid
Browse files Browse the repository at this point in the history
Signed-off-by: Andrey Borysenko <[email protected]>
  • Loading branch information
andrey18106 committed Nov 8, 2023
1 parent 39bf43a commit 85797eb
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions lib/Service/AppAPIService.php
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,66 @@ public function aeRequestToExApp(
return $this->requestToExApp($request, $userId, $exApp, $route, $method, $params);
}

/**
* Request to ExApp by appId with AppAPI auth headers and ExApp user initialization
*
* @param IRequest|null $request
* @param string $userId
* @param string $appId
* @param string $route
* @param string $method
* @param array $params
*
* @return array|IResponse
*/
public function aeRequestToExAppById(
?IRequest $request,
string $userId,
string $appId,
string $route,
string $method = 'POST',
array $params = []
): array|IResponse {
$exApp = $this->getExApp($appId);
if ($exApp === null) {
return ['error' => 'ExApp not found'];
}
try {
$this->exAppUsersService->setupExAppUser($exApp, $userId);
} catch (\Exception $e) {
$this->logger->error(sprintf('Error while inserting ExApp %s user. Error: %s', $exApp->getAppid(), $e->getMessage()), ['exception' => $e]);
return ['error' => 'Error while inserting ExApp user: ' . $e->getMessage()];
}
return $this->aeRequestToExApp($request, $userId, $exApp, $route, $method, $params);
}

/**
* Request to ExApp by appId with AppAPI auth headers
*
* @param IRequest|null $request
* @param string $userId
* @param string $appId
* @param string $route
* @param string $method
* @param array $params
*
* @return array|IResponse
*/
public function requestToExAppById(
?IRequest $request,
string $userId,
string $appId,
string $route,
string $method = 'POST',
array $params = []
): array|IResponse {
$exApp = $this->getExApp($appId);
if ($exApp === null) {
return ['error' => 'ExApp not found'];
}
return $this->requestToExApp($request, $userId, $exApp, $route, $method, $params);
}

/**
* Request to ExApp with AppAPI auth headers
*
Expand Down

0 comments on commit 85797eb

Please sign in to comment.