deviceInfo method

  1. @override
Future<StoneDeviceInfo> deviceInfo()
override

Implementation

@override
Future<StoneDeviceInfo> deviceInfo() async {
  try {
    final response = await methodChannel.invokeMethod<Map>('getSerialNumberAndDeviceModel');
    if (response is Map) {
      if (response['code'] == StoneStatusDeeplink.SUCCESS.name && response['data'] is Map) {
        final jsonData = response['data'];
        return StoneDeviceInfo.fromJson(json: jsonData);
      } else {
        throw StoneReprintException(message: response['message']);
      }
    } else {
      throw StoneReprintException(message: 'invalid response');
    }
  } on StoneReprintException catch (e) {
    throw StoneReprintException(message: e.message);
  } on PlatformException catch (e) {
    throw StoneReprintException(message: e.message ?? 'PlatformException');
  } catch (e) {
    throw StoneReprintException(message: "deviceInfo payment Error: $e");
  }
}