blob: dd4d55fe237264c944f97b21cfb6841be6bdc9fc (
plain)
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
|
#import <Foundation/Foundation.h>
@interface TestClass : NSObject
@end
@implementation TestClass
- (void)session_thumbnail_url:(NSDictionary *)data {
[session mergeCommonMovieItems:^(NSURL *exportURL, NSError *error) {
#if 0
[response setValue:[thumbnailUrl absoluteString] forKey:@"thumbnail_url"];
#else
NSString *extension = [thumbnailUrl pathExtension];
NSData *imageData = [NSData dataWithContentsOfURL:thumbnailUrl];
NSString *base64EncodedImage = [TestClassCommon Base64Encode:imageData];
NSString *base64Image = nil;
if ([extension isEqualToString:@"jpg"] == YES) {
base64Image = [NSString stringWithFormat:@"data:image/jpg;base64, %@", base64EncodedImage];
} else {
base64Image = [NSString stringWithFormat:@"data:image/png;base64, %@", base64EncodedImage];
}
[response setValue:base64Image forKey:@"thumbnail_url"];
#endif
[TestClassWebViewController sendEvent:[NSString stringWithFormat:@"session_thumbnail:%@", sessionId] withArgs:response];
}];
}
- (void)addFoo:(NSDictionary *)postData {
[TestClassRequest performMethod:TestClassRequestMethodPOST
onResource:resource
usingParameters:postData
withAccount:[TestClass account]
sendingProgressHandler:nil
responseHandler:^(NSURLResponse *response, NSData *responseData, NSError *error) {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
if ([httpResponse statusCode] == 200) {
#if DEBUG
NSString *rsp = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
TestClassLog(@"TOGGLE CONNECTION ADDED response:%li responseData:%@ error:%@", (long) [((NSHTTPURLResponse *) response) statusCode], rsp, [error localizedDescription]);
#endif
NSJSONSerialization *jsonConnection = [responseData TestClassJSONObject];
}
}];
}
@end
|