Tuling123API.swift 948 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. //
  2. // Tuling123API.swift
  3. // O2Platform
  4. //
  5. // Created by FancyLou on 2018/9/30.
  6. // Copyright © 2018 zoneland. All rights reserved.
  7. //
  8. import Moya
  9. enum Tuling123API {
  10. case openapi(TulingPostModel)
  11. }
  12. extension Tuling123API: TargetType {
  13. var baseURL: URL {
  14. let baseURLString = "http://www.tuling123.com/openapi"
  15. return URL(string: baseURLString)!
  16. }
  17. var path: String {
  18. return "/api"
  19. }
  20. var method: Moya.Method {
  21. switch self {
  22. case .openapi(_):
  23. return .post
  24. }
  25. }
  26. var sampleData: Data {
  27. return "".data(using: String.Encoding.utf8)!
  28. }
  29. var task: Task {
  30. switch self {
  31. case .openapi(let model):
  32. return .requestParameters(parameters: model.toJSON() ?? [:], encoding: JSONEncoding.default)
  33. }
  34. }
  35. var headers: [String : String]? {
  36. return nil
  37. }
  38. }