yattee/Model/VideoDetailsProvider.swift
2021-06-11 01:00:28 +02:00

26 lines
543 B
Swift

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)
}
}
}
}