diff --git a/QueueITLib.xcodeproj/project.pbxproj b/QueueITLib.xcodeproj/project.pbxproj index 61e39c8..802abed 100644 --- a/QueueITLib.xcodeproj/project.pbxproj +++ b/QueueITLib.xcodeproj/project.pbxproj @@ -13,8 +13,8 @@ 1DDF312E1C931DC00036E5EB /* QueueCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 1DDF312D1C931DC00036E5EB /* QueueCache.m */; }; 1DE12F901B57E2ED00DD3BBE /* libQueueITLib.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DE12F841B57E2ED00DD3BBE /* libQueueITLib.a */; }; 1DE12FA71B57F0C000DD3BBE /* QueueITApiClient.m in Sources */ = {isa = PBXBuildFile; fileRef = 1DE12FA61B57F0C000DD3BBE /* QueueITApiClient.m */; }; - 1DE12FAA1B57F14D00DD3BBE /* QueueService_NSURLConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = 1DE12FA91B57F14D00DD3BBE /* QueueService_NSURLConnection.m */; }; - 1DE12FB01B57F24000DD3BBE /* QueueService_NSURLConnectionRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 1DE12FAF1B57F24000DD3BBE /* QueueService_NSURLConnectionRequest.m */; }; + 1DE12FAA1B57F14D00DD3BBE /* QueueITApiClient_NSURLConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = 1DE12FA91B57F14D00DD3BBE /* QueueITApiClient_NSURLConnection.m */; }; + 1DE12FB01B57F24000DD3BBE /* QueueITApiClient_NSURLConnectionRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 1DE12FAF1B57F24000DD3BBE /* QueueITApiClient_NSURLConnectionRequest.m */; }; 1DE12FBC1B57F3A300DD3BBE /* QueueStatus.m in Sources */ = {isa = PBXBuildFile; fileRef = 1DE12FBB1B57F3A300DD3BBE /* QueueStatus.m */; }; 1DE12FBF1B57F3DD00DD3BBE /* IOSUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 1DE12FBE1B57F3DD00DD3BBE /* IOSUtils.m */; }; 1DE12FC21B57F42500DD3BBE /* QueueITEngine.m in Sources */ = {isa = PBXBuildFile; fileRef = 1DE12FC11B57F42500DD3BBE /* QueueITEngine.m */; }; @@ -66,10 +66,10 @@ 1DE12F951B57E2EE00DD3BBE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 1DE12FA51B57F0C000DD3BBE /* QueueITApiClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QueueITApiClient.h; sourceTree = ""; }; 1DE12FA61B57F0C000DD3BBE /* QueueITApiClient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QueueITApiClient.m; sourceTree = ""; }; - 1DE12FA81B57F14D00DD3BBE /* QueueService_NSURLConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QueueService_NSURLConnection.h; sourceTree = ""; }; - 1DE12FA91B57F14D00DD3BBE /* QueueService_NSURLConnection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QueueService_NSURLConnection.m; sourceTree = ""; }; - 1DE12FAE1B57F23F00DD3BBE /* QueueService_NSURLConnectionRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QueueService_NSURLConnectionRequest.h; sourceTree = ""; }; - 1DE12FAF1B57F24000DD3BBE /* QueueService_NSURLConnectionRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QueueService_NSURLConnectionRequest.m; sourceTree = ""; }; + 1DE12FA81B57F14D00DD3BBE /* QueueITApiClient_NSURLConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QueueITApiClient_NSURLConnection.h; sourceTree = ""; }; + 1DE12FA91B57F14D00DD3BBE /* QueueITApiClient_NSURLConnection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QueueITApiClient_NSURLConnection.m; sourceTree = ""; }; + 1DE12FAE1B57F23F00DD3BBE /* QueueITApiClient_NSURLConnectionRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QueueITApiClient_NSURLConnectionRequest.h; sourceTree = ""; }; + 1DE12FAF1B57F24000DD3BBE /* QueueITApiClient_NSURLConnectionRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QueueITApiClient_NSURLConnectionRequest.m; sourceTree = ""; }; 1DE12FBA1B57F3A300DD3BBE /* QueueStatus.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QueueStatus.h; sourceTree = ""; }; 1DE12FBB1B57F3A300DD3BBE /* QueueStatus.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QueueStatus.m; sourceTree = ""; }; 1DE12FBD1B57F3DD00DD3BBE /* IOSUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IOSUtils.h; sourceTree = ""; }; @@ -172,10 +172,10 @@ children = ( 1DE12FA51B57F0C000DD3BBE /* QueueITApiClient.h */, 1DE12FA61B57F0C000DD3BBE /* QueueITApiClient.m */, - 1DE12FA81B57F14D00DD3BBE /* QueueService_NSURLConnection.h */, - 1DE12FA91B57F14D00DD3BBE /* QueueService_NSURLConnection.m */, - 1DE12FAE1B57F23F00DD3BBE /* QueueService_NSURLConnectionRequest.h */, - 1DE12FAF1B57F24000DD3BBE /* QueueService_NSURLConnectionRequest.m */, + 1DE12FA81B57F14D00DD3BBE /* QueueITApiClient_NSURLConnection.h */, + 1DE12FA91B57F14D00DD3BBE /* QueueITApiClient_NSURLConnection.m */, + 1DE12FAE1B57F23F00DD3BBE /* QueueITApiClient_NSURLConnectionRequest.h */, + 1DE12FAF1B57F24000DD3BBE /* QueueITApiClient_NSURLConnectionRequest.m */, 1DDF312C1C931DC00036E5EB /* QueueCache.h */, 1DDF312D1C931DC00036E5EB /* QueueCache.m */, ); @@ -307,10 +307,10 @@ files = ( AD68D81928363A6C00200800 /* QueueITWaitingRoomView.m in Sources */, AD5278A8284A44E500F70BF9 /* QueueTryPassResult.m in Sources */, - 1DE12FB01B57F24000DD3BBE /* QueueService_NSURLConnectionRequest.m in Sources */, + 1DE12FB01B57F24000DD3BBE /* QueueITApiClient_NSURLConnectionRequest.m in Sources */, 1DE12FC21B57F42500DD3BBE /* QueueITEngine.m in Sources */, 1DCB83FD1BCE5375009B489A /* Reachability.m in Sources */, - 1DE12FAA1B57F14D00DD3BBE /* QueueService_NSURLConnection.m in Sources */, + 1DE12FAA1B57F14D00DD3BBE /* QueueITApiClient_NSURLConnection.m in Sources */, 1DDF312E1C931DC00036E5EB /* QueueCache.m in Sources */, 1D0970CD1F5EA46E00495466 /* QueuePassedInfo.m in Sources */, AD742D2C2837CA60001234CE /* QueueITWaitingRoomProvider.m in Sources */, diff --git a/QueueITLib/QueueConsts.h b/QueueITLib/QueueConsts.h index 6e030b0..8ca6191 100644 --- a/QueueITLib/QueueConsts.h +++ b/QueueITLib/QueueConsts.h @@ -3,6 +3,6 @@ #define QueueCloseUrl @"queueit://close" #define QueueRestartSessionUrl @"queueit://restartSession" -#define SDKVersion @"iOS-3.1.14"; +#define SDKVersion @"iOS-3.3.0"; #endif diff --git a/QueueITLib/QueueITApiClient.m b/QueueITLib/QueueITApiClient.m index ae2441c..f40752e 100644 --- a/QueueITLib/QueueITApiClient.m +++ b/QueueITLib/QueueITApiClient.m @@ -1,5 +1,5 @@ #import "QueueITApiClient.h" -#import "QueueService_NSURLConnection.h" +#import "QueueITApiClient_NSURLConnection.h" static QueueITApiClient *SharedInstance; @@ -13,7 +13,7 @@ + (QueueITApiClient *)getInstance { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ - SharedInstance = [[QueueService_NSURLConnection alloc] init]; + SharedInstance = [[QueueITApiClient_NSURLConnection alloc] init]; }); return SharedInstance; diff --git a/QueueITLib/QueueService_NSURLConnection.h b/QueueITLib/QueueITApiClient_NSURLConnection.h similarity index 52% rename from QueueITLib/QueueService_NSURLConnection.h rename to QueueITLib/QueueITApiClient_NSURLConnection.h index 0b5bf5a..01071bf 100644 --- a/QueueITLib/QueueService_NSURLConnection.h +++ b/QueueITLib/QueueITApiClient_NSURLConnection.h @@ -1,6 +1,6 @@ #import #import "QueueITApiClient.h" -@interface QueueService_NSURLConnection : QueueITApiClient +@interface QueueITApiClient_NSURLConnection : QueueITApiClient @end diff --git a/QueueITLib/QueueService_NSURLConnection.m b/QueueITLib/QueueITApiClient_NSURLConnection.m similarity index 75% rename from QueueITLib/QueueService_NSURLConnection.m rename to QueueITLib/QueueITApiClient_NSURLConnection.m index 919e905..21edb11 100644 --- a/QueueITLib/QueueService_NSURLConnection.m +++ b/QueueITLib/QueueITApiClient_NSURLConnection.m @@ -1,11 +1,11 @@ -#import "QueueService_NSURLConnection.h" -#import "QueueService_NSURLConnectionRequest.h" +#import "QueueITApiClient_NSURLConnection.h" +#import "QueueITApiClient_NSURLConnectionRequest.h" -@interface QueueService_NSURLConnection() +@interface QueueITApiClient_NSURLConnection() @end -@implementation QueueService_NSURLConnection +@implementation QueueITApiClient_NSURLConnection - (NSString *)submitRequestWithURL:(NSURL *)URL method:(NSString *)httpMethod @@ -25,8 +25,8 @@ - (NSString *)submitRequestWithURL:(NSURL *)URL [request addValue:@"application/json" forHTTPHeaderField:@"Accept"]; [request addValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; - QueueService_NSURLConnectionRequest *connectionRequest; - connectionRequest = [[QueueService_NSURLConnectionRequest alloc] initWithRequest:request + QueueITApiClient_NSURLConnectionRequest *connectionRequest; + connectionRequest = [[QueueITApiClient_NSURLConnectionRequest alloc] initWithRequest:request expectedStatusCode:expectedStatus success:success failure:failure @@ -39,7 +39,7 @@ - (NSString *)submitRequestWithURL:(NSURL *)URL #pragma mark - NSURLConnectionRequestDelegate -- (void)requestDidComplete:(QueueService_NSURLConnectionRequest *)request +- (void)requestDidComplete:(QueueITApiClient_NSURLConnectionRequest *)request { } diff --git a/QueueITLib/QueueService_NSURLConnectionRequest.h b/QueueITLib/QueueITApiClient_NSURLConnectionRequest.h similarity index 73% rename from QueueITLib/QueueService_NSURLConnectionRequest.h rename to QueueITLib/QueueITApiClient_NSURLConnectionRequest.h index 8608f55..6b5013d 100644 --- a/QueueITLib/QueueService_NSURLConnectionRequest.h +++ b/QueueITLib/QueueITApiClient_NSURLConnectionRequest.h @@ -3,7 +3,7 @@ @protocol QueueService_NSURLConnectionRequestDelegate; -@interface QueueService_NSURLConnectionRequest : NSObject +@interface QueueITApiClient_NSURLConnectionRequest : NSObject - (NSString *)uniqueIdentifier; @@ -16,5 +16,5 @@ @end @protocol QueueService_NSURLConnectionRequestDelegate -- (void)requestDidComplete:(QueueService_NSURLConnectionRequest *)request; +- (void)requestDidComplete:(QueueITApiClient_NSURLConnectionRequest *)request; @end diff --git a/QueueITLib/QueueService_NSURLConnectionRequest.m b/QueueITLib/QueueITApiClient_NSURLConnectionRequest.m similarity index 96% rename from QueueITLib/QueueService_NSURLConnectionRequest.m rename to QueueITLib/QueueITApiClient_NSURLConnectionRequest.m index 1f8f47d..13cdcc5 100644 --- a/QueueITLib/QueueService_NSURLConnectionRequest.m +++ b/QueueITLib/QueueITApiClient_NSURLConnectionRequest.m @@ -1,7 +1,7 @@ -#import "QueueService_NSURLConnectionRequest.h" +#import "QueueITApiClient_NSURLConnectionRequest.h" -@interface QueueService_NSURLConnectionRequest() +@interface QueueITApiClient_NSURLConnectionRequest() @property (nonatomic, strong) NSURLConnection *connection; @property (nonatomic, strong) NSURLRequest *request; @@ -16,7 +16,7 @@ @interface QueueService_NSURLConnectionRequest() @end -@implementation QueueService_NSURLConnectionRequest +@implementation QueueITApiClient_NSURLConnectionRequest - (instancetype)initWithRequest:(NSURLRequest *)request expectedStatusCode:(NSInteger)statusCode diff --git a/QueueITLib/QueueITEngine.h b/QueueITLib/QueueITEngine.h index 1705b57..8931119 100644 --- a/QueueITLib/QueueITEngine.h +++ b/QueueITLib/QueueITEngine.h @@ -8,25 +8,29 @@ @protocol QueuePassedDelegate; @protocol QueueViewWillOpenDelegate; -@protocol QueueViewDidAppearDelegate; @protocol QueueDisabledDelegate; @protocol QueueITUnavailableDelegate; @protocol QueueUserExitedDelegate; +@protocol QueueITErrorDelegate; @protocol QueueViewClosedDelegate; @protocol QueueSessionRestartDelegate; -@protocol QueueSuccessDelegate; +@protocol QueueUrlChangedDelegate; + +@protocol QueueViewDidAppearDelegate; -@interface QueueITEngine : NSObject +@interface QueueITEngine : NSObject @property (nonatomic, weak)id _Nullable queuePassedDelegate; @property (nonatomic, weak)id _Nullable queueViewWillOpenDelegate; -@property (nonatomic, weak)id _Nullable queueViewDidAppearDelegate; @property (nonatomic, weak)id _Nullable queueDisabledDelegate; @property (nonatomic, weak)id _Nullable queueITUnavailableDelegate; -@property (nonatomic, weak)id _Nullable queueUserExitedDelegate; +@property (nonatomic, weak)id _Nullable queueErrorDelegate; @property (nonatomic, weak)id _Nullable queueViewClosedDelegate; +@property (nonatomic, weak)id _Nullable queueUserExitedDelegate; @property (nonatomic, weak)id _Nullable queueSessionRestartDelegate; -@property (nonatomic, weak)id _Nullable queueSuccessDelegate; +@property (nonatomic, weak)id _Nullable queueUrlChangedDelegate; + +@property (nonatomic, weak)id _Nullable queueViewDidAppearDelegate; @property (nonatomic, strong)NSString* _Nullable errorMessage; @property (nonatomic, copy)NSString* _Nonnull customerId; @@ -47,7 +51,6 @@ error:(NSError* _Nullable*_Nullable) error; -(BOOL)runWithEnqueueKey:(NSString* _Nonnull) enqueueKey error:(NSError* _Nullable*_Nullable) error; --(BOOL)isUserInQueue; -(BOOL)isRequestInProgress; @end @@ -56,35 +59,40 @@ -(void)notifyYourTurn:(QueuePassedInfo* _Nullable) queuePassedInfo; @end -@protocol QueueSessionRestartDelegate --(void)notifySessionRestart; -@end - @protocol QueueViewWillOpenDelegate -(void)notifyQueueViewWillOpen; @end -@protocol QueueViewDidAppearDelegate --(void)notifyQueueViewDidAppear; +@protocol QueueDisabledDelegate +-(void)notifyQueueDisabled:(QueueDisabledInfo* _Nullable) queueDisabledInfo; @end -@protocol QueueUserExitedDelegate --(void)notifyUserExited; +@protocol QueueITUnavailableDelegate +-(void)notifyQueueITUnavailable:(NSString* _Nonnull) errorMessage; +@end + +@protocol QueueITErrorDelegate +-(void)notifyQueueError:(NSString* _Nonnull) errorMessage errorCode:(long)errorCode; @end @protocol QueueViewClosedDelegate -(void)notifyViewClosed; @end -@protocol QueueDisabledDelegate --(void)notifyQueueDisabled:(QueueDisabledInfo* _Nullable) queueDisabledInfo; +@protocol QueueUserExitedDelegate +-(void)notifyUserExited; @end -@protocol QueueITUnavailableDelegate --(void)notifyQueueITUnavailable:(NSString* _Nonnull) errorMessage; +@protocol QueueSessionRestartDelegate +-(void)notifySessionRestart; +@end + +@protocol QueueUrlChangedDelegate +-(void)notifyQueueUrlChanged:(NSString* _Nonnull) url; @end -@protocol QueueSuccessDelegate --(void)notifyQueueSuccess:(QueueTryPassResult* _Nullable) queuePassResult; + +@protocol QueueViewDidAppearDelegate +-(void)notifyQueueViewDidAppear; @end diff --git a/QueueITLib/QueueITEngine.m b/QueueITLib/QueueITEngine.m index 482b0cc..1f22bdb 100644 --- a/QueueITLib/QueueITEngine.m +++ b/QueueITLib/QueueITEngine.m @@ -20,7 +20,7 @@ -(instancetype)initWithHost:(UIViewController *)host customerId:(NSString*)custo { self = [super init]; if(self) { - self.waitingRoomProvider = [[QueueITWaitingRoomProvider alloc] init:customerId + self.waitingRoomProvider = [[QueueITWaitingRoomProvider alloc] initWithCustomerId:customerId eventOrAliasId:eventOrAliasId layoutName:layoutName language:language]; @@ -33,17 +33,8 @@ -(instancetype)initWithHost:(UIViewController *)host customerId:(NSString*)custo self.layoutName = layoutName; self.language = language; - self.waitingRoomView.viewUserExitedDelegate = self; - self.waitingRoomView.viewUserClosedDelegate = self; - self.waitingRoomView.viewSessionRestartDelegate = self; - self.waitingRoomView.viewQueuePassedDelegate = self; - self.waitingRoomView.viewQueueWillOpenDelegate = self; - self.waitingRoomView.viewQueueUpdatePageUrlDelegate = self; - self.waitingRoomView.viewQueueDidAppearDelegate = self; - - self.waitingRoomProvider.providerQueueDisabledDelegate = self; - self.waitingRoomProvider.providerQueueITUnavailableDelegate = self; - self.waitingRoomProvider.providerSuccessDelegate = self; + self.waitingRoomView.queueITWaitingRoomViewDelegate = self; + self.waitingRoomProvider.waitingRoomProviderDelegate = self; } return self; } @@ -52,10 +43,6 @@ -(void)setViewDelay:(int)delayInterval { [self.waitingRoomView setViewDelay:delayInterval]; } --(BOOL)isUserInQueue { - return [self.waitingRoomView isUserInQueue]; -} - -(BOOL)isRequestInProgress { return [self.waitingRoomProvider IsRequestInProgress]; } @@ -63,13 +50,19 @@ -(BOOL)isRequestInProgress { -(BOOL)runWithEnqueueKey:(NSString *)enqueueKey error:(NSError *__autoreleasing *)error { - return [self.waitingRoomProvider TryPassWithEnqueueKey:enqueueKey error:error]; + if(![self tryShowQueueFromCache]) { + return [self.waitingRoomProvider TryPassWithEnqueueKey:enqueueKey error:error]; + } + return YES; } -(BOOL)runWithEnqueueToken:(NSString *)enqueueToken error:(NSError *__autoreleasing *)error { - return [self.waitingRoomProvider TryPassWithEnqueueToken:enqueueToken error:error]; + if(![self tryShowQueueFromCache]) { + return [self.waitingRoomProvider TryPassWithEnqueueToken:enqueueToken error:error]; + } + return YES; } -(BOOL)run:(NSError **)error @@ -100,8 +93,6 @@ -(BOOL)tryShowQueueFromCache -(void)showQueue:(NSString*)queueUrl targetUrl:(NSString*)targetUrl { - [self notifyViewQueueWillOpen]; - [self.waitingRoomView show:queueUrl targetUrl:targetUrl]; } @@ -114,45 +105,46 @@ -(void)updateQueuePageUrl:(NSString *)queuePageUrl } } --(void)notifyViewUserExited { - [self.queueUserExitedDelegate notifyUserExited]; +- (void)waitingRoomView:(nonnull QueueITWaitingRoomView *)view notifyViewPassedQueue:(QueuePassedInfo * _Nullable)queuePassedInfo { + [self.cache clear]; + [self.queuePassedDelegate notifyYourTurn:queuePassedInfo]; } -- (void)notifyViewUserClosed { - [self.queueViewClosedDelegate notifyViewClosed]; +- (void)notifyViewQueueWillOpen:(nonnull QueueITWaitingRoomView *)view { + [self.queueViewWillOpenDelegate notifyQueueViewWillOpen]; } --(void)notifyViewSessionRestart { - [self.cache clear]; - [self.queueSessionRestartDelegate notifySessionRestart]; +- (void)waitingRoomProvider:(nonnull QueueITWaitingRoomProvider *)provider notifyProviderFailure:(NSString * _Nullable)errorMessage errorCode:(long)errorCode { + if(errorCode == 3) { + [self.queueITUnavailableDelegate notifyQueueITUnavailable:errorMessage]; + } + + [self.queueErrorDelegate notifyQueueError:errorMessage errorCode:errorCode]; } --(void) notifyViewPassedQueue:(QueuePassedInfo *)queuePassedInfo { +- (void)notifyViewSessionRestart:(nonnull QueueITWaitingRoomView *)view { [self.cache clear]; - [self.queuePassedDelegate notifyYourTurn:queuePassedInfo]; + [self.queueSessionRestartDelegate notifySessionRestart]; } --(void) notifyViewQueueDidAppear{ - [self.queueViewDidAppearDelegate notifyQueueViewDidAppear]; +- (void)notifyViewUserExited:(nonnull QueueITWaitingRoomView *)view { + [self.queueUserExitedDelegate notifyUserExited]; } --(void) notifyViewQueueWillOpen { - [self.queueViewWillOpenDelegate notifyQueueViewWillOpen]; +- (void)notifyViewUserClosed:(nonnull QueueITWaitingRoomView *)view { + [self.queueViewClosedDelegate notifyViewClosed]; } --(void) notifyViewUpdatePageUrl:(NSString* _Nullable) urlString { +- (void)waitingRoomView:(nonnull QueueITWaitingRoomView *)view notifyViewUpdatePageUrl:(NSString * _Nullable)urlString { [self updateQueuePageUrl:urlString]; + [self.queueUrlChangedDelegate notifyQueueUrlChanged:urlString]; } --(void) notifyProviderQueueDisabled:(QueueDisabledInfo *)queueDisabledInfo { - [self.queueDisabledDelegate notifyQueueDisabled:queueDisabledInfo]; -} - --(void)notifyProviderQueueITUnavailable:(NSString* _Nonnull) errorMessage { - [self.queueITUnavailableDelegate notifyQueueITUnavailable:errorMessage]; +-(void)notifyViewQueueDidAppear:(nonnull QueueITWaitingRoomView *)view { + [self.queueViewDidAppearDelegate notifyQueueViewDidAppear]; } --(void)notifyProviderSuccess:(QueueTryPassResult* _Nonnull) queuePassResult { +- (void)waitingRoomProvider:(nonnull QueueITWaitingRoomProvider *)provider notifyProviderSuccess:(QueueTryPassResult * _Nonnull)queuePassResult { if([[queuePassResult redirectType] isEqual: @"safetynet"]) { QueuePassedInfo* queuePassedInfo = [[QueuePassedInfo alloc] initWithQueueitToken:queuePassResult.queueToken]; @@ -167,8 +159,10 @@ -(void)notifyProviderSuccess:(QueueTryPassResult* _Nonnull) queuePassResult { } [self showQueue:queuePassResult.queueUrl targetUrl:queuePassResult.targetUrl]; - [self.cache clear]; - [self.queueSuccessDelegate notifyQueueSuccess:queuePassResult]; + + if(queuePassResult.urlTTLInMinutes>0){ + NSString* urlTtlString = [IOSUtils convertTtlMinutesToSecondsString:queuePassResult.urlTTLInMinutes]; + [self.cache update:queuePassResult.queueUrl urlTTL:urlTtlString targetUrl:queuePassResult.targetUrl]; + } } - @end diff --git a/QueueITLib/QueueITWKViewController.h b/QueueITLib/QueueITWKViewController.h index 76dffa4..7d0c5db 100644 --- a/QueueITLib/QueueITWKViewController.h +++ b/QueueITLib/QueueITWKViewController.h @@ -1,18 +1,10 @@ #import -@protocol ViewControllerClosedDelegate; -@protocol ViewControllerUserExitedDelegate; -@protocol ViewControllerSessionRestartDelegate; -@protocol ViewControllerQueuePassedDelegate; -@protocol ViewControllerPageUrlChangedDelegate; +@protocol QueueITViewControllerDelegate; @interface QueueITWKViewController : UIViewController -@property (nonatomic, weak)id _Nullable viewControllerClosedDelegate; -@property (nonatomic, weak)id _Nullable viewControllerUserExitedDelegate; -@property (nonatomic, weak)id _Nullable viewControllerRestartDelegate; -@property (nonatomic, weak)id _Nullable viewControllerQueuePassedDelegate; -@property (nonatomic, weak)id _Nullable viewControllerPageUrlChangedDelegate; +@property (nonatomic, weak)id _Nullable viewControllerDelegate; -(instancetype _Nullable )initWithHost:(nonnull UIViewController *)host queueUrl:(nonnull NSString*)queueUrl @@ -29,22 +21,10 @@ @end -@protocol ViewControllerClosedDelegate +@protocol QueueITViewControllerDelegate -(void)notifyViewControllerClosed; -@end - -@protocol ViewControllerUserExitedDelegate -(void)notifyViewControllerUserExited; -@end - -@protocol ViewControllerSessionRestartDelegate -(void)notifyViewControllerSessionRestart; -@end - -@protocol ViewControllerQueuePassedDelegate -(void)notifyViewControllerQueuePassed:(NSString* _Nullable) queueToken; -@end - -@protocol ViewControllerPageUrlChangedDelegate -(void)notifyViewControllerPageUrlChanged:(NSString* _Nullable) urlString; @end diff --git a/QueueITLib/QueueITWKViewController.m b/QueueITLib/QueueITWKViewController.m index e2c66df..a950f69 100644 --- a/QueueITLib/QueueITWKViewController.m +++ b/QueueITLib/QueueITWKViewController.m @@ -66,13 +66,13 @@ - (BOOL)handleSpecialUrls:(NSURL*) url decisionHandler:(nonnull void (^)(WKNavigationActionPolicy))decisionHandler { if([[url absoluteString] isEqualToString: QueueCloseUrl]){ [self close: ^{ - [self.viewControllerClosedDelegate notifyViewControllerClosed]; + [self.viewControllerDelegate notifyViewControllerClosed]; }]; decisionHandler(WKNavigationActionPolicyCancel); return true; } else if ([[url absoluteString] isEqualToString: QueueRestartSessionUrl]){ [self close:^{ - [self.viewControllerRestartDelegate notifyViewControllerSessionRestart]; + [self.viewControllerDelegate notifyViewControllerSessionRestart]; }]; decisionHandler(WKNavigationActionPolicyCancel); return true; @@ -156,7 +156,7 @@ - (void)webView:(WKWebView*)webView decidePolicyForNavigationAction:(nonnull WKN destinationUrl: url]) { self.isQueuePassed = YES; NSString* queueitToken = [self extractQueueToken:url.absoluteString]; - [self.viewControllerQueuePassedDelegate notifyViewControllerQueuePassed:queueitToken]; + [self.viewControllerDelegate notifyViewControllerQueuePassed:queueitToken]; [self.host dismissViewControllerAnimated:YES completion:^{ }]; decisionHandler(WKNavigationActionPolicyCancel); @@ -218,14 +218,14 @@ - (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigat NSArray *htmlBodyClasses = [resultString componentsSeparatedByString:@" "]; BOOL isExitClassPresent = [htmlBodyClasses containsObject:@"exit"]; if (isExitClassPresent) { - [self.viewControllerUserExitedDelegate notifyViewControllerUserExited]; + [self.viewControllerDelegate notifyViewControllerUserExited]; } } }]; } - (void)raiseQueuePageUrl:(NSString *)urlString { - [self.viewControllerPageUrlChangedDelegate notifyViewControllerPageUrlChanged:urlString]; + [self.viewControllerDelegate notifyViewControllerPageUrlChanged:urlString]; } -(void)appWillResignActive:(NSNotification*)note diff --git a/QueueITLib/QueueITWaitingRoomProvider.h b/QueueITLib/QueueITWaitingRoomProvider.h index d98ad5a..8198035 100644 --- a/QueueITLib/QueueITWaitingRoomProvider.h +++ b/QueueITLib/QueueITWaitingRoomProvider.h @@ -1,9 +1,7 @@ #import "QueueITWaitingRoomView.h" #import "QueueTryPassResult.h" -@protocol ProviderQueueDisabledDelegate; -@protocol ProviderQueueITUnavailableDelegate; -@protocol ProviderSuccessDelegate; +@protocol QueueITWaitingRoomProviderDelegate; @interface QueueITWaitingRoomProvider : NSObject @@ -13,29 +11,24 @@ typedef enum { } QueueITRuntimeError; #define QueueITRuntimeErrorArray @"Network connection is unavailable", @"Enqueue request is already in progress", nil -@property (nonatomic, weak)id _Nullable providerQueueDisabledDelegate; -@property (nonatomic, weak)id _Nullable providerQueueITUnavailableDelegate; -@property (nonatomic, weak)id _Nullable providerSuccessDelegate; +@property (nonatomic, weak)id _Nullable waitingRoomProviderDelegate; --(instancetype _Nonnull)init:(NSString* _Nonnull)customerId +-(instancetype _Nonnull)initWithCustomerId:(NSString* _Nonnull)customerId eventOrAliasId:(NSString* _Nonnull)eventOrAliasId layoutName:(NSString* _Nullable)layoutName language:(NSString* _Nullable)language; -(BOOL)TryPass: (NSError* _Nullable*_Nullable)error; --(BOOL)TryPassWithEnqueueToken:(NSString* _Nullable)enqueueToken error:(NSError* _Nullable*_Nullable)error; --(BOOL)TryPassWithEnqueueKey:(NSString* _Nullable)enqueueKey error:(NSError* _Nullable*_Nullable)error; +-(BOOL)TryPassWithEnqueueToken:(NSString* _Nullable)enqueueToken + error:(NSError* _Nullable*_Nullable)error; +-(BOOL)TryPassWithEnqueueKey:(NSString* _Nullable)enqueueKey + error:(NSError* _Nullable*_Nullable)error; -(BOOL)IsRequestInProgress; @end -@protocol ProviderQueueDisabledDelegate --(void)notifyProviderQueueDisabled:(QueueDisabledInfo* _Nullable) queueDisabledInfo; -@end - -@protocol ProviderQueueITUnavailableDelegate --(void)notifyProviderQueueITUnavailable:(NSString* _Nonnull) errorMessage; -@end +@protocol QueueITWaitingRoomProviderDelegate -@protocol ProviderSuccessDelegate --(void)notifyProviderSuccess:(QueueTryPassResult* _Nonnull) queuePassResult; +-(void)waitingRoomProvider:(nonnull QueueITWaitingRoomProvider*)provider notifyProviderSuccess:(QueueTryPassResult* _Nonnull) queuePassResult; +-(void)waitingRoomProvider:(nonnull QueueITWaitingRoomProvider*)provider notifyProviderFailure:(NSString* _Nullable)errorMessage + errorCode:(long)errorCode; @end diff --git a/QueueITLib/QueueITWaitingRoomProvider.m b/QueueITLib/QueueITWaitingRoomProvider.m index 5068c06..6c91fc5 100644 --- a/QueueITLib/QueueITWaitingRoomProvider.m +++ b/QueueITLib/QueueITWaitingRoomProvider.m @@ -24,7 +24,7 @@ @implementation QueueITWaitingRoomProvider static int MAX_RETRY_SEC = 10; static int INITIAL_WAIT_RETRY_SEC = 1; --(instancetype _Nonnull)init:(NSString* _Nonnull)customerId +-(instancetype _Nonnull)initWithCustomerId:(NSString* _Nonnull)customerId eventOrAliasId:(NSString* _Nonnull)eventOrAliasId layoutName:(NSString* _Nullable)layoutName language:(NSString* _Nullable)language { @@ -112,7 +112,7 @@ -(void)tryEnqueueWithUserAgent:(NSString*)secretAgent { if (error.code >= 400 && error.code < 500) { - [self.providerQueueITUnavailableDelegate notifyProviderQueueITUnavailable: errorMessage]; + [self.waitingRoomProviderDelegate waitingRoomProvider:self notifyProviderFailure:errorMessage errorCode:error.code]; } else { @@ -127,7 +127,7 @@ -(void)handleAppEnqueueResponse:(NSString*) queueId eventTargetURL:(NSString*) targetURL queueItToken:(NSString*) token { - bool isPassedThrough = [self isNullOrEmpty:token]; + bool isPassedThrough = ![self isNullOrEmpty:token]; NSString* redirectType = [self getRedirectTypeFromToken:token]; @@ -138,7 +138,7 @@ -(void)handleAppEnqueueResponse:(NSString*) queueId isPassedThrough:isPassedThrough queueToken:token]; - [self.providerSuccessDelegate notifyProviderSuccess:queueTryPassResult]; + [self.waitingRoomProviderDelegate waitingRoomProvider:self notifyProviderSuccess:queueTryPassResult]; } -(void)enqueueRetryMonitor:(NSString*)enqueueToken @@ -155,7 +155,7 @@ -(void)enqueueRetryMonitor:(NSString*)enqueueToken { self.deltaSec = INITIAL_WAIT_RETRY_SEC; self.requestInProgress = NO; - [self.providerQueueITUnavailableDelegate notifyProviderQueueITUnavailable: @"Unexpected error. Try again later"]; + [self.waitingRoomProviderDelegate waitingRoomProvider:self notifyProviderFailure:@"Error! Queue is unavailable." errorCode:3]; } } @@ -183,22 +183,6 @@ -(BOOL)IsRequestInProgress { return self.requestInProgress; } --(BOOL)isSafetyNet:(NSString*) queueId - queueURL:(NSString*) queueURL -{ - bool queueIdExists = queueId != nil && queueId != (id)[NSNull null]; - bool queueUrlExists = queueURL != nil && queueURL != (id)[NSNull null]; - return queueIdExists && !queueUrlExists; -} - --(BOOL)isDisabled:(NSString*) queueId - queueURL:(NSString*) queueURL -{ - bool queueIdExists = queueId != nil && queueId != (id)[NSNull null]; - bool queueUrlExists = queueURL != nil && queueURL != (id)[NSNull null]; - return !queueIdExists && !queueUrlExists; -} - -(BOOL)isNullOrEmpty:(NSString*)queueToken { bool isNull = queueToken == nil || queueToken == (id)[NSNull null]; bool isEmpty = isNull || [queueToken length] == 0; diff --git a/QueueITLib/QueueITWaitingRoomView.h b/QueueITLib/QueueITWaitingRoomView.h index 9526933..385e5c0 100644 --- a/QueueITLib/QueueITWaitingRoomView.h +++ b/QueueITLib/QueueITWaitingRoomView.h @@ -2,23 +2,11 @@ #import "QueueDisabledInfo.h" #import "QueuePassedInfo.h" -@protocol ViewQueuePassedDelegate; -@protocol ViewQueueWillOpenDelegate; -@protocol ViewUserClosedDelegate; -@protocol ViewUserExitedDelegate; -@protocol ViewSessionRestartDelegate; -@protocol ViewQueueUpdatePageUrlDelegate; -@protocol ViewQueueDidAppearDelegate; +@protocol QueueITWaitingRoomViewDelegate; -@interface QueueITWaitingRoomView : NSObject +@interface QueueITWaitingRoomView : NSObject -@property (nonatomic, weak)id _Nullable viewUserExitedDelegate; -@property (nonatomic, weak)id _Nullable viewUserClosedDelegate; -@property (nonatomic, weak)id _Nullable viewSessionRestartDelegate; -@property (nonatomic, weak)id _Nullable viewQueuePassedDelegate; -@property (nonatomic, weak)id _Nullable viewQueueDidAppearDelegate; -@property (nonatomic, weak)id _Nullable viewQueueWillOpenDelegate; -@property (nonatomic, weak)id _Nullable viewQueueUpdatePageUrlDelegate; +@property (nonatomic, weak)id _Nullable queueITWaitingRoomViewDelegate; -(instancetype _Nonnull)initWithHost:(UIViewController* _Nonnull)host customerId: (NSString* _Nonnull)customerId @@ -26,35 +14,16 @@ -(void)show:(NSString* _Nonnull)queueUrl targetUrl:(NSString* _Nonnull)targetUrl; -(void)setViewDelay:(int)delayInterval; --(BOOL)isUserInQueue; -(void)close:(void (^ __nullable)(void))onComplete; @end -@protocol ViewUserExitedDelegate --(void) notifyViewUserExited; -@end - -@protocol ViewUserClosedDelegate --(void) notifyViewUserClosed; -@end - -@protocol ViewSessionRestartDelegate --(void) notifyViewSessionRestart; -@end - -@protocol ViewQueuePassedDelegate --(void) notifyViewPassedQueue:(QueuePassedInfo* _Nullable)queuePassedInfo; -@end - -@protocol ViewQueueDidAppearDelegate --(void) notifyViewQueueDidAppear; -@end - -@protocol ViewQueueWillOpenDelegate --(void) notifyViewQueueWillOpen; -@end - -@protocol ViewQueueUpdatePageUrlDelegate --(void) notifyViewUpdatePageUrl:(NSString* _Nullable) urlString; +@protocol QueueITWaitingRoomViewDelegate +-(void) notifyViewUserExited:(nonnull QueueITWaitingRoomView*)view; +-(void) notifyViewUserClosed:(nonnull QueueITWaitingRoomView*)view; +-(void) notifyViewSessionRestart:(nonnull QueueITWaitingRoomView*)view; +-(void) waitingRoomView:(nonnull QueueITWaitingRoomView*)view notifyViewPassedQueue:(QueuePassedInfo* _Nullable)queuePassedInfo; +-(void) notifyViewQueueDidAppear:(nonnull QueueITWaitingRoomView*)view; +-(void) notifyViewQueueWillOpen:(nonnull QueueITWaitingRoomView*)view; +-(void) waitingRoomView:(nonnull QueueITWaitingRoomView*)view notifyViewUpdatePageUrl:(NSString* _Nullable) urlString; @end diff --git a/QueueITLib/QueueITWaitingRoomView.m b/QueueITLib/QueueITWaitingRoomView.m index ac392df..a7fdc16 100644 --- a/QueueITLib/QueueITWaitingRoomView.m +++ b/QueueITLib/QueueITWaitingRoomView.m @@ -8,7 +8,6 @@ @interface QueueITWaitingRoomView () @property NSString* customerId; @property NSString* eventId; @property int delayInterval; -@property BOOL isInQueue; @end @implementation QueueITWaitingRoomView @@ -37,11 +36,7 @@ -(void) show:(NSString* _Nonnull)queueUrl targetUrl:(NSString* _Nonnull)targetUr customerId:self.customerId eventId:self.eventId]; - queueWKVC.viewControllerClosedDelegate = self; - queueWKVC.viewControllerUserExitedDelegate = self; - queueWKVC.viewControllerRestartDelegate = self; - queueWKVC.viewControllerQueuePassedDelegate = self; - queueWKVC.viewControllerPageUrlChangedDelegate = self; + queueWKVC.viewControllerDelegate = self; if (@available(iOS 13.0, *)) { [queueWKVC setModalPresentationStyle: UIModalPresentationFullScreen]; @@ -50,15 +45,14 @@ -(void) show:(NSString* _Nonnull)queueUrl targetUrl:(NSString* _Nonnull)targetUr dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(self.delayInterval * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [self.host presentViewController:queueWKVC animated:YES completion:^{ self.currentWebView = queueWKVC; - self.isInQueue = YES; - [self.viewQueueDidAppearDelegate notifyViewQueueDidAppear ]; + [self.queueITWaitingRoomViewDelegate notifyViewQueueDidAppear:self ]; }]; }); } else { dispatch_async(dispatch_get_main_queue(), ^{ [self.host presentViewController:queueWKVC animated:YES completion:^{ self.currentWebView = queueWKVC; - [self.viewQueueDidAppearDelegate notifyViewQueueDidAppear ]; + [self.queueITWaitingRoomViewDelegate notifyViewQueueDidAppear:self ]; }]; }); } @@ -74,41 +68,32 @@ -(void)close:(void (^ __nullable)(void))onComplete } - (void)raiseQueueViewWillOpen { - [self.viewQueueWillOpenDelegate notifyViewQueueWillOpen]; + [self.queueITWaitingRoomViewDelegate notifyViewQueueWillOpen:self]; } -(void)setViewDelay:(int)delayInterval { self.delayInterval = delayInterval; } --(BOOL)isUserInQueue { - return self.isInQueue; -} - -(void) notifyViewControllerUserExited { - if (self.isInQueue) { - [self.viewUserExitedDelegate notifyViewUserExited]; - self.isInQueue = NO; - } + [self.queueITWaitingRoomViewDelegate notifyViewUserExited:self]; } -(void) notifyViewControllerClosed { - [self.viewUserClosedDelegate notifyViewUserClosed]; + [self.queueITWaitingRoomViewDelegate notifyViewUserClosed:self]; } -(void) notifyViewControllerSessionRestart { - [self.viewSessionRestartDelegate notifyViewSessionRestart]; + [self.queueITWaitingRoomViewDelegate notifyViewSessionRestart:self]; } -(void) notifyViewControllerQueuePassed:(NSString *)queueToken { - self.isInQueue = NO; - QueuePassedInfo* queuePassedInfo = [[QueuePassedInfo alloc] initWithQueueitToken:queueToken]; - [self.viewQueuePassedDelegate notifyViewPassedQueue:queuePassedInfo]; + [self.queueITWaitingRoomViewDelegate waitingRoomView:self notifyViewPassedQueue:queuePassedInfo]; } -(void)notifyViewControllerPageUrlChanged:(NSString* _Nullable) urlString { - [self.viewQueueUpdatePageUrlDelegate notifyViewUpdatePageUrl:urlString]; + [self.queueITWaitingRoomViewDelegate waitingRoomView:self notifyViewUpdatePageUrl:urlString]; } @end diff --git a/QueueITLib/QueueService.h b/QueueITLib/QueueService.h deleted file mode 100644 index 81dd543..0000000 --- a/QueueITLib/QueueService.h +++ /dev/null @@ -1,23 +0,0 @@ -#import -#import "QueueStatus.h" - -typedef void (^QueueServiceSuccess)(NSData *data); -typedef void (^QueueServiceFailure)(NSError *error, NSString* errorMessage); - -@interface QueueService : NSObject -+ (QueueService *)sharedInstance; -+ (void) setTesting:(bool)enabled; - --(NSString*)enqueue:(NSString*)customerId - eventOrAliasId:(NSString*)eventorAliasId - userId:(NSString*)userId - userAgent:(NSString*)userAgent - sdkVersion:(NSString*)sdkVersion - layoutName:(NSString*)layoutName - language:(NSString*)language - enqueueToken:(NSString*)enqueueToken - enqueueKey:(NSString*)enqueueKey - success:(void(^)(QueueStatus* queueStatus))success - failure:(QueueServiceFailure)failure; - -@end diff --git a/QueueITLib/QueueService.m b/QueueITLib/QueueService.m deleted file mode 100644 index 62d51cf..0000000 --- a/QueueITLib/QueueService.m +++ /dev/null @@ -1,118 +0,0 @@ -#import "QueueService.h" -#import "QueueService_NSURLConnection.h" - -static QueueService *SharedInstance; - -static NSString * const API_ROOT = @"https://%@.queue-it.net/api/mobileapp/queue"; -static NSString * const TESTING_API_ROOT = @"https://%@.test.queue-it.net/api/mobileapp/queue"; -static bool testingIsEnabled = NO; - -@implementation QueueService - -+ (QueueService *)sharedInstance -{ - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - SharedInstance = [[QueueService_NSURLConnection alloc] init]; - }); - - return SharedInstance; -} - -+ (void) setTesting:(bool)enabled -{ - testingIsEnabled = enabled; -} - --(NSString*)enqueue:(NSString *)customerId - eventOrAliasId:(NSString *)eventorAliasId - userId:(NSString *)userId - userAgent:(NSString *)userAgent - sdkVersion:(NSString*)sdkVersion - layoutName:(NSString*)layoutName - language:(NSString*)language - enqueueToken:(NSString*)enqueueToken - enqueueKey:(NSString*)enqueueKey - success:(void (^)(QueueStatus *))success - failure:(QueueServiceFailure)failure -{ - NSMutableDictionary* bodyDict = [[NSMutableDictionary alloc] init]; - [bodyDict setObject:userId forKey:@"userId"]; - [bodyDict setObject:userAgent forKey:@"userAgent"]; - [bodyDict setObject:sdkVersion forKey:@"sdkVersion"]; - - if(layoutName){ - [bodyDict setObject:layoutName forKey:@"layoutName"]; - } - - if(language){ - [bodyDict setObject:language forKey:@"language"]; - } - - if(enqueueToken){ - [bodyDict setObject:enqueueToken forKey:@"enqueueToken"]; - } - - if(enqueueKey){ - [bodyDict setObject:enqueueKey forKey:@"enqueueKey"]; - } - - NSString* urlAsString; - if(testingIsEnabled){ - urlAsString = [NSString stringWithFormat:TESTING_API_ROOT, customerId]; - }else{ - urlAsString = [NSString stringWithFormat:API_ROOT, customerId]; - } - urlAsString = [urlAsString stringByAppendingString:[NSString stringWithFormat:@"/%@", customerId]]; - urlAsString = [urlAsString stringByAppendingString:[NSString stringWithFormat:@"/%@", eventorAliasId]]; - urlAsString = [urlAsString stringByAppendingString:[NSString stringWithFormat:@"/enqueue"]]; - - return [self submitPOSTPath:urlAsString body:bodyDict - success:^(NSData *data) - { - NSError *error = nil; - NSDictionary *userDict = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error]; - if (userDict && [userDict isKindOfClass:[NSDictionary class]]) - { - QueueStatus* queueStatus = [[QueueStatus alloc] initWithDictionary:userDict]; - - if (success != NULL) { - success(queueStatus); - } - } else if (success != NULL) { - success(NULL); - } - } - failure:^(NSError *error, NSString* errorMessage) - { - failure(error, errorMessage); - } - ]; -} - -- (NSString *)submitPOSTPath:(NSString *)path - body:(NSDictionary *)bodyDict - success:(QueueServiceSuccess)success - failure:(QueueServiceFailure)failure -{ - NSURL *url = [NSURL URLWithString:path]; - return [self submitRequestWithURL:url - method:@"POST" - body:bodyDict - expectedStatus:200 - success:success - failure:failure]; -} - -#pragma mark - Abstract methods -- (NSString *)submitRequestWithURL:(NSURL *)URL - method:(NSString *)httpMethod - body:(NSDictionary *)bodyDict - expectedStatus:(NSInteger)expectedStatus - success:(QueueServiceSuccess)success - failure:(QueueServiceFailure)failure -{ - return nil; -} - -@end diff --git a/QueueITLib/QueueStatus.m b/QueueITLib/QueueStatus.m index 5942575..d56cbfd 100644 --- a/QueueITLib/QueueStatus.m +++ b/QueueITLib/QueueStatus.m @@ -27,17 +27,42 @@ -(instancetype)init:(NSString *)queueId - (instancetype)initWithDictionary:(NSDictionary *)dictionary { + NSString *queueId; + NSString *queueUrlString; + NSString *eventTargetUrl; + NSString *queueitToken; int queueUrlTTL = 0; + id value; + if(![dictionary[KEY_QUEUE_URL_TTL_IN_MINUTES] isEqual:[NSNull null]]) { queueUrlTTL = [dictionary[KEY_QUEUE_URL_TTL_IN_MINUTES] intValue]; } - return [self init:dictionary[KEY_QUEUE_ID] - queueUrl:dictionary[KEY_QUEUE_URL] - eventTargetUrl:dictionary[KEY_EVENT_TARGET_URL] + value = dictionary[KEY_QUEUE_ID]; + if ([value isKindOfClass:[NSString class]]) { + queueId = (NSString*)value; + } + + value = dictionary[KEY_QUEUE_URL]; + if ([value isKindOfClass:[NSString class]]) { + queueUrlString = (NSString*)value; + } + + value = dictionary[KEY_EVENT_TARGET_URL]; + if ([value isKindOfClass:[NSString class]]) { + eventTargetUrl = (NSString*)value; + } + + value = dictionary[KEY_QUEUEIT_TOKEN]; + if ([value isKindOfClass:[NSString class]]) { + queueitToken = (NSString*)value; + } + + return [self init:queueId + queueUrl:queueUrlString + eventTargetUrl:eventTargetUrl queueUrlTTL:queueUrlTTL - queueitToken:dictionary[KEY_QUEUEIT_TOKEN]]; + queueitToken:queueitToken]; } - @end diff --git a/QueueITLib/QueueTryPassResult.h b/QueueITLib/QueueTryPassResult.h index 0be1a91..71c1784 100644 --- a/QueueITLib/QueueTryPassResult.h +++ b/QueueITLib/QueueTryPassResult.h @@ -2,8 +2,8 @@ @interface QueueTryPassResult : NSObject -@property (nonatomic, strong) NSString* _Nonnull queueUrl; -@property (nonatomic, strong) NSString* _Nonnull targetUrl; +@property (nonatomic, strong) NSString* _Nullable queueUrl; +@property (nonatomic, strong) NSString* _Nullable targetUrl; @property (nonatomic) int urlTTLInMinutes; @property (nonatomic, strong) NSString* _Nonnull redirectType; @property (nonatomic) BOOL isPassedThrough; @@ -12,7 +12,7 @@ -(instancetype _Nonnull ) initWithQueueUrl: (NSString* _Nullable) queueUrl - targetUrl:(NSString* _Nonnull)targetUrl + targetUrl:(NSString* _Nullable)targetUrl urlTTLInMinutes: (int) urlTTLInMinutes redirectType: (NSString* _Nonnull) redirectType isPassedThrough: (BOOL) isPassedThrough diff --git a/QueueITLib/QueueTryPassResult.m b/QueueITLib/QueueTryPassResult.m index cd86aab..1e753e7 100644 --- a/QueueITLib/QueueTryPassResult.m +++ b/QueueITLib/QueueTryPassResult.m @@ -5,7 +5,7 @@ @implementation QueueTryPassResult -(instancetype _Nonnull ) initWithQueueUrl: (NSString* _Nullable) queueUrl - targetUrl:(NSString* _Nonnull)targetUrl + targetUrl:(NSString* _Nullable)targetUrl urlTTLInMinutes: (int) urlTTLInMinutes redirectType: (NSString* _Nonnull) redirectType isPassedThrough: (BOOL) isPassedThrough @@ -17,6 +17,7 @@ @implementation QueueTryPassResult self.urlTTLInMinutes = urlTTLInMinutes; self.redirectType = redirectType; self.isPassedThrough = isPassedThrough; + self.queueToken = queueToken; } return self; diff --git a/create_framework.sh b/create_framework.sh deleted file mode 100755 index 29c5a53..0000000 --- a/create_framework.sh +++ /dev/null @@ -1,15 +0,0 @@ -xcodebuild build -scheme QueueITLib -derivedDataPath ./builds/simulator -arch x86_64 -sdk iphonesimulator \ - && xcodebuild build -scheme QueueITLib -derivedDataPath ./builds/ios -sdk iphoneos \ - && xcodebuild build -scheme QueueITLib -derivedDataPath ./builds/simulator-arm64 -arch arm64 -sdk iphonesimulator \ - && lipo -create builds/simulator/Build/Products/Debug-iphonesimulator/libQueueITLib.a \ - builds/simulator-arm64/Build/Products/Debug-iphonesimulator/libQueueITLib.a \ - -output builds/simulator/libQueueITLib.a \ - && mkdir dist \ - && xcodebuild -create-xcframework \ - -library builds/ios/Build/Products/Debug-iphoneos/libQueueITLib.a \ - -headers builds/ios/Build/Products/Debug-iphoneos/include/QueueITLib \ - -library builds/simulator/libQueueITLib.a \ - -headers builds/simulator/Build/Products/Debug-iphonesimulator/include/QueueITLib \ - -output dist/QueueITLib.xcframework \ - && cd dist \ - && zip -r -X QueueITLib.xcframework.zip QueueITLib.xcframework \ No newline at end of file diff --git a/dist/QueueITLib.xcframework.zip b/dist/QueueITLib.xcframework.zip deleted file mode 100644 index ee7531d..0000000 Binary files a/dist/QueueITLib.xcframework.zip and /dev/null differ diff --git a/dist/QueueITLib.xcframework/Info.plist b/dist/QueueITLib.xcframework/Info.plist deleted file mode 100644 index b50ff70..0000000 --- a/dist/QueueITLib.xcframework/Info.plist +++ /dev/null @@ -1,45 +0,0 @@ - - - - - AvailableLibraries - - - HeadersPath - Headers - LibraryIdentifier - ios-arm64_x86_64-simulator - LibraryPath - libQueueITLib.a - SupportedArchitectures - - arm64 - x86_64 - - SupportedPlatform - ios - SupportedPlatformVariant - simulator - - - HeadersPath - Headers - LibraryIdentifier - ios-arm64_armv7 - LibraryPath - libQueueITLib.a - SupportedArchitectures - - arm64 - armv7 - - SupportedPlatform - ios - - - CFBundlePackageType - XFWK - XCFrameworkFormatVersion - 1.0 - - diff --git a/dist/QueueITLib.xcframework/ios-arm64_armv7/Headers/QueueConsts.h b/dist/QueueITLib.xcframework/ios-arm64_armv7/Headers/QueueConsts.h deleted file mode 100644 index 6e030b0..0000000 --- a/dist/QueueITLib.xcframework/ios-arm64_armv7/Headers/QueueConsts.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef QueueConsts_h -#define QueueConsts_h - -#define QueueCloseUrl @"queueit://close" -#define QueueRestartSessionUrl @"queueit://restartSession" -#define SDKVersion @"iOS-3.1.14"; - -#endif diff --git a/dist/QueueITLib.xcframework/ios-arm64_armv7/Headers/QueueITEngine.h b/dist/QueueITLib.xcframework/ios-arm64_armv7/Headers/QueueITEngine.h deleted file mode 100644 index 1705b57..0000000 --- a/dist/QueueITLib.xcframework/ios-arm64_armv7/Headers/QueueITEngine.h +++ /dev/null @@ -1,90 +0,0 @@ -#import -#import "QueuePassedInfo.h" -#import "QueueDisabledInfo.h" -#import "QueueTryPassResult.h" -#import "QueueConsts.h" -#import "QueueITWaitingRoomView.h" -#import "QueueITWaitingRoomProvider.h" - -@protocol QueuePassedDelegate; -@protocol QueueViewWillOpenDelegate; -@protocol QueueViewDidAppearDelegate; -@protocol QueueDisabledDelegate; -@protocol QueueITUnavailableDelegate; -@protocol QueueUserExitedDelegate; -@protocol QueueViewClosedDelegate; -@protocol QueueSessionRestartDelegate; -@protocol QueueSuccessDelegate; - -@interface QueueITEngine : NSObject - -@property (nonatomic, weak)id _Nullable queuePassedDelegate; -@property (nonatomic, weak)id _Nullable queueViewWillOpenDelegate; -@property (nonatomic, weak)id _Nullable queueViewDidAppearDelegate; -@property (nonatomic, weak)id _Nullable queueDisabledDelegate; -@property (nonatomic, weak)id _Nullable queueITUnavailableDelegate; -@property (nonatomic, weak)id _Nullable queueUserExitedDelegate; -@property (nonatomic, weak)id _Nullable queueViewClosedDelegate; -@property (nonatomic, weak)id _Nullable queueSessionRestartDelegate; -@property (nonatomic, weak)id _Nullable queueSuccessDelegate; - -@property (nonatomic, strong)NSString* _Nullable errorMessage; -@property (nonatomic, copy)NSString* _Nonnull customerId; -@property (nonatomic, copy)NSString* _Nonnull eventId; -@property (nonatomic, copy)NSString* _Nullable layoutName; -@property (nonatomic, copy)NSString* _Nullable language; - --(instancetype _Nonnull )initWithHost:(UIViewController* _Nonnull)host - customerId:(NSString* _Nonnull)customerId - eventOrAliasId:(NSString* _Nonnull)eventOrAliasId - layoutName:(NSString* _Nullable)layoutName - language:(NSString* _Nullable)language; - --(void)setViewDelay:(int)delayInterval; - --(BOOL)run:(NSError* _Nullable* _Nullable)error; --(BOOL)runWithEnqueueToken:(NSString* _Nonnull) enqueueToken - error:(NSError* _Nullable*_Nullable) error; --(BOOL)runWithEnqueueKey:(NSString* _Nonnull) enqueueKey - error:(NSError* _Nullable*_Nullable) error; --(BOOL)isUserInQueue; --(BOOL)isRequestInProgress; - -@end - -@protocol QueuePassedDelegate --(void)notifyYourTurn:(QueuePassedInfo* _Nullable) queuePassedInfo; -@end - -@protocol QueueSessionRestartDelegate --(void)notifySessionRestart; -@end - - -@protocol QueueViewWillOpenDelegate --(void)notifyQueueViewWillOpen; -@end - -@protocol QueueViewDidAppearDelegate --(void)notifyQueueViewDidAppear; -@end - -@protocol QueueUserExitedDelegate --(void)notifyUserExited; -@end - -@protocol QueueViewClosedDelegate --(void)notifyViewClosed; -@end - -@protocol QueueDisabledDelegate --(void)notifyQueueDisabled:(QueueDisabledInfo* _Nullable) queueDisabledInfo; -@end - -@protocol QueueITUnavailableDelegate --(void)notifyQueueITUnavailable:(NSString* _Nonnull) errorMessage; -@end - -@protocol QueueSuccessDelegate --(void)notifyQueueSuccess:(QueueTryPassResult* _Nullable) queuePassResult; -@end diff --git a/dist/QueueITLib.xcframework/ios-arm64_armv7/Headers/QueuePassedInfo.h b/dist/QueueITLib.xcframework/ios-arm64_armv7/Headers/QueuePassedInfo.h deleted file mode 100644 index 36fcc6f..0000000 --- a/dist/QueueITLib.xcframework/ios-arm64_armv7/Headers/QueuePassedInfo.h +++ /dev/null @@ -1,9 +0,0 @@ -#import - -@interface QueuePassedInfo : NSObject - -@property (nonatomic, strong) NSString* _Nullable queueitToken; - --(instancetype _Nonnull )initWithQueueitToken:(NSString* _Nullable) queueitToken; - -@end diff --git a/dist/QueueITLib.xcframework/ios-arm64_armv7/libQueueITLib.a b/dist/QueueITLib.xcframework/ios-arm64_armv7/libQueueITLib.a deleted file mode 100644 index dc4b722..0000000 Binary files a/dist/QueueITLib.xcframework/ios-arm64_armv7/libQueueITLib.a and /dev/null differ diff --git a/dist/QueueITLib.xcframework/ios-arm64_x86_64-simulator/Headers/QueueConsts.h b/dist/QueueITLib.xcframework/ios-arm64_x86_64-simulator/Headers/QueueConsts.h deleted file mode 100644 index 6e030b0..0000000 --- a/dist/QueueITLib.xcframework/ios-arm64_x86_64-simulator/Headers/QueueConsts.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef QueueConsts_h -#define QueueConsts_h - -#define QueueCloseUrl @"queueit://close" -#define QueueRestartSessionUrl @"queueit://restartSession" -#define SDKVersion @"iOS-3.1.14"; - -#endif diff --git a/dist/QueueITLib.xcframework/ios-arm64_x86_64-simulator/Headers/QueueITEngine.h b/dist/QueueITLib.xcframework/ios-arm64_x86_64-simulator/Headers/QueueITEngine.h deleted file mode 100644 index 1705b57..0000000 --- a/dist/QueueITLib.xcframework/ios-arm64_x86_64-simulator/Headers/QueueITEngine.h +++ /dev/null @@ -1,90 +0,0 @@ -#import -#import "QueuePassedInfo.h" -#import "QueueDisabledInfo.h" -#import "QueueTryPassResult.h" -#import "QueueConsts.h" -#import "QueueITWaitingRoomView.h" -#import "QueueITWaitingRoomProvider.h" - -@protocol QueuePassedDelegate; -@protocol QueueViewWillOpenDelegate; -@protocol QueueViewDidAppearDelegate; -@protocol QueueDisabledDelegate; -@protocol QueueITUnavailableDelegate; -@protocol QueueUserExitedDelegate; -@protocol QueueViewClosedDelegate; -@protocol QueueSessionRestartDelegate; -@protocol QueueSuccessDelegate; - -@interface QueueITEngine : NSObject - -@property (nonatomic, weak)id _Nullable queuePassedDelegate; -@property (nonatomic, weak)id _Nullable queueViewWillOpenDelegate; -@property (nonatomic, weak)id _Nullable queueViewDidAppearDelegate; -@property (nonatomic, weak)id _Nullable queueDisabledDelegate; -@property (nonatomic, weak)id _Nullable queueITUnavailableDelegate; -@property (nonatomic, weak)id _Nullable queueUserExitedDelegate; -@property (nonatomic, weak)id _Nullable queueViewClosedDelegate; -@property (nonatomic, weak)id _Nullable queueSessionRestartDelegate; -@property (nonatomic, weak)id _Nullable queueSuccessDelegate; - -@property (nonatomic, strong)NSString* _Nullable errorMessage; -@property (nonatomic, copy)NSString* _Nonnull customerId; -@property (nonatomic, copy)NSString* _Nonnull eventId; -@property (nonatomic, copy)NSString* _Nullable layoutName; -@property (nonatomic, copy)NSString* _Nullable language; - --(instancetype _Nonnull )initWithHost:(UIViewController* _Nonnull)host - customerId:(NSString* _Nonnull)customerId - eventOrAliasId:(NSString* _Nonnull)eventOrAliasId - layoutName:(NSString* _Nullable)layoutName - language:(NSString* _Nullable)language; - --(void)setViewDelay:(int)delayInterval; - --(BOOL)run:(NSError* _Nullable* _Nullable)error; --(BOOL)runWithEnqueueToken:(NSString* _Nonnull) enqueueToken - error:(NSError* _Nullable*_Nullable) error; --(BOOL)runWithEnqueueKey:(NSString* _Nonnull) enqueueKey - error:(NSError* _Nullable*_Nullable) error; --(BOOL)isUserInQueue; --(BOOL)isRequestInProgress; - -@end - -@protocol QueuePassedDelegate --(void)notifyYourTurn:(QueuePassedInfo* _Nullable) queuePassedInfo; -@end - -@protocol QueueSessionRestartDelegate --(void)notifySessionRestart; -@end - - -@protocol QueueViewWillOpenDelegate --(void)notifyQueueViewWillOpen; -@end - -@protocol QueueViewDidAppearDelegate --(void)notifyQueueViewDidAppear; -@end - -@protocol QueueUserExitedDelegate --(void)notifyUserExited; -@end - -@protocol QueueViewClosedDelegate --(void)notifyViewClosed; -@end - -@protocol QueueDisabledDelegate --(void)notifyQueueDisabled:(QueueDisabledInfo* _Nullable) queueDisabledInfo; -@end - -@protocol QueueITUnavailableDelegate --(void)notifyQueueITUnavailable:(NSString* _Nonnull) errorMessage; -@end - -@protocol QueueSuccessDelegate --(void)notifyQueueSuccess:(QueueTryPassResult* _Nullable) queuePassResult; -@end diff --git a/dist/QueueITLib.xcframework/ios-arm64_x86_64-simulator/Headers/QueuePassedInfo.h b/dist/QueueITLib.xcframework/ios-arm64_x86_64-simulator/Headers/QueuePassedInfo.h deleted file mode 100644 index 36fcc6f..0000000 --- a/dist/QueueITLib.xcframework/ios-arm64_x86_64-simulator/Headers/QueuePassedInfo.h +++ /dev/null @@ -1,9 +0,0 @@ -#import - -@interface QueuePassedInfo : NSObject - -@property (nonatomic, strong) NSString* _Nullable queueitToken; - --(instancetype _Nonnull )initWithQueueitToken:(NSString* _Nullable) queueitToken; - -@end diff --git a/dist/QueueITLib.xcframework/ios-arm64_x86_64-simulator/libQueueITLib.a b/dist/QueueITLib.xcframework/ios-arm64_x86_64-simulator/libQueueITLib.a deleted file mode 100644 index a0f2338..0000000 Binary files a/dist/QueueITLib.xcframework/ios-arm64_x86_64-simulator/libQueueITLib.a and /dev/null differ diff --git a/vnext-QueueITLibrary.podspec b/vnext-QueueITLibrary.podspec index 702f984..f8ffd1a 100644 --- a/vnext-QueueITLibrary.podspec +++ b/vnext-QueueITLibrary.podspec @@ -6,7 +6,7 @@ s.homepage = "https://github.com/queueit/ios-webui-sdk" s.license = 'MIT' s.authors = { 'Queue-It' => 'https://queue-it.com' } s.platform = :ios, '9.3' -s.source = { :git => 'https://github.com/queueit/ios-webui-sdk.git', :branch => 'poc-vnext', :tag => '3.1.14' } +s.source = { :git => 'https://github.com/queueit/ios-webui-sdk.git', :branch => 'poc-vnext', :tag => '3.3.0' } s.requires_arc = true s.source_files = "QueueITLib/*.{h,m}" end