import 'package:plugin_platform_interface/plugin_platform_interface.dart';

import 'apple_pay_method_channel.dart';

abstract class ApplePayPlatform extends PlatformInterface {
  /// Constructs a ApplePayPlatform.
  ApplePayPlatform() : super(token: _token);

  static final Object _token = Object();

  static ApplePayPlatform _instance = MethodChannelApplePay();

  /// The default instance of [ApplePayPlatform] to use.
  ///
  /// Defaults to [MethodChannelApplePay].
  static ApplePayPlatform get instance => _instance;

  /// Platform-specific implementations should set this with their own
  /// platform-specific class that extends [ApplePayPlatform] when
  /// they register themselves.
  static set instance(ApplePayPlatform instance) {
    PlatformInterface.verifyToken(instance, _token);
    _instance = instance;
  }

  Future<String?> getPlatformVersion() {
    throw UnimplementedError('platformVersion() has not been implemented.');
  }

  /// 发起购买
  Future<Map<String, dynamic>> purchase({
    required String productId,
    String? appAccountToken,
  }) async {
    throw UnimplementedError('purchase() has not been implemented.');
  }

  /// 恢复订阅
  Future<Map<String, dynamic>> restore() async {
    throw UnimplementedError('restore() has not been implemented.');
  }

  /// 检查订单
  Future<bool> check(String appleId) async {
    throw UnimplementedError('check() has not been implemented.');
  }
}
