//
//  MBIMBridgeOperation.h
//  kordophoned
//
//  Created by James Magahern on 11/13/18.
//  Copyright © 2018 James Magahern. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "HTTPMessage.h"
#import "HTTPResponse.h"
#import "HTTPErrorResponse.h"

#import "MBIMJSONDataResponse.h"

NS_ASSUME_NONNULL_BEGIN

typedef void (^MBIMBridgeOperationCompletionBlock)(NSObject<HTTPResponse> * _Nullable response);

@interface MBIMBridgeOperation : NSOperation
@property (class, nonatomic, readonly) NSString *endpointName;
@property (class, nonatomic, readonly) BOOL requiresAuthentication; // default YES

@property (nonatomic, strong) HTTPMessage *request;
@property (nonatomic, strong) NSData *requestBodyData;
@property (nonatomic, readonly) NSURL *requestURL;
@property (nonatomic, readonly) MBIMBridgeOperationCompletionBlock serverCompletionBlock;

+ (dispatch_queue_t)sharedIMAccessQueue;

+ (nullable Class)operationClassForEndpointName:(NSString *)endpointName;
- (instancetype)initWithRequestURL:(NSURL *)requestURL completion:(MBIMBridgeOperationCompletionBlock)completionBlock;

- (NSObject<HTTPResponse> *)cancelAndReturnTimeoutResponse;

// convenience
- (nullable NSString *)valueForQueryItemWithName:(NSString *)queryItemName;

@end

NS_ASSUME_NONNULL_END
