-
Notifications
You must be signed in to change notification settings - Fork 2
/
CoreAssetItemJSON.m
64 lines (47 loc) · 1.94 KB
/
CoreAssetItemJSON.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
//
// CoreAssetItemJSON.m
// CoreAssetManager
//
// Created by Bálint Róbert on 12/04/16.
// Copyright (c) 2016 IncepTech Ltd All rights reserved.
//
#import "CoreAssetItemJSON.h"
@implementation CoreAssetItemJSON
+ (NSUInteger)workerThreads {
return 4;
}
- (NSString *)fileSystemPath {
NSString *generatedPath = [CoreAssetItemNormal safelyGeneratedCollectionPath:super.assetName];
NSString *fsPath = [[CoreAssetItemNormal assetStorageDirectory] stringByAppendingPathComponent:[NSString stringWithFormat:@"json/%@.%@.json", NSStringFromClass(self.class), generatedPath]];
return fsPath;
}
- (NSURLRequest *)createURLRequest {
NSMutableURLRequest *request = [NSMutableURLRequest new];
TestLog(@"%@ %@: implement me", NSStringFromClass(self.class), NSStringFromSelector(_cmd));
return request;
}
- (NSData *)serializeRequestJSON {
NSError *error;
id jsonData = [NSJSONSerialization dataWithJSONObject:super.assetName options:0 error:&error];
if (error || !jsonData) {
TestLog(@"%@ %@: JSON serialization error: '%@'", NSStringFromClass(self.class), NSStringFromSelector(_cmd), error.localizedDescription);
}
return jsonData;
}
+ (nullable NSData *)serializeRequestJSONWithInput:(id)input {
NSError *error;
id jsonData = [NSJSONSerialization dataWithJSONObject:input options:0 error:&error];
if (error || !jsonData) {
TestLog(@"%@ %@: JSON serialization error: '%@'", NSStringFromClass(self.class), NSStringFromSelector(_cmd), error.localizedDescription);
}
return jsonData;
}
- (id)postProcessData:(NSData *)assetData {
NSError *error;
id jsonData = [NSJSONSerialization JSONObjectWithData:assetData options:0 error:&error];
if (error || !jsonData) {
TestLog(@"%@ %@: JSON de-serialization error: '%@'", NSStringFromClass(self.class), NSStringFromSelector(_cmd), error.localizedDescription);
}
return jsonData;
}
@end