forked from coding/Coding-iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMRPRS.m
More file actions
78 lines (72 loc) · 2.1 KB
/
MRPRS.m
File metadata and controls
78 lines (72 loc) · 2.1 KB
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
71
72
73
74
75
76
77
78
//
// MRPRS.m
// Coding_iOS
//
// Created by Ease on 15/5/29.
// Copyright (c) 2015年 Coding. All rights reserved.
//
#import "MRPRS.h"
@implementation MRPRS
- (instancetype)init
{
self = [super init];
if (self) {
_propertyArrayMap = [NSDictionary dictionaryWithObjectsAndKeys:
@"MRPR", @"list", nil];
_canLoadMore = YES;
_isLoading = _willLoadMore = NO;
_page = [NSNumber numberWithInteger:1];
_pageSize = [NSNumber numberWithInteger:20];
}
return self;
}
+(instancetype)MRPRSWithType:(MRPRSType)type userGK:(NSString *)user_gk projectName:(NSString *)project_name{
MRPRS *obj = [[MRPRS alloc] init];
obj.type = type;
obj.user_gk = user_gk;
obj.project_name = project_name;
return obj;
}
- (NSDictionary *)toParams{
return @{@"page" : (_willLoadMore? [NSNumber numberWithInteger:_page.intValue +1] : [NSNumber numberWithInteger:1]),
@"pageSize" : _pageSize};
}
- (NSString *)toPath{
NSString *typeStr;
switch (_type) {
case MRPRSTypeMRAll:
typeStr = @"merges/all";
break;
case MRPRSTypeMROpen:
typeStr = @"merges/open";
break;
case MRPRSTypeMRClose:
typeStr = @"merges/closed";
break;
case MRPRSTypePRAll:
typeStr = @"pulls/all";
break;
case MRPRSTypePROpen:
typeStr = @"pulls/open";
break;
case MRPRSTypePRClose:
typeStr = @"pulls/closed";
break;
default:
typeStr = @"";
break;
}
return [NSString stringWithFormat:@"api/user/%@/project/%@/git/%@", _user_gk, _project_name, typeStr];
}
- (void)configWithMRPRS:(MRPRS *)resultA{
self.page = resultA.page;
self.totalPage = resultA.totalPage;
self.totalRow = resultA.totalRow;
if (_willLoadMore) {
[self.list addObjectsFromArray:resultA.list];
}else{
self.list = [NSMutableArray arrayWithArray:resultA.list];
}
self.canLoadMore = self.page.intValue < self.totalPage.intValue;
}
@end