-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMeiPaiApi.swift
70 lines (61 loc) · 1.85 KB
/
MeiPaiApi.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//
// MeiPaiApi.swift
// Gank
//
// Created by 魏星 on 16/7/26.
// Copyright © 2016年 wx. All rights reserved.
//
import Foundation
import Moya
struct MeiPaiScheme {
static let BaseUrl = "https://newapi.meipai.com"
static let Category = "channels/header_list.json"
static let VideoList = "/channels/feed_timelin.json"
static let HotVideoList = "hot/feed_timeline.json"
}
struct MeiPaiKey {
static let IDKey = "id"
static let TypeKey = "type"
static let PageKey = "page"
static let CountKey = "count"
}
struct DefaultValues {
static let Count = 20
}
enum MeiPaiApi{
case GetCategoryList
case GetHotVideoList(page: Int,count: Int)
case GetVideoList(id: Int,type: Int,page: Int,count: Int)
}
extension MeiPaiApi: TargetType{
var baseURL:NSURL {
return NSURL(string: MeiPaiScheme.BaseUrl)!
}
var path: String {
switch self {
case .GetCategoryList:
return MeiPaiScheme.Category
case.GetVideoList(id: _,type: _, page: _, count: _):
return MeiPaiScheme.VideoList
case .GetHotVideoList(page: _, count: _):
return MeiPaiScheme.HotVideoList
}
}
var method: Moya.Method {
return .GET
}
var parameters: [String: AnyObject]? {
switch self {
case .GetCategoryList:
return ["language": "zh-Hans"]
case .GetHotVideoList(let page, let count):
return [MeiPaiKey.PageKey: page,MeiPaiKey.CountKey: count]
case .GetVideoList(let id, let type,let page, let count):
return [MeiPaiKey.IDKey: id,MeiPaiKey.TypeKey: type,MeiPaiKey.PageKey: page,MeiPaiKey.CountKey: count]
}
}
var multipartBody: [MultipartFormData]? { return nil }
var sampleData: NSData {
return "{}".dataUsingEncoding(NSUTF8StringEncoding)!
}
}