Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge pull request #27 from bryanhales/master

Integrate Github Notifications API
  • Loading branch information...
commit 877e0c8eab0d1fb604d19cc121a8f6374f367a4c 2 parents 4ce7b0e + 03941af
Owain R Hunt authored January 07, 2013
18  UAGithubEngine/UAGithubEngine.h
@@ -92,6 +92,24 @@ typedef void (^UAGithubEngineFailureBlock)(NSError *);
92 92
 - (void)deleteComment:(NSInteger)commentNumber forRepository:(NSString *)repositoryPath success:(UAGithubEngineBooleanSuccessBlock)successBlock failure:(UAGithubEngineFailureBlock)failureBlock;
93 93
 
94 94
 
  95
+#pragma mark
  96
+#pragma mark Activity
  97
+#pragma mark
  98
+
  99
+
  100
+#pragma mark Notifications
  101
+
  102
+- (void)notificationsWithSuccess:(UAGithubEngineSuccessBlock)successBlock failure:(UAGithubEngineFailureBlock)failureBlock;
  103
+- (void)notificationsForRepository:(NSString *)repositoryPath success:(UAGithubEngineSuccessBlock)successBlock failure:(UAGithubEngineFailureBlock)failureBlock;
  104
+- (void)notificationsForThread:(NSInteger)threadId success:(UAGithubEngineSuccessBlock)successBlock failure:(UAGithubEngineFailureBlock)failureBlock;
  105
+- (void)markNotificationsAsReadWithSuccess:(UAGithubEngineSuccessBlock)successBlock failure:(UAGithubEngineFailureBlock)failureBlock;
  106
+- (void)markNotificationsAsReadInRepository:(NSString *)repositoryPath success:(UAGithubEngineSuccessBlock)successBlock failure:(UAGithubEngineFailureBlock)failureBlock;
  107
+- (void)markNotificationThreadAsRead:(NSInteger)threadId success:(UAGithubEngineSuccessBlock)successBlock failure:(UAGithubEngineFailureBlock)failureBlock;
  108
+- (void)currentUserIsSubscribedToNotificationThread:(NSInteger)threadId success:(UAGithubEngineSuccessBlock)successBlock failure:(UAGithubEngineFailureBlock)failureBlock;
  109
+- (void)subscribeCurrentUserToNotificationThread:(NSInteger)threadId success:(UAGithubEngineSuccessBlock)successBlock failure:(UAGithubEngineFailureBlock)failureBlock;
  110
+- (void)unsubscribeCurrentUserFromNotificationThread:(NSInteger)threadId success:(UAGithubEngineSuccessBlock)successBlock failure:(UAGithubEngineFailureBlock)failureBlock;
  111
+
  112
+
95 113
 #pragma mark Events
96 114
 
97 115
 - (void)eventsForIssue:(NSInteger)issueId forRepository:(NSString *)repositoryPath success:(UAGithubEngineSuccessBlock)successBlock failure:(UAGithubEngineFailureBlock)failureBlock;
67  UAGithubEngine/UAGithubEngine.m
@@ -196,6 +196,8 @@ - (id)sendRequest:(NSString *)path requestType:(UAGithubRequestType)requestType
196 196
         case UAGithubOrganizationMembershipPublicizeRequest:
197 197
         case UAGithubTeamMemberAddRequest:
198 198
         case UAGithubTeamRepositoryManagershipAddRequest:
  199
+        case UAGithubNotificationsMarkReadRequest:
  200
+        case UAGithubNotificationThreadSubscriptionRequest:
199 201
         {
200 202
             [urlRequest setHTTPMethod:@"PUT"];
201 203
         }
@@ -215,6 +217,7 @@ - (id)sendRequest:(NSString *)path requestType:(UAGithubRequestType)requestType
215 217
         case UAGithubPullRequestCommentUpdateRequest:
216 218
         case UAGithubOrganizationUpdateRequest: 
217 219
         case UAGithubTeamUpdateRequest:
  220
+        case UAGithubNotificationsMarkThreadReadRequest:
218 221
         {
219 222
             [urlRequest setHTTPMethod:@"PATCH"];
220 223
         }
@@ -238,6 +241,7 @@ - (id)sendRequest:(NSString *)path requestType:(UAGithubRequestType)requestType
238 241
         case UAGithubTeamDeleteRequest:
239 242
         case UAGithubTeamMemberRemoveRequest:
240 243
         case UAGithubTeamRepositoryManagershipRemoveRequest:
  244
+        case UAGithubNotificationDeleteSubscriptionRequest:
241 245
         {
242 246
             [urlRequest setHTTPMethod:@"DELETE"];
243 247
         }
@@ -660,6 +664,69 @@ - (void)deleteComment:(NSInteger)commentNumber forRepository:(NSString *)reposit
660 664
 }
661 665
 
662 666
 
  667
+#pragma mark
  668
+#pragma mark Activity
  669
+#pragma mark
  670
+
  671
+
  672
+#pragma mark Notifications
  673
+
  674
+- (void)notificationsWithSuccess:(UAGithubEngineSuccessBlock)successBlock failure:(UAGithubEngineFailureBlock)failureBlock
  675
+{
  676
+    [self invoke:^(id self){[self sendRequest:@"notifications" requestType:UAGithubNotificationsRequest responseType:UAGithubNotificationsResponse error:nil];} success:successBlock failure:failureBlock];
  677
+}
  678
+
  679
+- (void)notificationsForRepository:(NSString *)repositoryPath success:(UAGithubEngineSuccessBlock)successBlock failure:(UAGithubEngineFailureBlock)failureBlock
  680
+{
  681
+    [self invoke:^(id self){[self sendRequest:[NSString stringWithFormat:@"repos/%@/notifications", repositoryPath] requestType:UAGithubNotificationsRequest responseType:UAGithubNotificationsResponse error:nil];} success:successBlock failure:failureBlock];
  682
+}
  683
+
  684
+- (void)notificationsForThread:(NSInteger)threadId success:(UAGithubEngineSuccessBlock)successBlock failure:(UAGithubEngineFailureBlock)failureBlock
  685
+{
  686
+    [self invoke:^(id self){[self sendRequest:[NSString stringWithFormat:@"notifications/threads/%ld", threadId] requestType:UAGithubNotificationsRequest responseType:UAGithubNotificationThreadsResponse error:nil];} success:successBlock failure:failureBlock];
  687
+}
  688
+
  689
+- (void)markNotificationsAsReadWithSuccess:(UAGithubEngineSuccessBlock)successBlock failure:(UAGithubEngineFailureBlock)failureBlock
  690
+{
  691
+    NSDictionary *params = [@{ @"read" : @"true" } copy];
  692
+    
  693
+    [self invoke:^(id self){[self sendRequest:@"notifications" requestType:UAGithubNotificationsMarkReadRequest responseType:UAGithubNoContentResponse withParameters:params error:nil];} success:successBlock failure:failureBlock];
  694
+}
  695
+
  696
+- (void)markNotificationsAsReadInRepository:(NSString *)repositoryPath success:(UAGithubEngineSuccessBlock)successBlock failure:(UAGithubEngineFailureBlock)failureBlock
  697
+{
  698
+    NSDictionary *params = [@{ @"read" : @"true" } copy];
  699
+    
  700
+    [self invoke:^(id self){[self sendRequest:[NSString stringWithFormat:@"repos/%@/notifications", repositoryPath] requestType:UAGithubNotificationsMarkReadRequest responseType:UAGithubNoContentResponse withParameters:params error:nil];} success:successBlock failure:failureBlock];
  701
+}
  702
+
  703
+- (void)markNotificationThreadAsRead:(NSInteger)threadId success:(UAGithubEngineSuccessBlock)successBlock failure:(UAGithubEngineFailureBlock)failureBlock
  704
+{
  705
+    NSDictionary *params = [@{ @"read" : @"true" } copy];
  706
+    
  707
+    [self invoke:^(id self){[self sendRequest:[NSString stringWithFormat:@"notifications/threads/%ld", threadId] requestType:UAGithubNotificationsMarkThreadReadRequest responseType:UAGithubNoContentResponse withParameters:params error:nil];} success:successBlock failure:failureBlock];
  708
+}
  709
+
  710
+- (void)currentUserIsSubscribedToNotificationThread:(NSInteger)threadId success:(UAGithubEngineSuccessBlock)successBlock failure:(UAGithubEngineFailureBlock)failureBlock
  711
+{
  712
+    [self invoke:^(id self){[self sendRequest:[NSString stringWithFormat:@"notifications/threads/%ld/subscription", threadId] requestType:UAGithubNotificationsRequest responseType:UAGithubNotificationThreadSubscriptionResponse error:nil];} success:successBlock failure:failureBlock];
  713
+}
  714
+
  715
+- (void)subscribeCurrentUserToNotificationThread:(NSInteger)threadId success:(UAGithubEngineSuccessBlock)successBlock failure:(UAGithubEngineFailureBlock)failureBlock
  716
+{
  717
+    NSDictionary *params = [@{ @"subscribed" : @"true" } copy];
  718
+    
  719
+    [self invoke:^(id self){[self sendRequest:[NSString stringWithFormat:@"notifications/threads/%ld/subscription", threadId] requestType:UAGithubNotificationThreadSubscriptionRequest responseType:UAGithubNotificationThreadSubscriptionResponse withParameters:params error:nil];} success:successBlock failure:failureBlock];
  720
+}
  721
+
  722
+- (void)unsubscribeCurrentUserFromNotificationThread:(NSInteger)threadId success:(UAGithubEngineSuccessBlock)successBlock failure:(UAGithubEngineFailureBlock)failureBlock
  723
+{
  724
+    NSDictionary *params = [@{ @"subscribed" : @"false" } copy];
  725
+    
  726
+    [self invoke:^(id self){[self sendRequest:[NSString stringWithFormat:@"notifications/threads/%ld/subscription", threadId] requestType:UAGithubNotificationDeleteSubscriptionRequest responseType:UAGithubNotificationThreadSubscriptionResponse withParameters:params error:nil];} success:successBlock failure:failureBlock];
  727
+}
  728
+
  729
+
663 730
 #pragma mark Events
664 731
 
665 732
 - (void)eventsForIssue:(NSInteger)issueId forRepository:(NSString *)repositoryPath success:(UAGithubEngineSuccessBlock)successBlock failure:(UAGithubEngineFailureBlock)failureBlock
8  UAGithubEngine/UAGithubEngineRequestTypes.h
@@ -124,6 +124,11 @@ typedef enum UAGithubRequestType
124 124
     UAGithubGistCommentCreateRequest,               // Create a new gist comment
125 125
     UAGithubGistCommentUpdateRequest,               // Edit a gist comment
126 126
     UAGithubGistCommentDeleteRequest,               // Delete a gist comment
  127
+    UAGithubNotificationsRequest,                   // List all notifications for the current user, grouped by repository
  128
+    UAGithubNotificationsMarkReadRequest,           // Mark a notification as read
  129
+    UAGithubNotificationsMarkThreadReadRequest,     // Mark a notification thread as read
  130
+    UAGithubNotificationThreadSubscriptionRequest,  // Subscribe or unsubscribe from a notification thread
  131
+    UAGithubNotificationDeleteSubscriptionRequest,  // Delete a notification thread subscription
127 132
     UAGithubIssueEventsRequest,                     // Get one or more issue events
128 133
     UAGithubIssueEventRequest,                           // Get exactly one issue event
129 134
     UAGithubPullRequestsRequest,                    // Get one or more pull requests
@@ -228,6 +233,9 @@ typedef enum UAGithubResponseType
228 233
     UAGithubPullRequestCommentsResponse,            // One or more pull request comments
229 234
     UAGithubPullRequestCommentResponse,             // Exactly one pull request comment
230 235
     UAGithubTagsResponse,							// Tags in name-SHA pairs
  236
+    UAGithubNotificationsResponse,                  // One or more notifications
  237
+    UAGithubNotificationThreadsResponse,            // One or more notification threads
  238
+    UAGithubNotificationThreadSubscriptionResponse, // Exactly one notification thread subscription
231 239
     UAGithubEventsResponse,                         // One or more events of unspecified type
232 240
     UAGithubOrganizationsResponse,                  // One or more organizations
233 241
     UAGithubOrganizationResponse,                   // Exactly one organization

0 notes on commit 877e0c8

Please sign in to comment.
Something went wrong with that request. Please try again.