-
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
Feature/callback models #67 #69
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.
A few comments :)
@@ -0,0 +1,202 @@ | |||
{"NotificationUrl": { |
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.
Please prettify this json
and the others with some prettifier :)
src/Model/Core/BunqModel.php
Outdated
* | ||
* @return BunqModel | ||
*/ | ||
public static function fromJsonToModel(string $json): BunqModel |
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.
let's say createFromJsonString
@@ -0,0 +1,282 @@ | |||
<?php | |||
|
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.
Please remove this newline :P
const ASSERT_JSON_DECODE_ERROR = 'Might be that the JSON file is not a valid json.'; | ||
const ASSERT_OBJECT_IS_NULL_ERROR = 'Object seems to be 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.
Please remove this newline :D
*/ | ||
const ASSERT_SHOULD_NOT_REACH_THIS_CODE_ERROR = 'Something super weird just happen'; | ||
const ASSERT_JSON_DECODE_ERROR = 'Might be that the JSON file is not a valid json.'; | ||
const ASSERT_OBJECT_IS_NULL_ERROR = 'Object seems to be 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.
We probably would like to be a bit more formal with these :D
*/ | ||
private function executeTest(string $fileName, string $className, string $getterName) | ||
{ | ||
$jsonString = FileUtil::getFileContents($fileName); |
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.
Let's go for jsonExpected
or jsonExpectedString
private function getNotificationUrlFromJson(string $jsonString): NotificationUrl | ||
{ | ||
$json = json_decode($jsonString, true); | ||
static::assertNotNull($json, self::ASSERT_JSON_DECODE_ERROR); |
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.
Assertions like personal space (unless they stick to other assertions) or get anxious otherwise. Please surround this one with newlines :D
} | ||
|
||
/** | ||
* @param array $json |
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.
array of what? :P
} | ||
|
||
/** | ||
* @param array $json |
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.
array of what? :P
* | ||
* @return string | ||
*/ | ||
private function getNotificationObjectAsString(array $json) |
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.
Perhaps, getNotificationObjectJsonString
? :)
@dnl-blkv all yours 👀 |
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.
A few comments in the code + one general:
I see you have replaced in quite some places resource
folder name to Resource
. But did you also rename the folder itself?
Diff shows some additions, such as tests/resource/NotificationUrlJsons/BunqMeTab.json
, where resource
is not capitalised...
tests/README.md
Outdated
@@ -32,7 +32,7 @@ are also tested :thumbs_up:. | |||
## Configuration | |||
|
|||
To run the tests you must first setup the test configuration JSON. The example | |||
of a configuration file is located at [`tests/resource/config.example.json`](./resource/config.example.json). | |||
of a configuration file is located at [`tests/Resource/config.example.json`](Resource/config.example.json). |
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.
./
was OK :D
} | ||
} | ||
} | ||
} |
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.
Please add terminating newline
} | ||
} | ||
} | ||
} |
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.
Please add terminating newline
/** | ||
* Getter string constants | ||
*/ | ||
const GET_PAYMENT = 'getPayment'; |
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.
Let us prefix these with GETTER_
, e.g. GETTER_PAYMENT
@dnl-blkv yes the Folder has been renamed to Resource 🤔. At least thats what it says on my local machine might be that something went wrong with git 🤔. |
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.
A few more comments...
/** | ||
* Assertion errors. | ||
*/ | ||
const ASSERT_SHOULD_NOT_REACH_THIS_CODE_ERROR = 'Congratulations you\'ve reached unreachable code.'; |
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.
Please prefix all the error constants with ERROR_
(instead of _ERROR
suffix); Also please put them to the top of the file (since this is how we do it across the SDKs.
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.
Also, the text of this assertion doesn't seem to be very descriptive :(
return $model; | ||
} | ||
|
||
throw new BunqException(self::ASSERT_SHOULD_NOT_REACH_THIS_CODE_ERROR); |
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.
The name of the error constant (just as its content) does not reflect the actual cause of the error. Please adjust it!
* @param BunqModel $model | ||
* | ||
* @return NotificationUrl | ||
* @throws BunqException |
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.
Please add the explanation of when the error is thrown:
@throws BunqException when {something}
{ | ||
static::assertArrayHasKey(self::KEY_NOTIFICATION_URL_MODEL, $json); | ||
} | ||
} |
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.
Please rearrange methods in this class in accordance with the step-down rule (depth-first order).
const FIELD_PAYMENT = 'payment'; | ||
const FIELD_SCHEDULE = 'schedule'; | ||
|
||
/** | ||
* Object type. | ||
*/ | ||
const OBJECT_TYPE = 'SchedulePayment'; |
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.
Please include the fix for the OBJECT_TYPE
's of scheduled objects.
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.
Looks good!
Closes #67
Closes #70