123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- //
- // O2AppAPI.swift
- // o2app
- //
- // Created by 刘振兴 on 2017/12/21.
- // Copyright © 2017年 zone. All rights reserved.
- //
- import Foundation
- import Moya
- // MARK:- 所有调用的API枚举
- enum O2AppAPI {
- case getNativeAppList
- case getPortalAppList
- }
- // MARK:- 上下文实现
- extension O2AppAPI:OOAPIContextCapable {
- var apiContextKey: String {
- return ""
- }
- }
- // MARK: - 是否需要加入x-token访问头
- extension O2AppAPI:OOAccessTokenAuthorizable {
- public var shouldAuthorize: Bool {
- return true
- }
- }
- extension O2AppAPI:TargetType {
- var baseURL: URL {
- let model = O2AuthSDK.shared.centerServerInfo()?.webServer
- let baseURLString = "\(model?.httpProtocol ?? "http")://\(model?.host ?? ""):\(model?.port ?? 0)"
- return URL(string: baseURLString)!
- }
-
- var path: String {
- switch self {
- case .getNativeAppList:
- return "/application.json"
- case .getPortalAppList:
- return ""
- }
- }
-
- var method: Moya.Method {
- return .get
- }
-
- var sampleData: Data {
- return "".data(using: String.Encoding.utf8)!
- }
-
- var task: Task {
- return .requestPlain
- }
-
- var headers: [String : String]? {
- return nil
- }
-
-
- }
|