Skip to content

Commit

Permalink
ACP-2148 Stripe Configuration/Disconnect is not working (#55)
Browse files Browse the repository at this point in the history
* ACP-2148 Added option to pass ApiBAseUrl as well as BaseUrl.
  • Loading branch information
stereomon authored Jan 16, 2024
1 parent bc1cbde commit 055abc3
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/registration.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ To see all options this command provides run it with
`vendor/bin/acp app:register -h` this will print all available options.

The following options are required to be set:

- `appIdentifier`
- `baseUrl`
- `authorizationToken`

Additionally, you can set the following options:

- `apiBaseUrl` - Use this option when your App has an API that is not hosted on the same domain as the App itself.
2 changes: 2 additions & 0 deletions src/SprykerSdk/Acp/Console/RegisterConsole.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ protected function configure(): void
->setDescription('Registers an App in ACP. When the App already exists in ACP it will be updated automatically.')
->addOption('appIdentifier', null, InputOption::VALUE_REQUIRED, 'The App Identifier of your App.')
->addOption('baseUrl', null, InputOption::VALUE_REQUIRED, 'The base URL to your App for app assets and APIs.')
->addOption('apiBaseUrl', null, InputOption::VALUE_OPTIONAL, 'The API base URL to your App for the App APIs. (Only needed when the App has different URLs for the App and the APIs.))')
->addOption('registryUrl', null, InputOption::VALUE_OPTIONAL, 'The base URL to the Registry Service (local, testing, staging)', 'https://api.atrs.spryker.com')
->addOption('authorizationToken', null, InputOption::VALUE_REQUIRED, 'The Token that is required to be able to send requests to the Registry Service.')
->addOption(AppConfigurationValidateConsole::CONFIGURATION_FILE, AppConfigurationValidateConsole::CONFIGURATION_FILE_SHORT, InputOption::VALUE_OPTIONAL, '', $this->getConfig()->getDefaultConfigurationFile())
Expand Down Expand Up @@ -132,6 +133,7 @@ protected function register(InputInterface $input, OutputInterface $output): int
$registerRequestTransfer->setRegistryUrl($input->getOption('registryUrl'));
$registerRequestTransfer->setAuthorizationToken($input->getOption('authorizationToken'));
$registerRequestTransfer->setBaseUrl($input->getOption('baseUrl'));
$registerRequestTransfer->setApiBaseUrl($input->getOption('apiBaseUrl'));

$registerRequestTransfer->setManifestPath($input->getOption(AppManifestValidateConsole::MANIFEST_PATH));
$registerRequestTransfer->setConfigurationFile($input->getOption(AppConfigurationValidateConsole::CONFIGURATION_FILE));
Expand Down
1 change: 1 addition & 0 deletions src/SprykerSdk/Acp/Registrator/RequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ protected function getBody(RegisterRequestTransfer $registerRequestTransfer): ar
'attributes' => [
'id' => $registerRequestTransfer->getAppIdentifierOrFail(),
'baseUrl' => rtrim($registerRequestTransfer->getBaseUrlOrFail(), '/'),
'apiBaseUrl' => $registerRequestTransfer->getApiBaseUrl() ? rtrim($registerRequestTransfer->getApiBaseUrl(), '/') : null,
'api' => json_encode($this->getJsonContentFromFile($registerRequestTransfer->getAcpApiFileOrFail(), $this->getDefaultApi())),
'configuration' => json_encode($this->getJsonContentFromFile($registerRequestTransfer->getConfigurationFileOrFail())),
'translation' => json_encode($this->getJsonContentFromFile($registerRequestTransfer->getTranslationFileOrFail())),
Expand Down
98 changes: 98 additions & 0 deletions src/Transfer/RegisterRequestTransfer.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ class RegisterRequestTransfer extends AbstractTransfer
*/
public const BASE_URL = 'baseUrl';

/**
* @var string
*/
public const API_BASE_URL = 'apiBaseUrl';

/**
* @var string
*/
Expand Down Expand Up @@ -92,6 +97,11 @@ class RegisterRequestTransfer extends AbstractTransfer
*/
protected $baseUrl;

/**
* @var string|null
*/
protected $apiBaseUrl;

/**
* @var string|null
*/
Expand Down Expand Up @@ -133,6 +143,9 @@ class RegisterRequestTransfer extends AbstractTransfer
'base_url' => 'baseUrl',
'baseUrl' => 'baseUrl',
'BaseUrl' => 'baseUrl',
'api_base_url' => 'apiBaseUrl',
'apiBaseUrl' => 'apiBaseUrl',
'ApiBaseUrl' => 'apiBaseUrl',
'manifest_path' => 'manifestPath',
'manifestPath' => 'manifestPath',
'ManifestPath' => 'manifestPath',
Expand Down Expand Up @@ -223,6 +236,18 @@ class RegisterRequestTransfer extends AbstractTransfer
'is_nullable' => false,
'is_strict' => false,
],
self::API_BASE_URL => [
'type' => 'string',
'type_shim' => null,
'name_underscore' => 'api_base_url',
'is_collection' => false,
'is_transfer' => false,
'is_value_object' => false,
'rest_request_parameter' => 'no',
'is_associative' => false,
'is_nullable' => false,
'is_strict' => false,
],
self::MANIFEST_PATH => [
'type' => 'string',
'type_shim' => null,
Expand Down Expand Up @@ -711,6 +736,79 @@ public function requireBaseUrl()
return $this;
}

/**
* @module Test
*
* @param string|null $apiBaseUrl
*
* @return $this
*/
public function setApiBaseUrl($apiBaseUrl)
{
$this->apiBaseUrl = $apiBaseUrl;
$this->modifiedProperties[self::API_BASE_URL] = true;

return $this;
}

/**
* @module Test
*
* @return string|null
*/
public function getApiBaseUrl()
{
return $this->apiBaseUrl;
}

/**
* @module Test
*
* @param string|null $apiBaseUrl
*
* @throws \Spryker\Shared\Kernel\Transfer\Exception\NullValueException
*
* @return $this
*/
public function setApiBaseUrlOrFail($apiBaseUrl)
{
if ($apiBaseUrl === null) {
$this->throwNullValueException(static::API_BASE_URL);
}

return $this->setApiBaseUrl($apiBaseUrl);
}

/**
* @module Test
*
* @throws \Spryker\Shared\Kernel\Transfer\Exception\NullValueException
*
* @return string
*/
public function getApiBaseUrlOrFail()
{
if ($this->apiBaseUrl === null) {
$this->throwNullValueException(static::API_BASE_URL);
}

return $this->apiBaseUrl;
}

/**
* @module Test
*
* @throws \Spryker\Shared\Kernel\Transfer\Exception\RequiredTransferPropertyException
*
* @return $this
*/
public function requireApiBaseUrl()
{
$this->assertPropertyIsSet(self::API_BASE_URL);

return $this;
}

/**
* @module Test
*
Expand Down

0 comments on commit 055abc3

Please sign in to comment.