/**
  * @param Account $account
  * @internal param $accessToken
  * @internal param $refreshToken
  * @return RestApi
  */
 protected function getApi(Account $account)
 {
     /** @var RestApi $gaApi */
     $gaApi = $this->container->get('ex_google_analytics.rest_api');
     $gaApi->getApi()->setCredentials($account->getAccessToken(), $account->getRefreshToken());
     $extractor = new Extractor($gaApi, $this->logger, $this->temp);
     $extractor->setConfiguration($this->getConfiguration());
     $extractor->setCurrAccountId($account->getAccountId());
     $gaApi->getApi()->setRefreshTokenCallback([$extractor, 'refreshTokenCallback']);
     $gaApi->getApi()->setBackoffCallback403($extractor->getBackoffCallback403());
     return $gaApi;
 }
Exemplo n.º 2
0
 protected function getOutputTable(Account $account, $tableName)
 {
     $outputBucket = $this->configuration->getInBucketId($account->getAccountId());
     if ($account->getAttribute('outputBucket') != null) {
         $outputBucket = $account->getAttribute('outputBucket');
     }
     return $outputBucket . '.' . $tableName;
 }
 public function addProfile(Account $account, array $data)
 {
     $exists = false;
     foreach ($account->getProfiles() as $profile) {
         /** @var Profile $profile */
         if ($profile->getGoogleId() == $data['googleId']) {
             $exists = true;
             break;
         }
     }
     if (!$exists) {
         $account->addProfile(new Profile($data));
         $account->save();
     }
 }