OrganizationPermissionAPI.swift 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. //
  2. // OrganizationPermissionAPI.swift
  3. // O2Platform
  4. // custom模块 通讯录 需要到应用市场下载安装
  5. // Created by FancyLou on 2021/7/28.
  6. // Copyright © 2021 zoneland. All rights reserved.
  7. //
  8. import Moya
  9. enum OrganizationPermissionAPI {
  10. case getPermissionViewInfo(String)
  11. }
  12. extension OrganizationPermissionAPI: OOAPIContextCapable {
  13. var apiContextKey: String {
  14. return "x_organizationPermission"
  15. }
  16. }
  17. // 是否需要xtoken
  18. extension OrganizationPermissionAPI: OOAccessTokenAuthorizable {
  19. var shouldAuthorize: Bool {
  20. return true
  21. }
  22. }
  23. extension OrganizationPermissionAPI: TargetType {
  24. var baseURL: URL {
  25. let model = O2AuthSDK.shared.centerServerInfo()?.assembles?["x_organizationPermission"]
  26. let baseURLString = "\(model?.httpProtocol ?? "http")://\(model?.host ?? ""):\(model?.port ?? 80)\(model?.context ?? "")"
  27. if let trueUrl = O2AuthSDK.shared.bindUnitTransferUrl2Mapping(url: baseURLString) {
  28. return URL(string: trueUrl)!
  29. }
  30. return URL(string: baseURLString)!
  31. }
  32. var path: String {
  33. switch self {
  34. case .getPermissionViewInfo(let view):
  35. return "/jaxrs/permission/view/\(view)"
  36. }
  37. }
  38. var method: Moya.Method {
  39. return .get
  40. }
  41. var sampleData: Data {
  42. return "".data(using: String.Encoding.utf8)!
  43. }
  44. var task: Task {
  45. return .requestPlain
  46. }
  47. var headers: [String : String]? {
  48. return nil
  49. }
  50. }