8000 TDOAuth.swift refinement by WinnieLYT · Pull Request #44 · yahoo/TDOAuth · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

TDOAuth.swift refinement #44

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

Merged
merged 11 commits into from
Oct 31, 2022
Merged

TDOAuth.swift refinement #44

merged 11 commits into from
Oct 31, 2022

Conversation

WinnieLYT
Copy link
Contributor

I confirm that this contribution is made under the terms of the license found in the root directory of this repository's source tree and that I have the authority necessary to make this contribution on behalf of its copyright owner.

This PR is to fix:

  • Some parameters are dropped because insufficient type casting on TDOQueryItem.
  • Encoding JSON object's httpBody failure
  • Add tests for TDOQueryItem to make sure the type casting is correct.

Copy link
Contributor
@adamkaplan adamkaplan left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution and extra thanks for the tests! I left one comment in the Switch that should be addressed.

private class func getStringValue(by rawValue: Any) -> String? {
var formattedValue: String?
switch rawValue {
case let losslessString as LosslessStringConvertible:
Copy link
Contributor

Choose a reason for hiding this comment

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

String conforms LosslessStringConvertible per the docs, as do several of the rest. This one should be after String and other direct conversions or they’ll never be called. it’s not clear to me if the new lossless convertible for something like bool is better/worse than the dedicated initializer. Maybe we can remove most of the cases here.

case let boolValue as Bool:
formattedValue = String(boolValue)
case let arrayValue as NSArray:
formattedValue = String(describing: arrayValue)
Copy link
Contributor
@adamkaplan adamkaplan Oct 27, 2022

Choose a reason for hiding this comment

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

Nice! My only concern with this is that there is no intent captured. Without an output contract here it seems possible that future implementations could break. I think it would interesting to add an extension of “Array where Element conforms to LosslessStringConvertible”, which conforms the array to the same protocol by concatenating in the exact format needed. This has the added benefit that you wouldn’t need a special case here.

But, this is good for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, @adamkaplan. Previously I kept those cases of NSNumber, String and Bool because LosslessStringConvertible doesn't take care of some Obj-C object types. Finally, my team provides me a better way of using NSObjectProtocol.
Please see if this is good to you.

Copy link
Contributor
@adamkaplan adamkaplan left a comment

Choose a reason for hiding this comment

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

Thanks!

@WinnieLYT
Copy link
Contributor Author

@adamkaplan , @stury
I fixed the failed test, and please help merge my PR. Thanks!

@stury
Copy link
Collaborator
stury commented Oct 31, 2022

@WinnieLYT Can you also update the version number in the podspec so we have a new patch release? This will make it simpler to roll out the change for you.

@WinnieLYT
Copy link
Contributor Author

@stury done.

@stury stury merged commit 7648118 into yahoo:master Oct 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0