BBASMPMSPackage.h 2.77 KB
//
//  BBASMPMSPackage.h
//  SWAN
//
//  Created by baidu on 2018/11/2.
//  Copyright © 2018 baidu. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "BBASMPMSCommon.h"

NS_ASSUME_NONNULL_BEGIN

extern NSString *const kBBASMAppPackageExtKeyIsOptimize;

/**
 * PMS package model.
 */
@interface BBASMPMSPackage : NSObject
/// Represent the field `bundle_id`. Package bundle ID. If the type is app main package, it means `app_id`, but not `app_key`.
@property (nonatomic, copy) NSString *packageID;
/// Represent the field `category`. Default is `BBASMPMSCategoryNotSet`. Must be set as swan
@property (nonatomic, assign) BBASMPMSCategory category;
/// Represent the field `version_code` in response data.
@property (nonatomic, assign) NSInteger versionCode;
/// Represent the field `version_name` in response data, string value of `versionCode`.
@property (nonatomic, copy) NSString *versionName;
/// Represent the field `pkg_type`. It means the main app is a released version or in other state.
@property (nonatomic, assign) BBASMPMSAppState appState;
/// Represent the field `size`. Package size in byte.
@property (nonatomic, assign) NSInteger size;
/// Represent the field `md5`. Swan app md5.
@property (nonatomic, copy) NSString *md5;
/// Represent the field `sign`. Swan app package signature.
@property (nonatomic, copy) NSString *signature;
/// Represent the field `download_url`. Package download url.
@property (nonatomic, copy) NSString *downloadUrl;
/// Represent the field `independent`. Means whether the subpage is independent, only appears in `sub`.
@property (nonatomic, assign) BOOL independent;
/// Represent the field `sub_path`.
@property (nonatomic, copy) NSString *subPath;
/// Represent the field `max_age`.
@property (nonatomic, strong) NSNumber *maxAge;
/// Represent package type.
@property (nonatomic, assign) BBASMPMSPackageType type;
/// The unzipped package file or directory path. It will be `nil` value if the package has not been downloaded and unzipped.
@property (nonatomic, copy) NSString *unzippedFilePath;
/// installScene
@property (nonatomic, assign) NSInteger installScene;
/// Represent the field `ext`, extension information.
@property (nonatomic, copy) NSDictionary *extInfo;

- (instancetype)initWithType:(BBASMPMSPackageType)type
                  dictionary:(NSDictionary *)dict;


#pragma mark - DB convert
/**
 * @brief 将package模型转换为小程序DB需要的字典类型,key由DB定义。
 * @return 转换后的Dict
 */
- (NSDictionary *)dictForDB;
/**
 * @brief 将DB中取出的字典转换成package模型,key由DB定义。
 * @param type 包类型
 * @param DBdict 小程序DB中取出的dict
 * @return 转换后的package
 */
- (instancetype)initWithType:(BBASMPMSPackageType)type DBdictionary:(NSDictionary *)DBdict;

@end

NS_ASSUME_NONNULL_END