07-19-2023, 01:27 AM
I've created an enum for Instagram endpoints with nested enums similar to [Moya][1].
enum Instagram {
enum Media {
case Popular
case Shortcode(id: String)
case Search(lat: Float, lng: Float, distance: Int)
}
enum Users {
case User(id: String)
case Feed
case Recent(id: String)
}
}
I would like to return the path for each endpoint.
extension Instagram: TargetType {
var path: String {
switch self {
case .Media.Shortcode(let id):
return "/media/shortcode"
}
}
}
However I'm getting an error on the switch statement above for the `path`.
> Enum case `Shortcode` is not a member of type `Instagram`
How to fix?
[Advanced Practical Enums][1]
[1]:
enum Instagram {
enum Media {
case Popular
case Shortcode(id: String)
case Search(lat: Float, lng: Float, distance: Int)
}
enum Users {
case User(id: String)
case Feed
case Recent(id: String)
}
}
I would like to return the path for each endpoint.
extension Instagram: TargetType {
var path: String {
switch self {
case .Media.Shortcode(let id):
return "/media/shortcode"
}
}
}
However I'm getting an error on the switch statement above for the `path`.
> Enum case `Shortcode` is not a member of type `Instagram`
How to fix?
[Advanced Practical Enums][1]
[1]:
[To see links please register here]