otp method

Future<OtpResult> otp(
  1. String query
)

Implementation

Future<OtpResult> otp(String query) async {
  Uri url;
  if (query.contains('-')) {
    url = Uri.parse('${baseUrl}api/devices/$query/otp');
  } else {
    url = Uri.parse('${baseUrl}api/devices/otp');
  }

  final response = query.contains('-')
      ? await client.get(url)
      : await client.post(url, body: jsonEncode({'sharedSecret': query}));

  if (response.statusCode != 200) {
    throw MailosaurError(response);
  }

  return OtpResult.fromJson(jsonDecode(response.body));
}