-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.codesnippet
88 lines (71 loc) · 2.49 KB
/
api.codesnippet
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
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDECodeSnippetCompletionPrefix</key>
<string>api</string>
<key>IDECodeSnippetCompletionScopes</key>
<array>
<string>All</string>
</array>
<key>IDECodeSnippetContents</key>
<string>@class RACSignal;
@interface <#ApiModel#> : NSObject
@end
@interface <#ApiResponseModel#> : NSObject <BFCApiModel>
@end
@interface <#Api#> : NSObject
+ (RACSignal *)excute:(<#ApiModel#> *)model;
@end
// ------
@implementation <#ApiModel#>
@end
@implementation <#ResponseModel#>
@end
@implementation <#Api#>
+ (RACSignal *)excute:(<#ApiModel#> *)model {
return [[RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
BFCApiOptions *options = [BFCApiOptions new];
options.requestMethod = BFCApiRequestMethodGET;
options.baseUrl = <#BaseUrl#>;
options.modelDescriptions = @[[BFCApiModelDescription modelWith:@"/data"
mappingClass:[<#ApiResponseModel#> class]
isArray:NO]];
options.params = @{
};
BFCApiRequest *request = [[BFCApiRequest alloc] initWithOptions:options];
request.completionHandler = ^(NSDictionary *result) {
<#ApiResponseModel#> *responseModel = result[@"/data"];
if (!responseModel) {
[subscriber sendError:nil];
}
[subscriber sendNext:responseModel];
[subscriber sendCompleted];
};
request.errorHandler = ^(NSError *error, NSDictionary * result) {
[subscriber sendError:error];
};
[request requestAsync];
return [RACDisposable disposableWithBlock:^{
if (![request isCancelled]) {
[request cancel];
}
}];
}] deliverOnMainThread];
}
@end
</string>
<key>IDECodeSnippetIdentifier</key>
<string>C180E3C9-9B28-47DF-9130-7AFCD96185EE</string>
<key>IDECodeSnippetLanguage</key>
<string>Xcode.SourceCodeLanguage.Objective-C-Plus-Plus</string>
<key>IDECodeSnippetSummary</key>
<string>api</string>
<key>IDECodeSnippetTitle</key>
<string>api</string>
<key>IDECodeSnippetUserSnippet</key>
<true/>
<key>IDECodeSnippetVersion</key>
<integer>2</integer>
</dict>
</plist>