createNewContact method
Creates new contact for inbox with inboxIdentifier
and passes user
body to be linked to created contact
Implementation
@override
Future<SquadweContact> createNewContact(
String inboxIdentifier, SquadweUser? user) async {
try {
final createResponse = await dio.post(
"/public/api/v1/inboxes/$inboxIdentifier/contacts",
data: user?.toJson());
if ((createResponse.statusCode ?? 0).isBetween(199, 300)) {
//creating contact successful continue with request
final contact = SquadweContact.fromJson(createResponse.data);
return contact;
} else {
throw SquadweClientException(
createResponse.statusMessage ?? "unknown error",
SquadweClientExceptionType.CREATE_CONTACT_FAILED);
}
} on DioError catch (e) {
throw SquadweClientException(
e.message, SquadweClientExceptionType.CREATE_CONTACT_FAILED);
}
}