deviceInfo method

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

Implementation

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