Reduce usage of contacts intersection endpoint.

// FREEBIE
This commit is contained in:
Matthew Chen 2017-04-13 10:10:38 -04:00
parent 1d946ccfed
commit 00f1b53e61
2 changed files with 15 additions and 1 deletions

View File

@ -6,6 +6,9 @@
NS_ASSUME_NONNULL_BEGIN
extern NSString *const kContactsUpdaterErrorDomain;
extern const NSInteger kContactsUpdaterRateLimitErrorCode;
@class Contact;
@interface ContactsUpdater : NSObject

View File

@ -14,6 +14,9 @@
NS_ASSUME_NONNULL_BEGIN
NSString *const kContactsUpdaterErrorDomain = @"kContactsUpdaterErrorDomain";
const NSInteger kContactsUpdaterRateLimitErrorCode = 413;
@implementation ContactsUpdater
+ (instancetype)sharedUpdater {
@ -206,7 +209,15 @@ NS_ASSUME_NONNULL_BEGIN
success([NSSet setWithArray:attributesForIdentifier.allKeys]);
}
failure:^(NSURLSessionDataTask *task, NSError *error) {
failure(error);
NSHTTPURLResponse *response = (NSHTTPURLResponse *)task.response;
if (response.statusCode == 413) {
NSString *const kContactsUpdaterErrorDomain = @"kContactsUpdaterErrorDomain";
failure([NSError errorWithDomain:kContactsUpdaterErrorDomain
code:kContactsUpdaterRateLimitErrorCode
userInfo:nil]);
} else {
failure(error);
}
}];
});
}