Commit c495a28b authored by Andrey Shevchuk's avatar Andrey Shevchuk

fixed InboundRoutes maps

parent 03541d10
...@@ -9,15 +9,6 @@ use Asterisk::API::Documentation::Generic; ...@@ -9,15 +9,6 @@ use Asterisk::API::Documentation::Generic;
our $VERSION = "1"; our $VERSION = "1";
our %out_hash_map = ( our %out_hash_map = (
"assigned" => {
"description" => "Assigned",
"format" => "raw",
"hidden" => 0,
"required" => 0,
"sample" => "",
"transform" => "assigned",
"type" => "string"
},
"billable" => { "billable" => {
"description" => "Billable", "description" => "Billable",
"format" => "raw", "format" => "raw",
...@@ -25,7 +16,7 @@ our %out_hash_map = ( ...@@ -25,7 +16,7 @@ our %out_hash_map = (
"required" => 0, "required" => 0,
"sample" => "", "sample" => "",
"transform" => "billable", "transform" => "billable",
"type" => "string" "type" => "bool"
}, },
"channels" => { "channels" => {
"description" => "Channels", "description" => "Channels",
...@@ -72,56 +63,28 @@ our %out_hash_map = ( ...@@ -72,56 +63,28 @@ our %out_hash_map = (
"transform" => "prompt_language", "transform" => "prompt_language",
"type" => "string" "type" => "string"
}, },
"routetype" => { "tz" => {
"description" => "Routetype", "default" => "",
"description" => "Time zone",
"format" => "raw", "format" => "raw",
"hidden" => 0, "hidden" => 0,
"required" => 0, "required" => 1,
"sample" => "", "sample" => "",
"transform" => "routetype", "transform" => "tz",
"type" => "string" "type" => "string"
}, },
"tenant" => { "routetype" => {
"description" => "Tenant", "description" => "Routetype",
"format" => "raw", "format" => "raw",
"hidden" => 0, "hidden" => 0,
"required" => 0, "required" => 0,
"sample" => "", "sample" => "",
"transform" => "tenant", "transform" => "routetype",
"type" => "string" "type" => "string"
},
"tenantid" => {
"description" => "Tenant ID",
"format" => "int64",
"hidden" => 0,
"required" => 1,
"sample" => 1,
"transform" => "tenant_id",
"type" => "integer"
} }
); );
my %in_hash_map = ( my %in_hash_map = (
"action_0" => {
"default" => "tl-reroute",
"description" => "Route action",
"format" => "raw",
"hidden" => 0,
"required" => 0,
"sample" => "tl-reroute",
"transform" => "action_0",
"type" => "string"
},
"assigned" => {
"description" => "Assigned",
"format" => "raw",
"hidden" => 0,
"required" => 0,
"sample" => "",
"transform" => "assigned",
"type" => "string"
},
"billable" => { "billable" => {
"description" => "Billable", "description" => "Billable",
"format" => "raw", "format" => "raw",
...@@ -129,7 +92,7 @@ my %in_hash_map = ( ...@@ -129,7 +92,7 @@ my %in_hash_map = (
"required" => 0, "required" => 0,
"sample" => "", "sample" => "",
"transform" => "billable", "transform" => "billable",
"type" => "string" "type" => "bool"
}, },
"channels" => { "channels" => {
"description" => "Channels", "description" => "Channels",
...@@ -175,6 +138,16 @@ my %in_hash_map = ( ...@@ -175,6 +138,16 @@ my %in_hash_map = (
"transform" => "prompt_language", "transform" => "prompt_language",
"type" => "string" "type" => "string"
}, },
"tz" => {
"default" => "",
"description" => "Time zone",
"format" => "raw",
"hidden" => 0,
"required" => 1,
"sample" => "",
"transform" => "tz",
"type" => "string"
},
"routetype" => { "routetype" => {
"default" => "schedule", "default" => "schedule",
"description" => "Route type", "description" => "Route type",
...@@ -184,27 +157,7 @@ my %in_hash_map = ( ...@@ -184,27 +157,7 @@ my %in_hash_map = (
"sample" => "schedule", "sample" => "schedule",
"transform" => "routetype", "transform" => "routetype",
"type" => "string" "type" => "string"
},
"schedule_0" => {
"default" => "tl-allhours-thirdlane",
"description" => "Route schedule",
"format" => "raw",
"hidden" => 0,
"required" => 0,
"sample" => "tl-allhours-thirdlane",
"transform" => "schedule_0",
"type" => "string"
},
"tenant_id" => {
"description" => "Tenant id",
"format" => "raw",
"hidden" => 0,
"required" => 0,
"sample" => "",
"transform" => "tenantid",
"type" => "string"
} }
); );
our %requests = ( our %requests = (
...@@ -438,6 +391,32 @@ sub map_out { ...@@ -438,6 +391,32 @@ sub map_out {
$out_hash = $self->{mapper}->fix_type($out_hash, $self->{type}->{out}, $self->{reverse}->{out}); $out_hash = $self->{mapper}->fix_type($out_hash, $self->{type}->{out}, $self->{reverse}->{out});
$out_hash->{options} = [ ];
my $options = { };
foreach my $key ( keys %{ $hash } ) {
if ($key =~ m/^(.*?)_(\d+)_(\d+)$/) {
$options->{$2}->{args}->{$3} = $hash->{$key};
} elsif ($key =~ m/^(.*?)_(\d+)$/) {
if ( $1 eq "args" ) {
my $i = 0;
foreach my $arg ( split /,/, $hash->{$key} ) {
$options->{$2}->{args}->{$i++} = $arg;
}
}
elsif ( not grep { $1 eq $_ } qw(var schedule_name) ) {
$options->{$2}->{$1} = $hash->{$key};
}
}
}
foreach my $key ( keys %{ $options } ) {
$options->{$key}->{args} = [ map { $options->{$key}->{args}->{$_} } sort { int( $a ) <=> int ( $b ) } keys %{ $options->{$key}->{args} //= {} } ];
}
$out_hash->{options} = [ map { $options->{$_} } sort { int( $a ) <=> int ( $b ) } keys %{ $options } ];
return $out_hash; return $out_hash;
} }
...@@ -462,6 +441,20 @@ sub map_in { ...@@ -462,6 +441,20 @@ sub map_in {
if exists $self->{map}->{in}->{$key} && exists $hash->{$key}; if exists $self->{map}->{in}->{$key} && exists $hash->{$key};
} }
if ( exists $hash->{options} ) {
for ( my $i = 0; $i < scalar @{ $hash->{options} }; $i++ ) {
$out_hash->{"schedule_$i"} = $hash->{options}->[$i]->{schedule};
$out_hash->{"action_$i"} = $hash->{options}->[$i]->{action};
if ( exists $hash->{options}->[$i]->{args} ) {
$out_hash->{"args_$i"} = join ",", @{ $hash->{options}->[$i]->{args} };
for ( my $t = 0; $t < scalar @{ $hash->{options}->[$i]->{args} }; $t++ ) {
$out_hash->{$hash->{options}->[$i]->{action} . "_" . $i . "_" . $t} = $hash->{options}->[$i]->{args}->[$t];
}
}
}
}
return $out_hash; return $out_hash;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment