Commits

Paul Schifferer committed b647c54

Added pagination parameters for message operations.

Comments (0)

Files changed (2)

Snapper/Source/Shared/SNPGetChannelMessagesOperation.h

 
 // -- Properties --
 @property (nonatomic, assign) NSUInteger channelId;
+@property (nonatomic, assign) NSUInteger beforeId;
+@property (nonatomic, assign) NSUInteger sinceId;
+@property (nonatomic, assign) NSInteger count;
 
 // -- Initializers --
 - (id)initWithChannelId:(NSUInteger)channelId

Snapper/Source/Shared/SNPGetChannelMessagesOperation.m

     return self;
 }
 
+
+#pragma mark - Workhorse
+
+- (void)main {
+
+    [self handleQueryParameters];
+
+    [super main];
+}
+
+- (void)handleQueryParameters {
+
+    NSMutableDictionary* parameters = [NSMutableDictionary dictionary];
+
+    if(self.parameters) {
+        [parameters addEntriesFromDictionary:self.parameters];
+    }
+
+    if(_beforeId) {
+        parameters[@"before_id"] = @(_beforeId);
+    }
+    if(_sinceId) {
+        parameters[@"since_id"] = @(_sinceId);
+    }
+    if(_count) {
+        parameters[@"count"] = @(_count);
+    }
+
+    if([[parameters allKeys] count]) {
+        self.parameters = parameters;
+    }
+}
+
 @end