<commit_before>//
//  GBIAP2Manager.h
//  GBIAP2
//
//  Created by <NAME> on 21/05/2013.
//  Copyright (c) 2013 Goonbee. All rights reserved.
//

#import <Foundation/Foundation.h>

#pragma mark - Types

typedef enum {
    GBIAP2MetadataFetchStateUnknown,
    GBIAP2MetadataFetchStateSuccess,
    GBIAP2MetadataFetchStateFailed,
} GBIAP2MetadataFetchState;

typedef enum {
    GBIAP2PurchaseStateUnknown,
    GBIAP2PurchaseStateSuccess,
    GBIAP2PurchaseStateCancelled,
    GBIAP2PurchaseStateFailed,
} GBIAP2PurchaseState;

typedef enum {
    GBIAP2VerificationStateUnknown,
    GBIAP2VerificationStateSuccess,
    GBIAP2VerificationStateFailed,
} GBIAP2VerificationState;

typedef enum {
    GBIAP2TransactionTypeUnknown,
    GBIAP2TransactionTypePurchase,
    GBIAP2TransactionTypeRePurchase,
    GBIAP2TransactionTypeRestore,
} GBIAP2TransactionType;

typedef enum {
    GBIAP2TransactionStateUnknown,
    GBIAP2TransactionStateSuccess,
    GBIAP2TransactionStateCancelled,
    GBIAP2TransactionStateFailed,
} GBIAP2TransactionState;

#pragma mark - Handler block types

//Enumeration
typedef void(^GBIAP2ProductHandler)(NSString *productIdentifier, NSString *title, NSString *description, NSString *formattedPrice, NSDecimalNumber *rawPrice);

//Metadata
typedef void(^GBIAP2MetadataFetchDidBeginHandler)(NSArray *productIdentifiers);
typedef void(^GBIAP2MetadataFetchDidEndHandler)(NSArray *productIdentifiers, GBIAP2MetadataFetchState fetchState);

//Purchase/restore requests
typedef void(^GBIAP2DidRequestPurchaseHandler)(NSString *productIdentifier);
typedef void(^GBIAP2DidRequestRestoreHandler)(void);

//Purchase or restore phase
typedef void(^GBIAP2PurchasePhaseDidBeginHandler)(NSString *productIdentifier, BOOL solicited);
typedef void(^GBIAP2PurchasePhaseDidEndHandler)(NSString *productIdentifier, GBIAP2PurchaseState purchaseState, BOOL solicited);

//Verification phase
typedef void(^GBIAP2VerificationPhaseDidBeginHandler)(NSString *productIdentifier, BOOL solicited);
typedef void(^GBIAP2VerificationPhaseDidEndHandler)(NSString *productIdentifier, GBIAP2VerificationState verificationState, BOOL solicited);

//Purchase acquiry
typedef void(^GBIAP2PurchaseDidCompleteHandler)(NSString *productIdentifier, GBIAP2TransactionType transactionType, GBIAP2TransactionState transactionState, BOOL solicited);


@protocol GBIAP2AnalyticsModule;

@interface GBIAP2 : NSObject

#pragma mark - Singleton

/**
 The shared purchase manager sinlgeton.
 */
+ (GBIAP2 *)purchaseManager;

//Just a quick convenience
#define GBIAPManager [GBIAP2 purchaseManager]

#pragma mark - Setup phase

/**
 Allows you to hook in an analytics or debugging module which will tell you when things happen. You can use this for debugging, or for pushing analytics data to yor favourite analytics provider.
 */
- (void)setAnalyticsModule:(id<GBIAP2AnalyticsModule>)analyticsModule;

/**
 Call this on app launch to resume any previous transactions which never completed. It's a good idea to register your handlers for the state transitions your interested in first (usually `addHandlerForDidSuccessfullyAcquireProduct`).
 */
- (void)resumePendingTransactions;

/**<commit_msg>Added a small convenience<commit_after>//
//  GBIAP2Manager.h
//  GBIAP2
//
//  Created by <NAME> on 21/05/2013.
//  Copyright (c) 2013 Goonbee. All rights reserved.
//

#import <Foundation/Foundation.h>

#pragma mark - Types

typedef enum {
    GBIAP2MetadataFetchStateUnknown,
    GBIAP2MetadataFetchStateSuccess,
    GBIAP2MetadataFetchStateFailed,
} GBIAP2MetadataFetchState;

typedef enum {
    GBIAP2PurchaseStateUnknown,
    GBIAP2PurchaseStateSuccess,
    GBIAP2PurchaseStateCancelled,
    GBIAP2PurchaseStateFailed,
} GBIAP2PurchaseState;

typedef enum {
    GBIAP2VerificationStateUnknown,
    GBIAP2VerificationStateSuccess,
    GBIAP2VerificationStateFailed,
} GBIAP2VerificationState;

typedef enum {
    GBIAP2TransactionTypeUnknown,
    GBIAP2TransactionTypePurchase,
    GBIAP2TransactionTypeRePurchase,
    GBIAP2TransactionTypeRestore,
} GBIAP2TransactionType;

typedef enum {
    GBIAP2TransactionStateUnknown,
    GBIAP2TransactionStateSuccess,
    GBIAP2TransactionStateCancelled,
    GBIAP2TransactionStateFailed,
} GBIAP2TransactionState;

#pragma mark - Handler block types

//Enumeration
typedef void(^GBIAP2ProductHandler)(NSString *productIdentifier, NSString *title, NSString *description, NSString *formattedPrice, NSDecimalNumber *rawPrice);

//Metadata
typedef void(^GBIAP2MetadataFetchDidBeginHandler)(NSArray *productIdentifiers);
typedef void(^GBIAP2MetadataFetchDidEndHandler)(NSArray *productIdentifiers, GBIAP2MetadataFetchState fetchState);

//Purchase/restore requests
typedef void(^GBIAP2DidRequestPurchaseHandler)(NSString *productIdentifier);
typedef void(^GBIAP2DidRequestRestoreHandler)(void);

//Purchase or restore phase
typedef void(^GBIAP2PurchasePhaseDidBeginHandler)(NSString *productIdentifier, BOOL solicited);
typedef void(^GBIAP2PurchasePhaseDidEndHandler)(NSString *productIdentifier, GBIAP2PurchaseState purchaseState, BOOL solicited);

//Verification phase
typedef void(^GBIAP2VerificationPhaseDidBeginHandler)(NSString *productIdentifier, BOOL solicited);
typedef void(^GBIAP2VerificationPhaseDidEndHandler)(NSString *productIdentifier, GBIAP2VerificationState verificationState, BOOL solicited);

//Purchase acquiry
typedef void(^GBIAP2PurchaseDidCompleteHandler)(NSString *productIdentifier, GBIAP2TransactionType transactionType, GBIAP2TransactionState transactionState, BOOL solicited);


@protocol GBIAP2AnalyticsModule;

@interface GBIAP2 : NSObject

#pragma mark - Singleton

/**
 The shared purchase manager sinlgeton.
 */
+ (GBIAP2 *)purchaseManager;

//Conveniences
#define GBIAPManager [GBIAP2 purchaseManager]
#define GBIAP [GBIAP2 purchaseManager]

#pragma mark - Setup phase

/**
 Allows you to hook in an analytics or debugging module which will tell you when things happen. You can use this for debugging, or for pushing analytics data to yor favourite analytics provider.
 */
- (void)setAnalyticsModule:(id<GBIAP2AnalyticsModule>)analyticsModule;

/**
 Call this on app launch to resume any previous transactions which never completed. It's a good idea to register your handlers for the state transitions your interested in first (usually `addHandlerForDidSuccessfullyAcquireProduct`).
 */
- (void)resumePendingTransactions;

/**
{'fraction_non_alphanumeric': 0.07238184958392212, 'fraction_numerical': 0.018056209766054324, 'mean_word_length': 6.702539298669891, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3061759', 'n_tokens_mistral': 1975, 'n_tokens_neox': 1840, 'n_words': 444}