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
91 lines (84 loc) · 2.53 KB
/
MRPRS.m
File metadata and controls
91 lines (84 loc) · 2.53 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
79
80
81
82
83
84
85
86
87
88
89
90
91
//
// 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 statusIsOpen:(BOOL)statusIsOpen userGK:(NSString *)user_gk projectName:(NSString *)project_name{
self = [self init];
if (self) {
_type = type;
_statusIsOpen = statusIsOpen;
_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;
if (_type != MRPRSTypePR || _type != MRPRSTypeMRAll) {
params[@"status"] = _statusIsOpen? @"open": @"closed";
}
return params;
}
- (NSString *)toPath{
NSString *typeStr;
switch (_type) {
case MRPRSTypeMRAll:
if (_statusIsOpen) {
typeStr = @"merges/open";
}else{
typeStr = @"merges/closed";
}
break;
case MRPRSTypeMRMine:
typeStr = @"merges/list/mine";
break;
case MRPRSTypeMRReview:
typeStr = @"merges/list/review";
break;
case MRPRSTypeMROther:
typeStr = @"merges/list/other";
break;
case MRPRSTypePR:
if (_statusIsOpen) {
typeStr = @"pulls/open";
}else{
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