MT#7377 API: check for pilot primary_number.

Before adding pbx_extension, check if pilot has a primary number.
mr3.3.1
Andreas Granig 12 years ago
parent 7089121482
commit 51640b7156

@ -321,6 +321,12 @@ sub prepare_resource {
return;
}
unless($pilot->primary_number) {
$c->log->error("trying to add pbx_extension to contract id " . $pilot->contract_id . " without having a primary number on pilot subscriber id " . $pilot->id);
$self->error($c, HTTP_UNPROCESSABLE_ENTITY, "The pilot subscriber does not have a primary number.");
return;
}
$resource->{e164}->{cc} = $pilot->primary_number->cc;
$resource->{e164}->{ac} = $pilot->primary_number->ac // '';
$resource->{e164}->{sn} = $pilot->primary_number->sn . $resource->{pbx_extension};

Loading…
Cancel
Save