-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bunq-install should display error message and not installation util. (bunq/sdk_php#133) #136
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Jorijn Some changes.
Most of them are refactor of old code. Feel free to address them if not ill pick it up myself ;)
bin/bunq-install
Outdated
\bunq\Util\InstallationUtil::automaticInstall( | ||
try { | ||
if (empty($allOption)) { | ||
\bunq\Util\InstallationUtil::interactiveInstall(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import class instead of full namespace.
bin/bunq-install
Outdated
if (empty($allOption)) { | ||
\bunq\Util\InstallationUtil::interactiveInstall(); | ||
} else { | ||
\bunq\Util\InstallationUtil::automaticInstall( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
bin/bunq-install
Outdated
if (empty($allOption)) { | ||
\bunq\Util\InstallationUtil::interactiveInstall(); | ||
} else { | ||
\bunq\Util\InstallationUtil::automaticInstall( | ||
new \bunq\Util\BunqEnumApiEnvironmentType($allOption['environment']), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
bin/bunq-install
Outdated
); | ||
} | ||
} catch (bunq\Exception\BunqException $exception) { | ||
echo sprintf(\bunq\Util\InstallationUtil::ERROR_BUNQ_EXCEPTION, $exception->getMessage()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
bin/bunq-install
Outdated
} catch (bunq\Exception\BunqException $exception) { | ||
echo sprintf(\bunq\Util\InstallationUtil::ERROR_BUNQ_EXCEPTION, $exception->getMessage()); | ||
} catch (Exception $exception) { | ||
echo sprintf(\bunq\Util\InstallationUtil::ERROR_EXCEPTION, $exception->getMessage()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
src/Util/InstallationUtil.php
Outdated
$environmentType = new BunqEnumApiEnvironmentType(static::readLine( | ||
self::PROMPT_ENVIRONMENT, | ||
self::ERROR_EMPTY_ENVIRONMENT | ||
)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 bracket per line.
src/Util/InstallationUtil.php
Outdated
|
||
$contextFileName = static::readLineOrNull(self::PROMPT_CONTEXT_FILE); | ||
|
||
if ($contextFileName === null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: remove this if statement after #137
src/Util/InstallationUtil.php
Outdated
|
||
$methodRegisterDevice = static::createAccessibleReflectionMethod( | ||
if ($environmentType->equals(BunqEnumApiEnvironmentType::SANDBOX()) && is_null($apiKey)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic could be extracted in its own method.
src/Util/InstallationUtil.php
Outdated
); | ||
$methodInitializeSessionContext->invoke($context); | ||
|
||
if ($contextFileName === null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the method signature, this could never be null 😅
TODO: remove if statement after #137
src/Util/InstallationUtil.php
Outdated
} | ||
} | ||
|
||
/** | ||
* @param BunqEnumApiEnvironmentType $environmentType | ||
* @param string $contextFileName | ||
* @param string|null $apiKey | ||
* @throws BunqException | ||
*/ | ||
public static function automaticInstall( | ||
BunqEnumApiEnvironmentType $environmentType, | ||
string $contextFileName, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This field should be made optional
@sandervdo as I've also committed in this PR, please 👀 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/Util/InstallationUtil.php
Outdated
$methodInitializeInstallationContext->invoke($context); | ||
|
||
$description = static::readLine(self::PROMPT_DESCRIPTION, self::ERROR_EMPTY_DESCRIPTION); | ||
$permittedIpsInput = static::readLineOrNull(self::PROMPT_PERMITTED_IPS); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$allPermittedIpInput
src/Util/InstallationUtil.php
Outdated
|
||
$description = static::readLine(self::PROMPT_DESCRIPTION, self::ERROR_EMPTY_DESCRIPTION); | ||
$permittedIpsInput = static::readLineOrNull(self::PROMPT_PERMITTED_IPS); | ||
$permittedIps = static::formatIps($permittedIpsInput); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$allPermittedIp
src/Util/InstallationUtil.php
Outdated
|
||
$description = static::readLine(self::PROMPT_DESCRIPTION, self::ERROR_EMPTY_DESCRIPTION); | ||
$permittedIpsInput = static::readLineOrNull(self::PROMPT_PERMITTED_IPS); | ||
$permittedIps = static::formatIps($permittedIpsInput); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Method name; formatAllIp
(damn, that screws up readability big time in non-monospaced fonts,..)
@sandervdo pushed. |
src/Util/InstallationUtil.php
Outdated
|
||
$description = static::readLine(self::PROMPT_DESCRIPTION, self::ERROR_EMPTY_DESCRIPTION); | ||
$allPermittedIpInput = static::readLineOrNull(self::PROMPT_ALL_PERMITTED_IP); | ||
$allPermittedIp = static::formatIps($allPermittedIpInput); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Method name unchanged @OGKevin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops 🤦♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sandervdo done.
This PR closes/fixes the following issues:
needs #138