//
//  NimbleMTXTransaction.h
//  NimbleMTX
//
//  Created by Machine Union (dev361) on 2012-11-29.
//  Copyright (c) 2012 Electronic Arts. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <NimbleBase/NimbleError.h>

typedef void (^NimbleMTXValidateReceiptLocallyCallback)(NimbleError* error);

typedef enum
{
	NIMBLE_MTX_TRANSACTION_TYPE_PURCHASE,
	NIMBLE_MTX_TRANSACTION_TYPE_RESTORE
} NimbleMTXTransactionType;

typedef enum
{
	NIMBLE_MTX_TRANSACTION_STATE_UNDEFINED,
	NIMBLE_MTX_TRANSACTION_STATE_USER_INITIATED,
	NIMBLE_MTX_TRANSACTION_STATE_WAITING_FOR_PREPURCHASE_INFO,
	NIMBLE_MTX_TRANSACTION_STATE_WAITING_FOR_PLATFORM_RESPONSE,
	NIMBLE_MTX_TRANSACTION_STATE_WAITING_FOR_VERIFICATION,
	NIMBLE_MTX_TRANSACTION_STATE_WAITING_FOR_GAME_TO_CONFIRM_ITEM_GRANT,
	NIMBLE_MTX_TRANSACTION_STATE_WAITING_FOR_PLATFORM_CONSUMPTION,
	NIMBLE_MTX_TRANSACTION_STATE_COMPLETE
} NimbleMTXTransactionState;

@protocol NimbleMTXTransaction <NSObject>

// transactionId returns a local Nimble-generated ID. This is separate from the 1st party (StoreKit) transaction ID.
@property (nonatomic, copy, readonly) NSString* transactionId;

@property (nonatomic, copy, readonly) NSString* itemSku;

@property (nonatomic, assign, readonly) NimbleMTXTransactionState transactionState;

@property (nonatomic, assign, readonly) NimbleMTXTransactionType transactionType;

@property (nonatomic, assign, readonly) float priceDecimal;

//@property (nonatomic, assign, readonly) NSString* currencyCode;

@property (nonatomic, copy, readonly) NSDate* timestamp;

@property (nonatomic, copy, readonly) NSString* receipt;

@property (nonatomic, retain, readonly) NSDictionary* additionalInfo;

@property (nonatomic, retain, readonly) NSError* error;

/*!
 * Validate iOS7-style receipt locally. (GOSREQ-1084)
 * The game team must call this manually. There is no automated action by Nimble.
 *
 * @param ValidateReceiptLocallyCallback callback containing error if available, null otherwise
 */
- (void)validateReceiptLocally:(NimbleMTXValidateReceiptLocallyCallback)callback;

- (NSString*)getItemSellId;

@end
