//
//  XXGIAPTransactionModel.h
//  XXGIAPHelp
//
//  Created by kane on 2018/8/8.
//  Copyright © 2018年 kane. All rights reserved.
//

#import <Foundation/Foundation.h>


typedef NS_ENUM(NSUInteger, TransactionStatus) {
    TransactionStatusWaitApple,
    TransactionStatusAppleCancel,
    TransactionStatusAppleFailed,
    TransactionStatusAppleSucc,
    TransactionStatusSeriverError,
    TransactionStatusSeriverFailed,
    TransactionStatusSeriverSucc,
};


@interface XXGIAPTransactionModel : NSObject

#pragma mark - Properties

/**
 * 事务 id.
 */
@property(nonatomic, copy) NSString *xxpk_transactionIdentifier;

/**
 * 交易时间(添加到交易队列时的时间).
 */
@property(nonatomic, strong, readonly) NSDate *xxpk_transactionDate;

/**
 * 商品 id.
 */
@property(nonatomic, copy, readonly) NSString *xxpk_productIdentifier;

/// 请求里的applicationUsername
@property (nonatomic, copy) NSString *xxpk_applicationUsername;


/**
 订单状态
 */
@property(nonatomic, assign) TransactionStatus xxpk_transactionStatus;



/* 票据 */
@property (nonatomic,copy)NSString * xxpk_appStoreReceipt;


/**
 错误信息
 */
@property (nonatomic, strong) NSError *xxpk_error;


/// 检测次数,如果在
@property (nonatomic, assign) NSInteger xxpk_cancelStatusCheckCount;

/* 以下属性,只有使用订单号参数购买方式:
 - (void)buyProductWithUserID:(NSString *)userid
 productIdentifier:(NSString *)productIdentifier
                      orderId:(NSString *)orderId; 才有值 */

/**
 * 用户 id.
 */
@property(nonatomic, copy, readonly) NSString *xxpk_userId;

/**
 * 后台配置的订单号.
 */
@property(nonatomic, copy,readonly) NSString *xxpk_seriverOrder;

/**
 * 价格字符.
 */
@property(nonatomic, copy) NSString *xxpk_priceString;

/**
 * 货币
 */
@property(nonatomic, copy) NSString *xxpk_codeString;


#pragma mark - Method

/**
 * 初始化方法(没有收据的).
 *
 * @warning: 所有数据都必须有值, 否则会报错, 并返回 nil.
 *
 * @param productIdentifier       商品 id.
 * @param applicationUsername   applicationUsername
 */
+ (instancetype)xxpk_modelWithProductIdentifier:(NSString *)productIdentifier
                       applicationUsername:(NSString *)applicationUsername;

+ (XXGIAPTransactionModel *)xxpk_modelWithDic:(NSDictionary *)dic;
- (NSMutableDictionary *)xxpk_toDic;


@end
