-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathIRWebAPITwitterInterface+DirectMessages.m
More file actions
123 lines (67 loc) · 4.69 KB
/
IRWebAPITwitterInterface+DirectMessages.m
File metadata and controls
123 lines (67 loc) · 4.69 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
//
// IRWebAPITwitterInterface+DirectMessages.m
// IRWebAPIKit
//
// Created by Evadne Wu on 1/18/11.
// Copyright 2011 Iridia Productions. All rights reserved.
//
#import "IRWebAPITwitterInterface+DirectMessages.h"
@implementation IRWebAPITwitterInterface (DirectMessages)
- (void) retrieveIncomingDirectMessagesWithRange:(IRWebAPITwitterDirectMessageIDRange)inRange successHandler:(IRWebAPIInterfaceCallback)inSuccessCallback failureHandler:(IRWebAPIInterfaceCallback)inFailureCallback {
[self.engine fireAPIRequestNamed:@"1/direct_messages.json" withArguments:[NSDictionary dictionaryWithObjectsAndKeys:
IRWebAPIKitNumberOrNull([NSNumber numberWithUnsignedLongLong:inRange.since]), @"since_id",
IRWebAPIKitNumberOrNull([NSNumber numberWithUnsignedLongLong:inRange.before]), @"max_id",
[NSNumber numberWithInt:self.defaultBatchSize], @"count",
[NSNumber numberWithBool:YES], @"include_entities",
nil] options:nil validator:nil successHandler: ^ (NSDictionary *inResponseOrNil, NSDictionary *inResponseContext, BOOL *outNotifyDelegate, BOOL *outShouldRetry) {
if (inSuccessCallback)
inSuccessCallback(inResponseOrNil, outNotifyDelegate, outShouldRetry);
} failureHandler: ^ (NSDictionary *inResponseOrNil, NSDictionary *inResponseContext, BOOL *outNotifyDelegate, BOOL *outShouldRetry) {
if (inFailureCallback)
inFailureCallback(inResponseOrNil, outNotifyDelegate, outShouldRetry);
}];
}
- (void) retrieveOutgoingDirectMessagesWithRange:(IRWebAPITwitterDirectMessageIDRange)inRange successHandler:(IRWebAPIInterfaceCallback)inSuccessCallback failureHandler:(IRWebAPIInterfaceCallback)inFailureCallback {
[self.engine fireAPIRequestNamed:@"1/direct_messages/sent.json" withArguments:[NSDictionary dictionaryWithObjectsAndKeys:
IRWebAPIKitNumberOrNull([NSNumber numberWithUnsignedLongLong:inRange.since]), @"since_id",
IRWebAPIKitNumberOrNull([NSNumber numberWithUnsignedLongLong:inRange.before]), @"max_id",
[NSNumber numberWithInt:self.defaultBatchSize], @"count",
[NSNumber numberWithBool:YES], @"include_entities",
nil] options:nil validator:nil successHandler: ^ (NSDictionary *inResponseOrNil, NSDictionary *inResponseContext, BOOL *outNotifyDelegate, BOOL *outShouldRetry) {
if (inSuccessCallback)
inSuccessCallback(inResponseOrNil, outNotifyDelegate, outShouldRetry);
} failureHandler: ^ (NSDictionary *inResponseOrNil, NSDictionary *inResponseContext, BOOL *outNotifyDelegate, BOOL *outShouldRetry) {
if (inFailureCallback)
inFailureCallback(inResponseOrNil, outNotifyDelegate, outShouldRetry);
}];
}
- (void) sendDirectMessageToUser:(IRWebAPITwitterUserID)inUserID withContents:(NSString *)inContents successHandler:(IRWebAPIInterfaceCallback)inSuccessCallback failureHandler:(IRWebAPIInterfaceCallback)inFailureCallback {
[self.engine fireAPIRequestNamed:@"1/direct_messages/new.json" withArguments:[NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithUnsignedLongLong:inUserID], @"user_id",
inContents, @"text",
[NSNumber numberWithBool:YES], @"include_entities",
nil] options:[NSDictionary dictionaryWithObjectsAndKeys:
@"POST", kIRWebAPIEngineRequestHTTPMethod,
nil] validator:nil successHandler: ^ (NSDictionary *inResponseOrNil, NSDictionary *inResponseContext, BOOL *outNotifyDelegate, BOOL *outShouldRetry) {
if (inSuccessCallback)
inSuccessCallback(inResponseOrNil, outNotifyDelegate, outShouldRetry);
} failureHandler: ^ (NSDictionary *inResponseOrNil, NSDictionary *inResponseContext, BOOL *outNotifyDelegate, BOOL *outShouldRetry) {
if (inFailureCallback)
inFailureCallback(inResponseOrNil, outNotifyDelegate, outShouldRetry);
}];
}
- (void) deleteDirectMessageWithID:(IRWebAPITwitterDirectMessageID)inMessageID successHandler:(IRWebAPIInterfaceCallback)inSuccessCallback failureHandler:(IRWebAPIInterfaceCallback)inFailureCallback {
[self.engine fireAPIRequestNamed:[NSString stringWithFormat:@"1/direct_messages/destroy/%llu.json", inMessageID] withArguments:[NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithUnsignedLongLong:inMessageID], @"id",
[NSNumber numberWithBool:YES], @"include_entities",
nil] options:[NSDictionary dictionaryWithObjectsAndKeys:
@"POST", kIRWebAPIEngineRequestHTTPMethod,
nil] validator:nil successHandler: ^ (NSDictionary *inResponseOrNil, NSDictionary *inResponseContext, BOOL *outNotifyDelegate, BOOL *outShouldRetry) {
if (inSuccessCallback)
inSuccessCallback(inResponseOrNil, outNotifyDelegate, outShouldRetry);
} failureHandler: ^ (NSDictionary *inResponseOrNil, NSDictionary *inResponseContext, BOOL *outNotifyDelegate, BOOL *outShouldRetry) {
if (inFailureCallback)
inFailureCallback(inResponseOrNil, outNotifyDelegate, outShouldRetry);
}];
}
@end