| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- //
- // LoginApi.swift
- // SolarStationSwift
- //
- // Created by weclouds on 2018/8/3.
- // Copyright © 2018年 weclouds. All rights reserved.
- //
- import Foundation
- import Moya
- import Alamofire
- //import RxSwift
- //import RxCocoa
- let LoginProvider = MoyaProvider<LoginAPI>()
- enum LoginAPI {
- case common_login(username:String, client_key:String, password:String,os:String)
- }
- extension LoginAPI:TargetType {
- var base :String {
- return moyaBase
- }
- //请求的url
- public var baseURL: URL {return URL(string:base)!}
- //详细的路径
- public var path:String {
- switch self {
- case .common_login:
- return "/common/login"
- }
- }
- //请求的方式
- public var method: Moya.Method {
- switch self {
- case .common_login :
- return .post
- }
- }
- //单元测试用
- public var sampleData:Data {
- switch self {
- case .common_login:
- return stubbedResponse("common_login")
- }
- }
- //任务
- public var task: Task {
- switch self {
- case .common_login(let username, let client_key, let password,let os):
- return .requestParameters(parameters: [
- "username":username,
- "client_key": client_key,
- "password": password,
- "os":os
- ], encoding: URLEncoding.default)
- }
- }
- //请求头信息
- public var headers: [String : String]? {
- return nil
- }
-
- }
|