Skip to content
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

Merged
merged 13 commits into from
Apr 9, 2018

Conversation

Jorijn
Copy link
Contributor

@Jorijn Jorijn commented Apr 7, 2018

This PR closes/fixes the following issues:

needs #138

@bunq bunq deleted a comment Apr 7, 2018
@OGKevin OGKevin changed the title separated responsibilities: displaying the error message belongs to t… Bunq-install should display error message and not installation util. (bunq/sdk_php#133) Apr 7, 2018
@OGKevin OGKevin self-requested a review April 7, 2018 15:34
@OGKevin OGKevin added this to To do in 1.0.0 - SDK via automation Apr 7, 2018
@OGKevin OGKevin added this to the 0.13.5 milestone Apr 7, 2018
Copy link
Contributor

@OGKevin OGKevin left a 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();
Copy link
Contributor

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(
Copy link
Contributor

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']),
Copy link
Contributor

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());
Copy link
Contributor

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());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

$environmentType = new BunqEnumApiEnvironmentType(static::readLine(
self::PROMPT_ENVIRONMENT,
self::ERROR_EMPTY_ENVIRONMENT
));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 bracket per line.


$contextFileName = static::readLineOrNull(self::PROMPT_CONTEXT_FILE);

if ($contextFileName === null) {
Copy link
Contributor

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


$methodRegisterDevice = static::createAccessibleReflectionMethod(
if ($environmentType->equals(BunqEnumApiEnvironmentType::SANDBOX()) && is_null($apiKey)) {
Copy link
Contributor

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.

);
$methodInitializeSessionContext->invoke($context);

if ($contextFileName === null) {
Copy link
Contributor

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

}
}

/**
* @param BunqEnumApiEnvironmentType $environmentType
* @param string $contextFileName
* @param string|null $apiKey
* @throws BunqException
*/
public static function automaticInstall(
BunqEnumApiEnvironmentType $environmentType,
string $contextFileName,
Copy link
Contributor

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

@OGKevin OGKevin moved this from To do to open PR in 1.0.0 - SDK Apr 7, 2018
@bunq bunq deleted a comment Apr 7, 2018
@bunq bunq deleted a comment Apr 9, 2018
@bunq bunq deleted a comment Apr 9, 2018
OGKevin
OGKevin previously approved these changes Apr 9, 2018
@bunq bunq deleted a comment Apr 9, 2018
@OGKevin
Copy link
Contributor

OGKevin commented Apr 9, 2018

@sandervdo as I've also committed in this PR, please 👀

@OGKevin OGKevin requested a review from sandervdo April 9, 2018 09:13
Copy link
Contributor

@sandervdo sandervdo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$methodInitializeInstallationContext->invoke($context);

$description = static::readLine(self::PROMPT_DESCRIPTION, self::ERROR_EMPTY_DESCRIPTION);
$permittedIpsInput = static::readLineOrNull(self::PROMPT_PERMITTED_IPS);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$allPermittedIpInput


$description = static::readLine(self::PROMPT_DESCRIPTION, self::ERROR_EMPTY_DESCRIPTION);
$permittedIpsInput = static::readLineOrNull(self::PROMPT_PERMITTED_IPS);
$permittedIps = static::formatIps($permittedIpsInput);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$allPermittedIp


$description = static::readLine(self::PROMPT_DESCRIPTION, self::ERROR_EMPTY_DESCRIPTION);
$permittedIpsInput = static::readLineOrNull(self::PROMPT_PERMITTED_IPS);
$permittedIps = static::formatIps($permittedIpsInput);
Copy link
Contributor

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,..)

@bunq bunq deleted a comment Apr 9, 2018
@OGKevin
Copy link
Contributor

OGKevin commented Apr 9, 2018

@sandervdo pushed.


$description = static::readLine(self::PROMPT_DESCRIPTION, self::ERROR_EMPTY_DESCRIPTION);
$allPermittedIpInput = static::readLineOrNull(self::PROMPT_ALL_PERMITTED_IP);
$allPermittedIp = static::formatIps($allPermittedIpInput);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method name unchanged @OGKevin

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops 🤦‍♂️

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sandervdo done.

@bunq bunq deleted a comment Apr 9, 2018
@bunq bunq deleted a comment Apr 9, 2018
@OGKevin OGKevin merged commit 34152ff into bunq:develop Apr 9, 2018
1.0.0 - SDK automation moved this from open PR to merged Apr 9, 2018
@OGKevin
Copy link
Contributor

OGKevin commented Apr 9, 2018

@andrederoos

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
1.0.0 - SDK
  
merged
Development

Successfully merging this pull request may close these issues.

Separation of concerns: InstallationUtil class is displaying error messages
3 participants