diff --git a/bin/ngcp-create-subscriber b/bin/ngcp-create-subscriber index 6cbd2d6..8f85da1 100755 --- a/bin/ngcp-create-subscriber +++ b/bin/ngcp-create-subscriber @@ -27,8 +27,11 @@ GetOptions($opts, 'cc|c=s', 'ac|a=s', 'sn|n=s', + 'aliases=s@', + 'display_name=s', 'webpassword|w=s', 'pbx_pilot', + 'pbx_extension=s', 'verbose', ) or usage(); @@ -70,18 +73,34 @@ sub main { } my $uri = '/api/subscribers/'; + my %data = map { $_ => $opts->{$_} } qw(customer_id username password webpassword); $data{primary_number} = { map { $_ => $opts->{$_} } qw(cc ac sn) }; $data{administrative} = $opts->{admin}; $data{is_pbx_pilot} = $opts->{pbx_pilot}; + $data{display_name} = $opts->{display_name} // undef; + $data{pbx_extension} = $opts->{pbx_extension} // undef; my $tmp = $dom->as_hash->{_embedded}->{'ngcp:domains'}; if (ref $tmp eq 'ARRAY') { $data{domain_id} = @{$tmp}[0]->{id}; } else { $data{domain_id} = $tmp->{id}; } + + if ($opts->{aliases}) { + $data{alias_numbers} = [ + map { + { + map { + split /\=/, $_ + } split /\s+/, $_ + } + } @{$opts->{aliases}} + ]; + } + my $res = $client->request('POST', $uri, \%data); print $res->result . "\n"; @@ -157,11 +176,29 @@ A local number part of the subscriber's number. Set the administrative flag for the new subscriber. Defaults to 0 (no). +=item B<--display> I + +A display name part of the subscriber's number. + +=item B<--aliases> + +A list of alias numbers + + Format: --aliases "cc=43 ac=1 sn=123" --aliases "cc=43 ac=1 sn=456" + Optional: + is_devid=1 + devid_alias=Alice + + =item B<--pbx_pilot> Set the "pbx pilot" flag for the new subscriber. Defaults to 0 (no). +=item B<--pbx_extension> + +PBX extension number (only usable for PBX subscribers) + =item B<--verbose> Show additional debug information. Default false.