Skip to content

Commit

Permalink
Set e164_origination for offnet terminating cdrs when possible (2600h…
Browse files Browse the repository at this point in the history
…z#6414)

* PISTON-1046:Set e164_origination when possible for offnet_terminating cdrs

* PISTON-1046:Wrapped function description
  • Loading branch information
bradfordben authored May 1, 2020
1 parent ef4f6cc commit 3e08f4a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
14 changes: 8 additions & 6 deletions applications/stepswitch/src/stepswitch_resources.erl
Original file line number Diff line number Diff line change
Expand Up @@ -553,12 +553,14 @@ maybe_resource_to_endpoints(#resrc{id=Id
'false' -> <<"no_classifier">>
end,
lager:debug("building resource ~s endpoints (classifier ~s)", [Id, _MaybeClassifier]),
CCVUpdates = [{<<"Global-Resource">>, Global}
,{<<"Resource-ID">>, Id}
,{<<"E164-Destination">>, Number}
,{<<"DID-Classifier">>, knm_converters:classify(Number)}
,{<<"Original-Number">>, kapi_offnet_resource:to_did(OffnetJObj)}
],
CCVUpdates = props:filter_empty(
[{<<"Global-Resource">>, Global}
,{<<"Resource-ID">>, Id}
,{<<"E164-Destination">>, Number}
,{<<"E164-Origination">>, stepswitch_util:convert_to_e164_format(CallerIdNumber, 'undefined')}
,{<<"DID-Classifier">>, knm_converters:classify(Number)}
,{<<"Original-Number">>, kapi_offnet_resource:to_did(OffnetJObj)}
]),
Updates = [{<<"Name">>, Name}
,{<<"Weight">>, Weight}
],
Expand Down
13 changes: 13 additions & 0 deletions applications/stepswitch/src/stepswitch_util.erl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
-export([route_by/0]).
-export([resources_to_endpoints/3]).
-export([json_to_template_props/1]).
-export([convert_to_e164_format/2]).

-include("stepswitch.hrl").
-include_lib("kazoo_stdlib/include/kazoo_json.hrl").
Expand Down Expand Up @@ -56,6 +57,18 @@ get_inbound_destination(JObj) ->
{Number, _} = kapps_util:get_destination(JObj, ?APP_NAME, <<"inbound_user_field">>),
convert_to_e164_format(Number, ?SS_CONFIG_CAT, <<"assume_inbound_e164">>).

%%------------------------------------------------------------------------------
%% @doc Convert Number to e164 format if the number is reconcilable else return
%% the value Default
%% @end
%%------------------------------------------------------------------------------
-spec convert_to_e164_format(kz_term:ne_binary(), Default) -> kz_term:ne_binary() | Default.
convert_to_e164_format(Number, Default) ->
case knm_converters:is_reconcilable(Number) of
'true' -> knm_converters:normalize(Number);
'false' -> Default
end.

%%------------------------------------------------------------------------------
%% @doc Convert number to e164 format depending on config values set in system_config db
%% @end
Expand Down

0 comments on commit 3e08f4a

Please sign in to comment.