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

NS_ASSUME_NONNULL_BEGIN

/**
 Key for version.
 */
extern NSString * const BTClientTokenKeyVersion;

/**
 Domain for client token errors.
 */
extern NSString * const BTClientTokenErrorDomain;

/**
 Key for authorization fingerprint.
 */
extern NSString * const BTClientTokenKeyAuthorizationFingerprint;

/**
 Key for configuration URL.
 */
extern NSString * const BTClientTokenKeyConfigURL;

/**
 Error codes associated with a client token.
 */
typedef NS_ENUM(NSInteger, BTClientTokenError) {
    /// Unknown error
    BTClientTokenErrorUnknown = 0,

    /// Invalid
    BTClientTokenErrorInvalid,

    /// Unsupported version
    BTClientTokenErrorUnsupportedVersion,
};

/**
 An authorization string used to initialize the Braintree SDK
 */
@interface BTClientToken : NSObject <NSCoding, NSCopying>

/**
 The client token as a BTJSON object
*/
@property (nonatomic, readonly, strong) BTJSON *json;

/**
 The extracted authorization fingerprint
*/
@property (nonatomic, readonly, copy) NSString *authorizationFingerprint;

/**
 The extracted configURL
*/
@property (nonatomic, readonly, strong) NSURL *configURL;

/**
 The original string used to initialize this instance
*/
@property (nonatomic, readonly, copy) NSString *originalValue;

#pragma mark - Initializers

/**
 Initialize a client token with a client token string generated by a Braintree Server Library.
*/
- (nullable instancetype)initWithClientToken:(NSString *)clientToken error:(NSError **)error NS_DESIGNATED_INITIALIZER;

/**
 Base initializer - do not use.
 */
- (instancetype)init __attribute__((unavailable("Please use initWithClientToken:error: instead.")));

@end

NS_ASSUME_NONNULL_END
