-
Notifications
You must be signed in to change notification settings - Fork 22
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
Constants following PascalCase convention #71
base: develop
Are you sure you want to change the base?
Constants following PascalCase convention #71
Conversation
@AnTao 😁 Nice on getting the commits right! And thanks for this pull request! |
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 questions and a note regarding environment constants.
|
||
private static ApiContext apiContext; | ||
private static ApiContext _apiContext; |
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.
Why the leading _
?
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.
I believe it was resharper doing some work 'automatically'. Shall I revert the underscore on all the private variables?
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.
Yes please revert the _
, unless there is a style guide entry that is supporting this _
👍
@@ -58,8 +58,8 @@ private static string UploadAvatarAndGetUuid(byte[] fileContentByte) | |||
{ | |||
var customHeaders = new Dictionary<string, string> | |||
{ | |||
{ApiClient.HEADER_ATTACHMENT_DESCRIPTION, ATTACHMENT_DECSRIPTION}, | |||
{ApiClient.HEADER_CONTENT_TYPE, CONTEN_TYPE}, | |||
{ApiClient.HeaderAttachmentDescription, ATTACHMENT_DECSRIPTION}, |
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.
ATTACHMENT_DECSRIPTION
is still in caps.
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.
I might have missed this ones, changing it.
{ApiClient.HEADER_ATTACHMENT_DESCRIPTION, ATTACHMENT_DECSRIPTION}, | ||
{ApiClient.HEADER_CONTENT_TYPE, CONTEN_TYPE}, | ||
{ApiClient.HeaderAttachmentDescription, ATTACHMENT_DECSRIPTION}, | ||
{ApiClient.HeaderContentType, CONTEN_TYPE}, |
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.
CONTEN_TYPE
is still in caps.
There seems to be a few constants in this file that have not been refactored, please refactor them.
BunqSdk/Http/ApiClient.cs
Outdated
|
||
private readonly HttpClient client; | ||
private readonly HttpClient _client; |
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.
Why the leading _
?
BunqSdk/Http/ApiClient.cs
Outdated
|
||
private readonly ApiContext apiContext; | ||
private readonly ApiContext _apiContext; |
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.
Why the leading _
?
BunqSdk/Json/BunqJsonConvert.cs
Outdated
|
||
private static bool isInitialized; | ||
private static bool _isInitialized; |
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.
Why the leading _
?
BunqSdk/Model/Core/Installation.cs
Outdated
|
||
public SessionToken SessionToken { get; private set; } | ||
private readonly Id id; | ||
private readonly PublicKeyServer publicKeyServer; | ||
private readonly Id _id; |
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.
Why the leading _
?
BunqSdk/Model/Core/Installation.cs
Outdated
private readonly Id id; | ||
private readonly PublicKeyServer publicKeyServer; | ||
private readonly Id _id; | ||
private readonly PublicKeyServer _publicKeyServer; |
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.
Why the leading _
?
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.
It seems that I have been sloppy with the initial constants names!
- Please rename the constants as I’ve pointed out.
private const string PAYMENT_AMOUNT_EUR = "0.01"; | ||
private const string PAYMENT_CURRENCY = "EUR"; | ||
private const string PAYMENT_DESCRIPTION = "C# test Payment"; | ||
private const string Amount = "0.01"; |
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 rename this back to PaymentAmountEur
as Amount
can also refer to the Amount
object.
private const string PAYMENT_CURRENCY = "EUR"; | ||
private const string PAYMENT_DESCRIPTION = "C# test Payment"; | ||
private const string Amount = "0.01"; | ||
private const string Currency = "EUR"; |
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 rename this back to PaymentCurrecnyEur
private const string PAYMENT_DESCRIPTION = "C# test Payment"; | ||
private const string Amount = "0.01"; | ||
private const string Currency = "EUR"; | ||
private const string Description = "C# test Payment"; |
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 rename this back to PaymentDescription
. This is our standard on how to name constants. There should be a group
identifier and in this case it is Payment
.
{Payment.FIELD_AMOUNT, new Amount(PAYMENT_AMOUNT_EUR, PAYMENT_CURRENCY)}, | ||
{Payment.FIELD_DESCRIPTION, PAYMENT_DESCRIPTION}, | ||
{Payment.FIELD_COUNTERPARTY_ALIAS, COUNTER_PARTY_SELF} | ||
{Payment.FIELD_AMOUNT, new Amount(Amount, Currency)}, |
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.
Don't forget to refactor the renames on these lines as well.
private const string FIELD_PAYMENT_DESCRIPTION = "C# test Payment"; | ||
private const string FIELD_STATUS = "ACCEPTED"; | ||
private const int INDEX_FIRST = 0; | ||
private const string Amount = "0.01"; |
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 as above, here I was kinda sloppy with the constants name 🙈, Please rename them as described in my comment above.
private const string TAB_ITEM_FIELD_DESCRIPTION = "Super expensive java tea"; | ||
private const string FIELD_STATUS_WAITING = "WAITING_FOR_PAYMENT"; | ||
private const string TabDescription = "Pay the tab for Java test please."; | ||
private const string StatusOpen = "OPEN"; |
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.
TabStatusOpen
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.
@OGKevin it should be TabUsageSingleStatusOpen following the style you describe above regarding the group, right? naming is hard
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.
@AnTao Naming is indeed hard! 😁 but you will get used to it!
Yes TabUsageSingleStatusOpen
sounds good 👍
private const string FIELD_STATUS_WAITING = "WAITING_FOR_PAYMENT"; | ||
private const string TabDescription = "Pay the tab for Java test please."; | ||
private const string StatusOpen = "OPEN"; | ||
private const string Amount = "42.00"; |
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.
TabAmountEur
private const string TabDescription = "Pay the tab for Java test please."; | ||
private const string StatusOpen = "OPEN"; | ||
private const string Amount = "42.00"; | ||
private const string Currency = "EUR"; |
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.
TabCurrencyEur
private const string Amount = "42.00"; | ||
private const string Currency = "EUR"; | ||
private const string TabItemDescription = "Super expensive java tea"; | ||
private const string StatusWaiting = "WAITING_FOR_PAYMENT"; |
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.
TabStatusWaiting
{TabUsageSingle.FIELD_STATUS, FIELD_STATUS_OPEN}, | ||
{TabUsageSingle.FIELD_AMOUNT_TOTAL, new Amount(AMOUNT_EUR, FIELD_CURRENCY)} | ||
{TabUsageSingle.FIELD_DESCRIPTION, TabDescription}, | ||
{TabUsageSingle.FIELD_STATUS, StatusOpen}, |
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.
Don't forget to refactor these lines after the constants renames.
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.
Future proofing and some small consistency comments.
We're almost there! 👍 👏 @AnTao
private const string MonetaryAccountBankSubStatus = "REDEMPTION_VOLUNTARY"; | ||
private const string MonetaryAccountBankReason = "OTHER"; | ||
private const string MonetaryAccountBankReasonDescription = "Because this is a test"; | ||
private const string MonetaryAccountBankCurrency = "EUR"; |
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.
Lets make this name future proof, MonetaryAccountBankCurrencyEur
. If we start supporting other currencies then there will be less names to change 👍
private const string Description = "Payment From C# Test"; | ||
private const string Text = "test msg send from C# test"; | ||
private const string PaymentChatAmountEur = "0.01"; | ||
private const string PaymentChatCurrency = "EUR"; |
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 suffix the currency Eur
private const string TabUsageSingleDescription = "Pay the tab for Java test please."; | ||
private const string TabUsageSingleStatusOpen = "OPEN"; | ||
private const string TabAmountEur = "42.00"; | ||
private const string TabCurrency = "EUR"; |
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 suffix Eur
and consistency
private const string StatusWaiting = "WAITING_FOR_PAYMENT"; | ||
private const string TabUsageSingleDescription = "Pay the tab for Java test please."; | ||
private const string TabUsageSingleStatusOpen = "OPEN"; | ||
private const string TabAmountEur = "42.00"; |
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 be consistent 😝 TabAmountEur
-> TabUsageSingleAmountEur
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 constant is also used along with the TabItemShop entity. Changing it for consistency!
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.
One small test amount comment.
After that LGTM
private const string FIELD_STATUS_WAITING = "WAITING_FOR_PAYMENT"; | ||
private const string TabUsageSingleDescription = "Pay the tab for Java test please."; | ||
private const string TabUsageSingleStatusOpen = "OPEN"; | ||
private const string TabUsageSingleAmountEur = "42.00"; |
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.
😮 42.00
is way to much :P it will drain the test account pretty fast haha! Please lower this amount.
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.
LGTM
@sandervdo you're up, please 👀 |
All tests are passing. 👏. Because this PR doenst need any extra tests, I'm marking the |
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.
Thanks for all your work in this PR! I mostly have very small comments, some names are plural whereas our convention is to not use plural names at all (we use PaymentIds
-> allPaymentId
for instance). Some comments will require a second look of @OGKevin as he's the SDK hero. 😄
BunqSdk.Samples/PaymentListSample.cs
Outdated
private const string MESSAGE_LATEST_PAGE_IDS = "Latest page IDs: "; | ||
private const string MESSAGE_SECOND_LATEST_PAGE_IDS = "Second latest page IDs: "; | ||
private const string MESSAGE_NO_PRIOR_PAYMENTS_FOUND = "No prior payments found!"; | ||
private const string MessageLatestPageIds = "Latest page IDs: "; |
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.
Plural -> MessageLatestPageAllPaymentId
BunqSdk.Samples/PaymentListSample.cs
Outdated
private const string MESSAGE_SECOND_LATEST_PAGE_IDS = "Second latest page IDs: "; | ||
private const string MESSAGE_NO_PRIOR_PAYMENTS_FOUND = "No prior payments found!"; | ||
private const string MessageLatestPageIds = "Latest page IDs: "; | ||
private const string MessageSecondLatestPageIds = "Second latest page IDs: "; |
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.
Plural -> MessageSecondLatestPageAllPaymentId
BunqSdk.Samples/PaymentListSample.cs
Outdated
private const string MESSAGE_NO_PRIOR_PAYMENTS_FOUND = "No prior payments found!"; | ||
private const string MessageLatestPageIds = "Latest page IDs: "; | ||
private const string MessageSecondLatestPageIds = "Second latest page IDs: "; | ||
private const string MessageNoPriorPaymentsFound = "No prior payments found!"; |
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.
Plural -> MessageNoPriorPaymentFound
BunqSdk.Samples/PaymentListSample.cs
Outdated
}; | ||
Console.WriteLine(MESSAGE_LATEST_PAGE_IDS); | ||
var paymentResponse = Payment.List(apiContext, USER_ITEM_ID, MONETARY_ACCOUNT_ITEM_ID, | ||
Console.WriteLine(MessageLatestPageIds); |
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.
MessageLatestPageAllPaymentId
BunqSdk.Samples/PaymentListSample.cs
Outdated
paginationCountOnly.UrlParamsCountOnly); | ||
PrintPayments(paymentResponse.Value); | ||
var pagination = paymentResponse.Pagination; | ||
|
||
if (pagination.HasPreviousPage()) | ||
{ | ||
Console.WriteLine(MESSAGE_SECOND_LATEST_PAGE_IDS); | ||
var previousPaymentResponse = Payment.List(apiContext, USER_ITEM_ID, MONETARY_ACCOUNT_ITEM_ID, | ||
Console.WriteLine(MessageSecondLatestPageIds); |
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.
Rename (check for other occurrences too of renamed constants)
@@ -34,4 +34,6 @@ same directory, fill in your sandbox user data and rename the copy to `config.js | |||
|
|||
## Execution | |||
To run tests via Rider, you can right click on the `BunqSdk.Tests` solution and should be able to run | |||
the tests cases form the IDE. | |||
the tests cases from the IDE. | |||
To run the tests via Visual Studio, you can use the Test Explorer window. Use default shortcut Ctrl+R, A |
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.
Is there a shortcut for the Mac edition of Visual Studio too?
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.
For VS Code there is an [extension] (https://github.com/formulahendry/vscode-dotnet-test-explorer) for testing. Although I use VS Code more and more frequently, I still do 95% of .NET development with Visual Studio, so I don't have much feedback on this extension, yet. I am also not sure if this shortcut will work with VS Code.
Are you guys using Rider? What is your feedback? (Sorry for the off topic of the PR)
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.
Yea I use Rider, please list this extension in the README as well then to ensure that others know that they must install the extension 👍
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.
@AnTao myself I don't code in C# at all, but we use the Jetbrains editors mostly yes (PhpStorm, PyCharm, etc.). But in my case, no Rider.
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.
@OGKevin can you check for the shortcut on MacOS then?
BunqSdk/Context/ApiContext.cs
Outdated
|
||
/// <summary> | ||
/// Minimum time to session expiry not requiring session reset. | ||
/// </summary> | ||
private const int TIME_TO_SESSION_EXPIRY_MINIMUM_SECONDS = 30; | ||
private const int TimeToSessionExpiryMinimumSeconds = 30; |
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.
TimeToSessionExpiryMinimumSecond (hmm, looks weird, @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.
🤷♂️ your suggestion is fine, 🙅♂️ plurals.
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.
@OGKevin @sandervdo TimeToSessionExpiryAllMinimumSecond 🙈 This renaming changes will bring a lot of breaking changes!
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.
@AnTao How do you mean ? I only see one usage for it which is here:
sdk_csharp/BunqSdk/Context/ApiContext.cs
Line 196 in c71114b
TIME_TO_SESSION_EXPIRY_MINIMUM_SECONDS |
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.
Ow wait shit your right! I understand. Therefore this pull request needs to actually wait for 0.13.0
👍 Because this is indeed a breaking change! Holy crap how did I miss this 😅
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.
@OGKevin actually the ones I changed in ApiContext.cs are all with the private modifier, so that will be alright.
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.
@AnTao Correct, but the field constants for the generated code for instance all will be used publicly, means current implementations will break!
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.
Lets continue the breaking change discussion in the issue please 👍
|
||
/// <summary> | ||
/// Glue to concatenate the error messages. | ||
/// </summary> | ||
private const string GLUE_ERROR_MESSAGES = "\n"; | ||
private const string GlueErrorMessages = "\n"; |
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.
ErrorMessageGlue
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.
GlueAllErrorMessage
Group by Glue
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.
I don't like the Glue
too much. Why don't we use Separator
or sth?
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.
Hmm well Separator
can also be used just fine 👍
BunqSdk/Http/ApiClient.cs
Outdated
private const string DeviceServerUrl = "device-server"; | ||
private const string InstallationUrl = "installation"; | ||
private const string SessionServerUrl = "session-server"; | ||
private static readonly string[] UrisNotRequiringActiveSession = new string[] |
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.
AllUriNotRequiringActiveSession
BunqSdk/Security/SecurityUtils.cs
Outdated
private const string HEADER_NAME_PREFIX_X_BUNQ = "X-Bunq-"; | ||
private const string DELIMITER_HEADER_VALUE = ","; | ||
private const string FORMAT_HEADER_STRING = "{0}: {1}"; | ||
private const string Newline = "\n"; |
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.
@OGKevin do you want these constants grouped as well? Could use Format prefix.
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.
Ah yeas Format
prefix would indeed be great 👌.
@AnTao FYI I've pushed some minor changed, be sure to pull before you push new changes 👍 |
Thanks for the push @OGKevin |
@AnTao I dont understand ? Why did you close this pull request ? There is nothing wrong with it! |
@OGKevin I did not even noticed I've closed it. My bad! Thanks for re-opening it. |
This PR closes/fixes the following issues: