//
// © 2018-2020 Qualcomm Technologies, Inc. and/or its subsidiaries. All rights reserved.
//

#import <Foundation/Foundation.h>

@class IoTWrappedRepresentation;
@class IoTServiceDiscoveryResult;
@protocol IoTTransportDispatcher;

NS_ASSUME_NONNULL_BEGIN

typedef NSDictionary<NSString *, NSString *> * IoTQueryParams;
typedef void(^IoTTransportDispatcherCompletion)(IoTWrappedRepresentation * rep, int code);
typedef void(^IoTTransportDispatcherObserveCompletion)(IoTWrappedRepresentation *rep, int code, int sequenceNumber);

typedef void(^IoTTransportServiceDiscoveredCallback)(IoTServiceDiscoveryResult *discoveredService);
typedef void(^IoTTransportResourceDiscoveredCallback)(NSString *resource);

@protocol IoTTransport <NSObject>

- (void)scanForServicesOfTypes:(NSSet<NSString *> *)types
             serviceDiscovered:(IoTTransportServiceDiscoveredCallback)serviceDiscovered
                         queue:(dispatch_queue_t)serviceDiscoveredQueue;

- (void)scanForResourcesForHost:(NSString *)host
                      uriPrefix:(NSString *)uriPrefix
             resourceDiscovered:(IoTTransportResourceDiscoveredCallback)resourceDiscovered
                          queue:(dispatch_queue_t)resourceDiscoveredQueue;

- (id<IoTTransportDispatcher>)dispatcher;

- (void)start;

- (void)stop;

@end

@protocol IoTTransportDispatcher <NSObject>

- (void)configureForHost:(NSString *)host
                     uri:(NSString *)uri
            resourceType:(NSString *)resourceType
              interfaces:(NSArray<NSString *> *)interfaces
              observable:(BOOL)observable;

- (BOOL)getWithQueryParameters:(IoTQueryParams)params
                    completion:(IoTTransportDispatcherCompletion)completion
               completionQueue:(dispatch_queue_t)completionQueue;

- (BOOL)postAttributes:(IoTWrappedRepresentation *)representation
       queryParameters:(IoTQueryParams)queryParams
            completion:(IoTTransportDispatcherCompletion)completion
       completionQueue:(dispatch_queue_t)completionQueue;

- (BOOL)startObservingWithQueryParameters:(IoTQueryParams)params
                               didObserve:(IoTTransportDispatcherObserveCompletion)didObserve
                             observeQueue:(dispatch_queue_t)observeQueue;

- (void)stopObserving;

@end

NS_ASSUME_NONNULL_END
