-
Notifications
You must be signed in to change notification settings - Fork 12
feat: [HL-80] Meal details by id API 🍔 #99
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
base: develop
Are you sure you want to change the base?
Conversation
| var ingredients: [String] = [] | ||
| var measures: [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.
| var ingredients: [String] = [] | |
| var measures: [String] = [] | |
| let ingredients: [String] = [] | |
| let measures: [String] = [] |
|
|
||
| // MARK: - Meal Details | ||
| public struct MealDetails: Decodable { | ||
| let id, name, drinkAlternate, category, area, instructions, thumbnail, tags: 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.
Id should never be optional
| @@ -0,0 +1,57 @@ | |||
| // MARK: - MealDetailsResponse | |||
| public struct MealDetailsResponse: 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.
| public struct MealDetailsResponse: Decodable { | |
| struct MealDetailsResponse: Decodable { |
No need to make this public, just return a list of meals.
| var ingredients: [String] = [] | ||
| var measures: [String] = [] | ||
|
|
||
| enum CodingKeys: String, CodingKey { |
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.
| enum CodingKeys: String, CodingKey { | |
| private enum CodingKeys: String, CodingKey { |
| .compactMap { $0.isEmpty ? nil : $0} | ||
| } | ||
|
|
||
| private func dynamicValuesFor(dynamicKey: String, with decoder: Decoder) throws -> [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.
Thanks for adding this. A good practice when adding a code that the others in the might might not be aware of is to write comments. Documentation helps your future self understand why ou added this in the first place.
| @@ -0,0 +1,12 @@ | |||
| struct DynamicCodingKeys: CodingKey { | |||
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 adding it, I like the idea 🙏🏼
| var intValue: Int? | ||
| init?(intValue: Int) { | ||
| self.intValue = intValue | ||
| self.stringValue = "\(intValue)" | ||
| } | ||
|
|
||
| var stringValue: String | ||
| init(stringValue: String) { | ||
| self.stringValue = stringValue | ||
| } |
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.
| var intValue: Int? | |
| init?(intValue: Int) { | |
| self.intValue = intValue | |
| self.stringValue = "\(intValue)" | |
| } | |
| var stringValue: String | |
| init(stringValue: String) { | |
| self.stringValue = stringValue | |
| } | |
| let intValue: Int? | |
| init?(intValue: Int) { | |
| self.intValue = intValue | |
| self.stringValue = "\(intValue)" | |
| } | |
| let stringValue: String | |
| init(stringValue: String) { | |
| self.stringValue = stringValue | |
| } |
To avoid duplication, you might consider making it generic, or at least have two versions for both Int and String.
| var ingredients: [String] = [] | ||
| var measures: [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.
| var ingredients: [String] = [] | |
| var measures: [String] = [] | |
| let ingredients: [String] = [] | |
| let measures: [String] = [] |
Mutability is a big source of bugs. Avoid it.
Proposed Changes
Created Meal details API request
Related Issues
List any related issues or pull requests.
N/A
Additional Information
N/A
Screenshot
N/A
Checklist