verify method

Future<VerifyResponse> verify(
  1. VerifyRequest params
)

Implementation

Future<VerifyResponse> verify(VerifyRequest params) async {
  final url = Uri.parse('${_wepinBaseUrl}user/verify');
  final jsonRequestBody = jsonEncode(params.toJson());
  final response = await http.post(
    url,
    headers: headers,
    body: jsonRequestBody,
  );

  if (response.statusCode >= 200 && response.statusCode < 300) {
    final responseBody = jsonDecode(response.body);
    return VerifyResponse.fromJson(responseBody);
  } else {
    var errorCode = WepinErrorCode.failedSendEmail;
    if (response.statusCode == 400) {
      errorCode = WepinErrorCode.invalidEmailDomain;
    }
    throw WepinError(errorCode, 'code: ${response.statusCode} , body: ${response.body}');
  }
}