1818use GuzzleHttp \Exception \TransferException ;
1919use GuzzleHttp \RequestOptions ;
2020use Psr \Http \Message \ResponseInterface ;
21+ use TxTextControl \ReportingCloud \Assert \Assert ;
2122use TxTextControl \ReportingCloud \Exception \InvalidArgumentException ;
2223use TxTextControl \ReportingCloud \Exception \RuntimeException ;
2324use TxTextControl \ReportingCloud \Filter \Filter ;
2425use TxTextControl \ReportingCloud \Stdlib \ConsoleUtils ;
25- use TxTextControl \ReportingCloud \Stdlib \StringUtils ;
2626
2727/**
2828 * Abstract ReportingCloud
@@ -60,35 +60,35 @@ abstract class AbstractReportingCloud
6060 *
6161 * @const DEFAULT_BASE_URI
6262 */
63- protected const DEFAULT_BASE_URI = 'https://api.reporting.cloud ' ;
63+ public const DEFAULT_BASE_URI = 'https://api.reporting.cloud ' ;
6464
6565 /**
66- * Default version string of backend
66+ * Default debug flag of REST client
6767 *
68- * @const DEFAULT_VERSION
68+ * @const DEFAULT_DEBUG
6969 */
70- protected const DEFAULT_VERSION = ' v1 ' ;
70+ protected const DEFAULT_DEBUG = false ;
7171
7272 /**
73- * Default timeout of backend in seconds
73+ * Default test flag of backend
7474 *
75- * @const DEFAULT_TIMEOUT
75+ * @const DEFAULT_TEST
7676 */
77- protected const DEFAULT_TIMEOUT = 120 ;
77+ protected const DEFAULT_TEST = false ;
7878
7979 /**
80- * Default test flag of backend
80+ * Default timeout of backend in seconds
8181 *
82- * @const DEFAULT_TEST
82+ * @const DEFAULT_TIMEOUT
8383 */
84- protected const DEFAULT_TEST = false ;
84+ protected const DEFAULT_TIMEOUT = 120 ;
8585
8686 /**
87- * Default debug flag of REST client
87+ * Default version string of backend
8888 *
89- * @const DEFAULT_DEBUG
89+ * @const DEFAULT_VERSION
9090 */
91- protected const DEFAULT_DEBUG = false ;
91+ protected const DEFAULT_VERSION = ' v1 ' ;
9292
9393 // </editor-fold>
9494
@@ -506,7 +506,7 @@ public function getClient(): ?Client
506506 if (!$ this ->client instanceof Client) {
507507
508508 $ headers = [
509- 'Authorization ' => $ this ->getAuthorizationHeader ()
509+ 'Authorization ' => $ this ->getAuthorizationHeader (),
510510 ];
511511
512512 $ options = [
@@ -546,7 +546,8 @@ public function setClient(Client $client): self
546546 protected function setDefaultOptions (): self
547547 {
548548 if (null === $ this ->getBaseUri ()) {
549- $ baseUri = $ this ->getBaseUriFromConstOrEnvVar () ?? self ::DEFAULT_BASE_URI ;
549+ $ baseUri = ConsoleUtils::baseUri () ?? self ::DEFAULT_BASE_URI ;
550+ Assert::assertBaseUri ($ baseUri );
550551 $ this ->setBaseUri ($ baseUri );
551552 }
552553
@@ -569,35 +570,6 @@ protected function setDefaultOptions(): self
569570 return $ this ;
570571 }
571572
572- /**
573- * Return the base URI from the PHP const or environment variable "REPORTING_CLOUD_BASE_URI",
574- * checking that the hostname and sub-domain match the known hostname and sub-domain.
575- *
576- * Return null, if the environment variable has not been set or is empty.
577- *
578- * @throws InvalidArgumentException
579- * @return string|null
580- */
581- protected function getBaseUriFromConstOrEnvVar (): ?string
582- {
583- $ baseUri = ConsoleUtils::baseUri ();
584-
585- if (empty ($ baseUri )) {
586- return null ;
587- }
588-
589- $ sdkHost = (string ) parse_url (self ::DEFAULT_BASE_URI , PHP_URL_HOST );
590- $ envHost = (string ) parse_url ($ baseUri , PHP_URL_HOST );
591-
592- if (!StringUtils::endsWith ($ envHost , $ sdkHost )) {
593- $ format = 'Base URI from environment variable "%s" with value "%s" does not end in "%s" ' ;
594- $ message = sprintf ($ format , ConsoleUtils::BASE_URI , $ baseUri , $ sdkHost );
595- throw new InvalidArgumentException ($ message );
596- }
597-
598- return $ baseUri ;
599- }
600-
601573 /**
602574 * Request the URI with options
603575 *
0 commit comments