//
//  ZYJQNZoneInfo.h
//  ZYJQiniuSDK
//
//  Created by yangsen on 2020/4/16.
//  Copyright © 2020 Qiniu. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

typedef NS_ENUM(NSUInteger, ZYJQNZoneInfoType) {
    ZYJQNZoneInfoTypeMain,
    ZYJQNZoneInfoTypeBackup,
};
typedef enum : NSUInteger {
    ZYJQNZoneRegion_z0,
    ZYJQNZoneRegion_z1,
    ZYJQNZoneRegion_z2,
    ZYJQNZoneRegion_as0,
    ZYJQNZoneRegion_na0,
    ZYJQNZoneRegion_unknown
} ZYJQNZoneRegion;

@interface ZYJQNZoneInfo : NSObject

@property (nonatomic, assign, readonly) ZYJQNZoneInfoType type;
@property (nonatomic, assign, readonly) long ttl;
@property (nonatomic, strong, readonly) NSArray<NSString *> *upDomainsList;
@property (nonatomic, strong, readonly) NSMutableDictionary *upDomainsDic;

- (instancetype)init:(long)ttl
       upDomainsList:(NSMutableArray<NSString *> *)upDomainsList
        upDomainsDic:(NSMutableDictionary *)upDomainsDic
          zoneRegion:(ZYJQNZoneRegion)zoneRegion;

- (ZYJQNZoneInfo *)buildInfoFromJson:(NSDictionary *)resp;

- (void)frozenDomain:(NSString *)domain;

- (BOOL)isValid;

@end

@interface ZYJQNZonesInfo : NSObject

@property (nonatomic, strong) NSArray<ZYJQNZoneInfo *> *zonesInfo;

@property (nonatomic, assign, readonly) BOOL hasBackupZone;

+ (instancetype)buildZonesInfoWithResp:(NSDictionary *)resp;

- (instancetype)initWithZonesInfo:(NSArray<ZYJQNZoneInfo *> *)zonesInfo;

- (ZYJQNZoneInfo *)getZoneInfoWithType:(ZYJQNZoneInfoType)type;

- (NSString *)getZoneInfoRegionNameWithType:(ZYJQNZoneInfoType)type;

@end

NS_ASSUME_NONNULL_END
