//
//  AliyunIdentityAdapter.h
//  AliyunIdentityAdapter
//
//  Copyright © 2024 aliyun.com. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <AliyunIdentityNetwork/IDVNetworkEnvProvider.h>

NS_ASSUME_NONNULL_BEGIN

//! Project version number for AliyunIdentityAdapter.
FOUNDATION_EXPORT double AliyunIdentityAdapterVersionNumber;

//! Project version string for AliyunIdentityAdapter.
FOUNDATION_EXPORT const unsigned char AliyunIdentityAdapterVersionString[];

#pragma mark - Region Definition

/**
 * 区域枚举 - 区分国内/国际环境
 */
typedef NS_ENUM(NSInteger, IDVRegion) {
    IDVRegionChina = 0,          // 国内
    IDVRegionInternational = 1   // 国际
};

#pragma mark - Feature Flags

/**
 * 功能开关 - 控制国内/国际差异功能
 */
@interface IDVFeatureFlags : NSObject

/// 是否支持 WebSocket 通信
@property (nonatomic, readonly) BOOL supportsWebSocket;

/// 是否支持 NFC 护照读取
@property (nonatomic, readonly) BOOL supportsNFC;

/// 是否启用 TLS 证书链验证
@property (nonatomic, readonly) BOOL enablesTLSCertValidation;

/// 是否启用崩溃上报
@property (nonatomic, readonly) BOOL enablesCrashReporting;

/// 是否支持 Cloudflare 兜底
@property (nonatomic, readonly) BOOL supportsCloudflareBackup;

- (instancetype)initWithRegion:(IDVRegion)region;

@end

#pragma mark - AliyunIdentityAdapter

/**
 * 数据处理适配层
 *
 * 国内/国际环境差异的唯一隔离点。
 * 实现 IDVNetworkEnvProvider 协议，为 Network 层提供环境配置。
 * 管理证件类型过滤、API 参数适配、Feature Flag 等。
 */
@interface AliyunIdentityAdapter : NSObject <IDVNetworkEnvProvider>

+ (instancetype)sharedInstance;

#pragma mark - Configuration

/// 初始化时设置区域 (必须在 Platform install 之前调用)
- (void)configureWithRegion:(IDVRegion)region;

/// 当前区域
@property (nonatomic, readonly) IDVRegion currentRegion;

/// 当前区域的 Feature Flags
@property (nonatomic, strong, readonly) IDVFeatureFlags *featureFlags;

#pragma mark - Environment (IDVNetworkEnvProvider)

/// 设置网络环境 (online/pre/dev)
- (void)setNetEnv:(NSInteger)envCode;

/// 使用 certifyId 更新动态端点 (国际版根据 certifyId 前缀选择区域)
- (void)updateEndpointsWithCertifyId:(NSString *)certifyId;

#pragma mark - Document Types

/// 获取当前区域支持的证件类型列表
- (NSArray<NSString *> *)supportedDocumentTypes;

/// 判断指定证件类型在当前区域是否支持
- (BOOL)isDocumentTypeSupported:(NSString *)documentType;

#pragma mark - API Adaptation

/// 适配 API 请求参数 (处理国内/国际 Action 和 Version 差异)
- (NSDictionary *)adaptRequestParams:(NSDictionary *)params forAction:(NSString *)action;

/// 适配 API 响应数据 (处理国内/国际返回格式差异)
- (NSDictionary *)adaptResponseData:(NSDictionary *)response forAction:(NSString *)action;

#pragma mark - Crash Reporting Policy

/// 崩溃上报策略由 featureFlags.enablesCrashReporting 决定，
/// 实际的崩溃捕获与上报由 AliyunCrashKit 在 Platform 层承载（国内/国际通用，
/// 崩溃数据统一上报 cloudauth-device.aliyuncs.com）。

@end

NS_ASSUME_NONNULL_END
