1234567891011121314151617181920212223242526272829303132333435363738 |
- import Foundation
- import RxSwift
- import ObjectMapper
- struct ContentResource<Content>: Resource {
- typealias Model = Content
-
- var host: String
- var path: Interfaces
- var parameter: Parameter
- var parseJSON: (JSON) -> Content?
-
- init(host: String = "https://api.pai.ai",
- path: Interfaces, parameter: Parameter,
- parseJSON: @escaping (JSON) -> Content?) {
- self.host = host
- self.path = path
- self.parameter = parameter
- self.parseJSON = parseJSON
- }
-
- func parse(_ json: JSON) -> Content? {
- return parseJSON(json)
- }
-
- func loadContent() -> Single<Content> {
- return NetworkApi.share.post(resource: self)
- }
- }
|