No Description

UploadResource.swift 728B

123456789101112131415161718192021222324252627282930313233
  1. //
  2. // UploadResource.swift
  3. // PaiaiDataKit
  4. //
  5. // Created by FFIB on 2019/1/2.
  6. // Copyright © 2019 FFIB. All rights reserved.
  7. //
  8. import Foundation
  9. import RxSwift
  10. struct UploadResource<Content>: Resource {
  11. typealias Model = Content
  12. var path: Interfaces
  13. var parameter: Parameter
  14. var parseJSON: (JSON) -> Content?
  15. init(path: Interfaces, parameter: Parameter, parseJSON: @escaping (JSON) -> Content?) {
  16. self.path = path
  17. self.parameter = parameter
  18. self.parseJSON = parseJSON
  19. }
  20. func parse(_ json: JSON) -> Content? {
  21. return parseJSON(json)
  22. }
  23. func upload() -> Single<Content> {
  24. return NetworkApi.share.upload(resource: self)
  25. }
  26. }