yattee/Model/VideoDetailsProvider.swift

26 lines
543 B
Swift
Raw Normal View History

2021-06-10 22:50:10 +00:00
import Alamofire
import Foundation
import SwiftyJSON
final class VideoDetailsProvider: DataProvider {
@Published var video: Video?
var id: String
init(_ id: String) {
self.id = id
super.init()
}
func load() {
DataProvider.request("videos/\(id)").responseJSON { response in
switch response.result {
case let .success(value):
self.video = Video(JSON(value))
case let .failure(error):
print(error)
}
}
}
}