-
Notifications
You must be signed in to change notification settings - Fork 0
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
Project APIs #40
Project APIs #40
Conversation
06de281
to
cb98d99
Compare
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 - just a question about ProjectType
|
||
/// Describes the type of a MyDataHelps project. | ||
/// May be one of: Research Study, Wellness Program, or Clinical Program. | ||
public struct ProjectType: RawRepresentable, Equatable, Decodable { |
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.
Any reason why this would be a struct instead of an enum?
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 forward compatibility. If this were struct ProjectType: String
, and we introduce a new ProjectType value on the server, then the SDK would immediately fail to decode the ProjectInfo for such projects, throwing a decoding error. Using a RawRepresentable struct instead, these new ProjectType values successfully decode, simply as instances with different rawValues.
This pattern is used with most of the enum-like decodable values in the SDK. In practice, the syntax for using these structs (choosing specific values or checking for equality to specific values) looks identical to plain enums, as seen throughout the example app. e.g. you can just check for projectInfo.type == .researchStudy
, use the shorthand dot-syntax in switch cases, etc.
See https://github.com/CareEvolution/MyDataHelpsKit-dev/pull/1#discussion_r598414777 for the original discussion about 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.
Also, your comment has brought attention to the unnecessary documentation comment "May be one of…", which I copied/pasted from the JS SDK. I'll remove that.
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.
Updated unit tests to verify/clarify handling of unknown "enum" values.
7dbcb60
to
08786dd
Compare
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.
Changes LGTM 👍
Overview
Implements model types, API calls, example app views, and unit tests for project info APIs.
See https://developer.mydatahelps.org/sdk/project_settings.html to compare to JavaScript SDK counterparts.
Security
REMINDER: All file contents are public.
Describe briefly what security risks you considered, why they don't apply, or how they've been mitigated.
Checklist
Consider "Squash and merge" as needed to keep the commit history reasonable on
main
.