MCPcopy Create free account
hub / github.com/Rello/analytics / ExternalJson

Class ExternalJson

lib/Datasource/ExternalJson.php:15–305  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13use Psr\Log\LoggerInterface;
14
15class ExternalJson implements IDatasource
16{
17 private const CACHE_TTL_SECONDS = 30;
18
19 private LoggerInterface $logger;
20 private IL10N $l10n;
21 private ExternalHttpClient $httpClient;
22
23 public function __construct(
24 IL10N $l10n,
25 LoggerInterface $logger,
26 ExternalHttpClient $httpClient,
27 )
28 {
29 $this->l10n = $l10n;
30 $this->logger = $logger;
31 $this->httpClient = $httpClient;
32 }
33
34 /**
35 * @return string Display Name of the data source
36 */
37 public function getName(): string
38 {
39 return $this->l10n->t('External') . ': JSON';
40 }
41
42 /**
43 * @return int digit unique data source id
44 */
45 public function getId(): int
46 {
47 return 6;
48 }
49
50 /**
51 * @return array available options of the data source
52 */
53 public function getTemplate(): array
54 {
55 $template = array();
56 $template[] = ['id' => 'url', 'name' => 'URL', 'placeholder' => 'url'];
57 $template[] = ['id' => 'method', 'name' => $this->l10n->t('HTTP method'), 'placeholder' => 'GET/POST', 'type' => 'tf'];
58 $template[] = ['id' => 'path', 'name' => $this->l10n->t('Object path'), 'placeholder' => 'x/y/z'];
59 $template[] = ['id' => 'section', 'name' => $this->l10n->t('More options'), 'type' => 'section'];
60 $template[] = ['id' => 'content-type', 'name' => 'Header Content-Type', 'placeholder' => 'application/json'];
61 $template[] = ['id' => 'customHeaders', 'name' => 'Custom headers', 'placeholder' => 'key: value,key: value'];
62 $template[] = ['id' => 'auth', 'name' => $this->l10n->t('Authentication'), 'placeholder' => 'User:Password'];
63 $template[] = ['id' => 'body', 'name' => 'Request body', 'placeholder' => ''];
64 $template[] = ['id' => 'timestamp', 'name' => $this->l10n->t('Timestamp of data load'), 'placeholder' => 'true-' . $this->l10n->t('Yes') . '/false-' . $this->l10n->t('No'), 'type' => 'tf'];
65 return $template;
66 }
67
68 /**
69 * Read the Data
70 * @param $option
71 * @return array available options of the data source
72 */

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected