OOContactExpressAPI.swift 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. //
  2. // OOContactExpressAPI.swift
  3. // O2Platform
  4. //
  5. // Created by FancyLou on 2019/8/13.
  6. // Copyright © 2019 zoneland. All rights reserved.
  7. //
  8. import Moya
  9. //x_organization_assemble_express
  10. enum OOContactExpressAPI {
  11. //根据职务列表和组织查询 组织下对应的身份列表
  12. case identityListByUnitAndDuty([String], String)
  13. //查询人员person的dn
  14. case personListDN([String])
  15. }
  16. extension OOContactExpressAPI: OOAPIContextCapable {
  17. var apiContextKey: String {
  18. return "x_organization_assemble_express"
  19. }
  20. }
  21. extension OOContactExpressAPI: OOAccessTokenAuthorizable {
  22. var shouldAuthorize: Bool {
  23. return true
  24. }
  25. }
  26. extension OOContactExpressAPI: TargetType {
  27. var baseURL: URL {
  28. let model = O2AuthSDK.shared.o2APIServer(context: .x_organization_assemble_express)
  29. let baseURLString = "\(model?.httpProtocol ?? "http")://\(model?.host ?? ""):\(model?.port ?? 0)\(model?.context ?? "")"
  30. return URL(string: baseURLString)!
  31. }
  32. var path: String {
  33. switch self {
  34. case .identityListByUnitAndDuty(_, _):
  35. return "/jaxrs/unitduty/list/identity/unit/name/object"
  36. case .personListDN(_):
  37. return "/jaxrs/person/list"
  38. }
  39. }
  40. var method: Moya.Method {
  41. switch self {
  42. case .identityListByUnitAndDuty(_, _), .personListDN(_):
  43. return .post
  44. }
  45. }
  46. var sampleData: Data {
  47. return "".data(using: String.Encoding.utf8)!
  48. }
  49. var task: Task {
  50. switch self {
  51. case .identityListByUnitAndDuty(let dutyList, let unit):
  52. return .requestParameters(parameters: ["nameList": dutyList, "unit": unit], encoding: JSONEncoding.default)
  53. case .personListDN(let idList):
  54. return.requestParameters(parameters: ["personList": idList], encoding: JSONEncoding.default)
  55. }
  56. }
  57. var headers: [String : String]? {
  58. return nil
  59. }
  60. }