Reduce usage of contacts intersection endpoint.
// FREEBIE
This commit is contained in:
parent
1d946ccfed
commit
00f1b53e61
|
@ -6,6 +6,9 @@
|
|||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
extern NSString *const kContactsUpdaterErrorDomain;
|
||||
extern const NSInteger kContactsUpdaterRateLimitErrorCode;
|
||||
|
||||
@class Contact;
|
||||
|
||||
@interface ContactsUpdater : NSObject
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}];
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue