-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathMRPRS.m
72 lines (65 loc) · 2.18 KB
/
MRPRS.m
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
//
// 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)initWithType:(MRPRSType)type userGK:(NSString *)user_gk projectName:(NSString *)project_name{
self = [self init];
if (self) {
_type = type;
_user_gk = user_gk;
_project_name = project_name;
}
return self;
}
- (NSDictionary *)toParams{
NSMutableDictionary *params = @{@"page" : (_willLoadMore? [NSNumber numberWithInteger:_page.intValue +1] : [NSNumber numberWithInteger:1]),
@"pageSize" : _pageSize}.mutableCopy;
params[@"status"] = (_type == MRPRSTypeMRCanMerge? @"canmerge":
_type == MRPRSTypeMRCannotMerge? @"cannotmerge":
_type == MRPRSTypeMRRefused? @"refused":
_type == MRPRSTypeMRAccepted? @"accepted":
nil);
return params;
}
- (NSString *)toPath{
NSString *typeStr;
if (_type < MRPRSTypePROpen) {
typeStr = @"merges/filter";
}else{
typeStr = (_type == MRPRSTypePROpen? @"pulls/open":
_type == MRPRSTypePRClosed? @"pulls/closed":
_type == MRPRSTypePRAll? @"pulls/all":
@"");
}
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