Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
sayan goswami committed Jun 13, 2023
1 parent 46a3f69 commit e9ca718
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
23 changes: 15 additions & 8 deletions src/Helper/Log/GoogleApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ class GoogleApiClient {
*/
private $googleApiRefreshToken;

/**
* Spreadsheet id of the Google Sheet.
*/
private CONST SPREAD_SHEET_ID = "1CllNKp9W1x0t_B3kKJhsJa5lMAevpxTSgIid4aOz2cE";

/**
* The sheet id of the spreadsheet.
*/
private CONST SHEET_ID = "Sheet1";

/**
* Constructs an instance.
*
Expand All @@ -75,9 +85,9 @@ class GoogleApiClient {
public function __construct(HttpClientInterface $http_client,
SymfonyStyle $output,
DrupalCoreVersionResolver $coreVersionResolver,
$google_api_client_id,
$google_api_client_secret,
$google_refresh_token) {
string|null $google_api_client_id,
string|null $google_api_client_secret,
string|null $google_refresh_token) {
$this->httpClient = $http_client;
$this->output = $output;
$this->version = $coreVersionResolver;
Expand All @@ -89,12 +99,11 @@ public function __construct(HttpClientInterface $http_client,
/**
* Gets the oldest supported branch of Drupal core.
*
* @throws \Acquia\Orca\Exception\OrcaHttpException
* @throws \Acquia\Orca\Exception\OrcaVersionNotFoundException
*/
public function postData(array $data): void {

// Skip tests that have versions defined but are not running.
// Skip tests that have versions defined but are redundant and exits early.
// If version is null--e.g., for STATIC_CODE_ANALYSIS jobs--then send data
// as it is.
if (is_null($data['version'])) {
Expand All @@ -110,8 +119,6 @@ public function postData(array $data): void {

$this->output->section("Sending data to Google sheet");

$spread_sheet_id = "1CllNKp9W1x0t_B3kKJhsJa5lMAevpxTSgIid4aOz2cE";
$sheet_id = "Sheet1";
$access_token = $this->getToken();
if (is_null($access_token)) {
return;
Expand Down Expand Up @@ -145,7 +152,7 @@ public function postData(array $data): void {
$response = $this->httpClient
->request(
'POST',
'https://sheets.googleapis.com/v4/spreadsheets/' . $spread_sheet_id . '/values/' . $sheet_id . ':append',
'https://sheets.googleapis.com/v4/spreadsheets/' . self::SPREAD_SHEET_ID . '/values/' . self::SHEET_ID . ':append',
$options
);

Expand Down
2 changes: 0 additions & 2 deletions tests/Helper/Log/GoogleApiClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ protected function createGoogleClient(): GoogleApiClient {
}

/**
* @throws \Acquia\Orca\Exception\OrcaHttpException
* @throws \Acquia\Orca\Exception\OrcaVersionNotFoundException
*/
public function testPostDataWithNullVersion(): void {
Expand All @@ -90,7 +89,6 @@ public function testPostDataWithNullVersion(): void {
}

/**
* @throws \Acquia\Orca\Exception\OrcaHttpException
* @throws \Acquia\Orca\Exception\OrcaVersionNotFoundException
*/
public function testPostDataWithLatestDrupalVersion(): void {
Expand Down

0 comments on commit e9ca718

Please sign in to comment.