/**
  * @param Integration $integration
  *
  * @return string
  */
 protected function getIntegrationSummary(Integration $integration)
 {
     $details = $integration->getProperties();
     unset($details['id'], $details['type']);
     switch ($integration->type) {
         case 'github':
         case 'bitbucket':
             $summary = sprintf('Repository: %s', $details['repository']);
             if ($integration->hasLink('#hook')) {
                 $summary .= "\n" . sprintf('Hook URL: %s', $integration->getLink('#hook'));
             }
             break;
         case 'hipchat':
             $summary = sprintf('Room ID: %s', $details['room']);
             break;
         case 'webhook':
             $summary = sprintf('URL: %s', $details['url']);
             break;
         default:
             $summary = json_encode($details);
     }
     if (strlen($summary) > 240) {
         $summary = substr($summary, 0, 237) . '...';
     }
     return $summary;
 }
 /**
  * @param Integration     $integration
  * @param InputInterface  $input
  * @param OutputInterface $output
  */
 protected function displayIntegration(Integration $integration, InputInterface $input, OutputInterface $output)
 {
     $table = new Table($input, $output);
     $info = [];
     foreach ($integration->getProperties() as $property => $value) {
         $info[$property] = $this->propertyFormatter->format($value, $property);
     }
     if ($integration->hasLink('#hook')) {
         $info['hook_url'] = $this->propertyFormatter->format($integration->getLink('#hook'));
     }
     $table->renderSimple(array_values($info), array_keys($info));
 }
 /**
  * @param Integration $integration
  *
  * @return string
  */
 protected function formatIntegrationData(Integration $integration)
 {
     $properties = $integration->getProperties();
     $info = [];
     if ($properties['type'] == 'github') {
         $info["Repository"] = $properties['repository'];
         $info["Build PRs"] = $properties['build_pull_requests'] ? 'yes' : 'no';
         $info["Fetch branches"] = $properties['fetch_branches'] ? 'yes' : 'no';
         $info["Payload URL"] = $integration->hasLink('#hook') ? $integration->getLink('#hook', true) : '[unknown]';
     } elseif ($properties['type'] == 'bitbucket') {
         $info["Repository"] = $properties['repository'];
         $info["Fetch branches"] = $properties['fetch_branches'] ? 'yes' : 'no';
         $info["Prune branches"] = $properties['prune_branches'] ? 'yes' : 'no';
         $info["Payload URL"] = $integration->hasLink('#hook') ? $integration->getLink('#hook', true) : '[unknown]';
     } elseif ($properties['type'] == 'hipchat') {
         $info["Room ID"] = $properties['room'];
         $info["Events"] = implode(', ', $properties['events']);
         $info["States"] = implode(', ', $properties['states']);
     } elseif ($properties['type'] == 'webhook') {
         $info["URL"] = $properties['url'];
     }
     $output = '';
     foreach ($info as $label => $value) {
         $output .= "{$label}: {$value}\n";
     }
     return rtrim($output);
 }
 /**
  * @param Integration $integration
  *
  * @return string
  */
 protected function formatIntegrationData(Integration $integration)
 {
     $properties = $integration->getProperties();
     $output = '';
     if ($properties['type'] == 'github') {
         $payloadUrl = $integration->hasLink('#hook') ? $integration->getLink('#hook', true) : '[unknown]';
         $output = "Repository: " . $properties['repository'] . "\nBuild PRs: " . ($properties['build_pull_requests'] ? 'yes' : 'no') . "\nFetch branches: " . ($properties['fetch_branches'] ? 'yes' : 'no') . "\nPayload URL: " . $payloadUrl;
     } elseif ($properties['type'] == 'hipchat') {
         $output = "Room ID: " . $properties['room'] . "\nEvents: " . implode(', ', $properties['events']) . "\nStates: " . implode(', ', $properties['states']);
     } elseif ($properties['type'] == 'webhook') {
         $output = "URL: " . $properties['url'];
     }
     return $output;
 }