getCustomer method
Implementation
Future<LinkCustomerDetails> getCustomer({required String customerId}) async {
if (customerId.isEmpty || customerId.length != 36) {
throw Exception('customerId parameter must be a valid UUID string.');
}
final uri = Uri(
scheme: _scheme,
host: _host,
path: '/v1/customers/$customerId',
);
final response = await http.get(uri, headers: {
'content-type': 'application/json',
'Authorization': 'Bearer $accessToken',
});
if (response.statusCode >= 200 && response.statusCode < 300) {
final jsonResponse = jsonDecode(response.body) as Map<String, dynamic>;
return LinkCustomerDetails.fromJson(jsonResponse);
} else {
throw Exception(
'StatusCode:${response.statusCode}\n` + `ErrorMessage: ${response.reasonPhrase}\n');
}
}