Skip to content

Commit

Permalink
qf-get: use typed kapps_config:get calls when possible (2600hz#3686)
Browse files Browse the repository at this point in the history
* qf-get: use type get calls when possible

* qf-get: add get_ne_binary/3,4 to kapps_account_config

* qf-get: add support for missing clauses in schema generator
  • Loading branch information
fenollp authored and lazedo committed May 11, 2017
1 parent 6c267bd commit 5d393dd
Show file tree
Hide file tree
Showing 101 changed files with 422 additions and 480 deletions.
4 changes: 1 addition & 3 deletions applications/acdc/src/acdc_agent_handler.erl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
-include("acdc.hrl").
-include_lib("kazoo_amqp/include/kapi_conf.hrl").

-define(DEFAULT_PAUSE ,kapps_config:get(?CONFIG_CAT, <<"default_agent_pause_timeout">>, 600)).
-define(DEFAULT_PAUSE, kapps_config:get_integer(?CONFIG_CAT, <<"default_agent_pause_timeout">>, 600)).

-spec handle_status_update(kz_json:object(), kz_proplist()) -> 'ok'.
handle_status_update(JObj, _Props) ->
Expand All @@ -45,9 +45,7 @@ handle_status_update(JObj, _Props) ->
maybe_stop_agent(AccountId, AgentId, JObj);
<<"pause">> ->
'true' = kapi_acdc_agent:pause_v(JObj),

Timeout = kz_json:get_integer_value(<<"Time-Limit">>, JObj, ?DEFAULT_PAUSE),

maybe_pause_agent(AccountId, AgentId, Timeout, JObj);
<<"resume">> ->
'true' = kapi_acdc_agent:resume_v(JObj),
Expand Down
20 changes: 10 additions & 10 deletions applications/acdc/src/acdc_agent_listener.erl
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,18 @@
-define(SERVER, ?MODULE).

-record(state, {call :: kapps_call:call()
,acdc_queue_id :: ne_binary() % the ACDc Queue ID
,msg_queue_id :: ne_binary() % the AMQP Queue ID of the ACDc Queue process
,agent_id :: ne_binary()
,acct_db :: ne_binary()
,acct_id :: ne_binary()
,fsm_pid :: pid()
,acdc_queue_id :: api_ne_binary() % the ACDc Queue ID
,msg_queue_id :: api_ne_binary() % the AMQP Queue ID of the ACDc Queue process
,agent_id :: api_ne_binary()
,acct_db :: api_ne_binary()
,acct_id :: api_ne_binary()
,fsm_pid :: api_pid()
,agent_queues = [] :: ne_binaries()
,last_connect :: kz_now() % last connection
,last_attempt :: kz_now() % last attempt to connect
,last_connect :: kz_now() | undefined % last connection
,last_attempt :: kz_now() | undefined % last attempt to connect
,my_id :: ne_binary()
,my_q :: api_binary() % AMQP queue name
,timer_ref :: reference()
,timer_ref :: api_reference()
,sync_resp :: kz_json:object() % furthest along resp
,supervisor :: pid()
,record_calls = 'false' :: boolean()
Expand Down Expand Up @@ -1244,7 +1244,7 @@ maybe_start_recording(Call, 'true', Url) ->
end.

recording_format() ->
kapps_config:get(<<"callflow">>, [<<"call_recording">>, <<"extension">>], <<"mp3">>).
kapps_config:get_ne_binary(<<"callflow">>, [<<"call_recording">>, <<"extension">>], <<"mp3">>).

-spec agent_id(agent()) -> api_binary().
agent_id(Agent) ->
Expand Down
2 changes: 1 addition & 1 deletion applications/acdc/src/acdc_maintenance.erl
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ agent_logout(AcctId, AgentId) ->
-spec agent_pause(ne_binary(), ne_binary()) -> 'ok'.
-spec agent_pause(ne_binary(), ne_binary(), pos_integer()) -> 'ok'.
agent_pause(AcctId, AgentId) ->
Timeout = kapps_config:get(?CONFIG_CAT, <<"default_agent_pause_timeout">>, 600),
Timeout = kapps_config:get_integer(?CONFIG_CAT, <<"default_agent_pause_timeout">>, 600),
agent_pause(AcctId, AgentId, Timeout).
agent_pause(AcctId, AgentId, Timeout) ->
kz_util:put_callid(?MODULE),
Expand Down
2 changes: 1 addition & 1 deletion applications/callflow/src/callflow.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
-define(CACHE_NAME, 'callflow_cache').

-define(DEFAULT_TIMEZONE
,kapps_config:get(<<"accounts">>, <<"default_timezone">>, <<"America/Los_Angeles">>)
,kapps_config:get_ne_binary(<<"accounts">>, <<"default_timezone">>, <<"America/Los_Angeles">>)
).

-define(RESTRICTED_ENDPOINT_KEY, <<"Restricted-Endpoint-ID">>).
Expand Down
2 changes: 1 addition & 1 deletion applications/callflow/src/cf_util.erl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
-define(SIP_ENDPOINT_ID_KEY(Db, User), {?MODULE, 'sip_endpoint_id', Db, User}).
-define(PARKING_PRESENCE_KEY(Db, Request), {?MODULE, 'parking_callflow', Db, Request}).
-define(MANUAL_PRESENCE_KEY(Db), {?MODULE, 'manual_presence', Db}).
-define(OPERATOR_KEY, kapps_config:get(?CF_CONFIG_CAT, <<"operator_key">>, <<"0">>)).
-define(OPERATOR_KEY, kapps_config:get_ne_binary(?CF_CONFIG_CAT, <<"operator_key">>, <<"0">>)).
-define(MWI_SEND_UNSOLICITATED_UPDATES, <<"mwi_send_unsoliciated_updates">>).
-define(VM_CACHE_KEY(Db, Id), {?MODULE, 'vmbox', Db, Id}).

Expand Down
2 changes: 1 addition & 1 deletion applications/callflow/src/module/cf_acdc_agent.erl
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ pause_agent(Call, AgentId, Data, Timeout) when is_integer(Timeout) ->
pause_agent(Call, AgentId, Data) ->
Timeout = kz_json:get_integer_value(<<"timeout">>
,Data
,kapps_config:get(<<"acdc">>, <<"default_agent_pause_timeout">>, 600)
,kapps_config:get_integer(<<"acdc">>, <<"default_agent_pause_timeout">>, 600)
),
lager:info("agent ~s is pausing work for ~b s", [AgentId, Timeout]),
pause_agent(Call, AgentId, Data, Timeout).
Expand Down
2 changes: 1 addition & 1 deletion applications/callflow/src/module/cf_disa.erl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

-export([handle/2]).

-define(DEFAULT_USE_ACCOUNT_CALLER_ID, kapps_config:get(?CF_CONFIG_CAT, <<"default_use_account_caller_id">>, 'true')).
-define(DEFAULT_USE_ACCOUNT_CALLER_ID, kapps_config:get_is_true(?CF_CONFIG_CAT, <<"default_use_account_caller_id">>, 'true')).
-define(DEFAULT_PIN_LENGTH, kapps_config:get_integer(?CF_CONFIG_CAT, <<"default_pin_length">>, 10)).

%%--------------------------------------------------------------------
Expand Down
39 changes: 17 additions & 22 deletions applications/callflow/src/module/cf_voicemail.erl
Original file line number Diff line number Diff line change
Expand Up @@ -56,39 +56,34 @@
)).

-define(MAX_LOGIN_ATTEMPTS
,kapps_config:get(?CF_CONFIG_CAT
,[?KEY_VOICEMAIL, ?KEY_MAX_LOGIN_ATTEMPTS]
,3
)
).
,kapps_config:get_integer(?CF_CONFIG_CAT
,[?KEY_VOICEMAIL, ?KEY_MAX_LOGIN_ATTEMPTS]
,3
)).

-define(DEFAULT_MAX_PIN_LENGTH
,kapps_config:get_integer(?CF_CONFIG_CAT
,[?KEY_VOICEMAIL, ?KEY_MAX_PIN_LENGTH]
,6
)
).
)).

-define(DEFAULT_SAVE_AFTER_NOTIFY
,kapps_config:get(?CF_CONFIG_CAT
,[?KEY_VOICEMAIL, ?KEY_SAVE_AFTER_NOTIFY]
,'false'
)
).
,kapps_config:get_is_true(?CF_CONFIG_CAT
,[?KEY_VOICEMAIL, ?KEY_SAVE_AFTER_NOTIFY]
,'false'
)).

-define(DEFAULT_DELETE_AFTER_NOTIFY
,kapps_config:get(?CF_CONFIG_CAT
,[?KEY_VOICEMAIL, ?KEY_DELETE_AFTER_NOTIFY]
,'false'
)
).
,kapps_config:get_is_true(?CF_CONFIG_CAT
,[?KEY_VOICEMAIL, ?KEY_DELETE_AFTER_NOTIFY]
,'false'
)).

-define(DEFAULT_FORWARD_TYPE
,kapps_config:get(?CF_CONFIG_CAT
,[?KEY_VOICEMAIL, <<"vm_message_foraward_type">>]
,<<"only_forward">>
)
).
,kapps_config:get_ne_binary(?CF_CONFIG_CAT
,[?KEY_VOICEMAIL, <<"vm_message_foraward_type">>]
,<<"only_forward">>
)).

-define(DEFAULT_FIND_BOX_PROMPT, <<"vm-enter_id">>).

Expand Down
2 changes: 1 addition & 1 deletion applications/camper/src/camper_onnet_handler.erl
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ handle_cast({'add_request', JObj}, GlobalState) ->
Targets = kz_json:get_value(<<"Targets">>, JObj, []),
Timeout = timer:minutes(kz_json:get_value(<<"Timeout">>
,JObj
,kapps_config:get(?APP_NAME, ?TIMEOUT, ?DEFAULT_TIMEOUT)
,kapps_config:get_integer(?APP_NAME, ?TIMEOUT, ?DEFAULT_TIMEOUT)
)),
kz_hooks:register(AccountId, <<"CHANNEL_DESTROY">>),
NewGlobal = with_state(AccountId
Expand Down
24 changes: 12 additions & 12 deletions applications/cccp/src/cccp.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@

-define(CCCP_CONFIG_CAT, <<"cccp">>).

-record(state, {a_leg_name :: ne_binary()
,a_leg_number :: ne_binary()
,b_leg_number :: ne_binary()
-record(state, {a_leg_name :: api_ne_binary()
,a_leg_number :: api_ne_binary()
,b_leg_number :: api_ne_binary()
,call = kapps_call:new() :: kapps_call:call()
,account_id :: ne_binary()
,authorizing_id :: ne_binary()
,account_id :: api_ne_binary()
,authorizing_id :: api_ne_binary()
,queue :: api_binary()
,parked_call_id :: ne_binary()
,offnet_ctl_q :: ne_binary()
,auth_doc_id :: ne_binary()
,media_id :: ne_binary()
,retain_cid :: ne_binary()
,parked_call_id :: api_ne_binary()
,offnet_ctl_q :: api_ne_binary()
,auth_doc_id :: api_ne_binary()
,media_id :: api_ne_binary()
,retain_cid :: api_ne_binary()
,self = self() :: pid()
,consumer_pid :: pid()
,callback_delay :: integer()
,consumer_pid :: api_pid()
,callback_delay :: api_integer()
}).

-type state() :: #state{}.
Expand Down
20 changes: 11 additions & 9 deletions applications/cccp/src/cccp_handlers.erl
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@

-include("cccp.hrl").

-define(CB_NUMBER
,knm_converters:normalize(kapps_config:get_ne_binary(?CCCP_CONFIG_CAT, <<"cccp_cb_number">>))).
-define(CC_NUMBER
,knm_converters:normalize(kapps_config:get_ne_binary(?CCCP_CONFIG_CAT, <<"cccp_cc_number">>))).

-spec handle_route_req(kz_json:object(), kz_proplist()) -> any().
handle_route_req(JObj, Props) ->
'true' = kapi_route:req_v(JObj),

Call = kapps_call:from_route_req(JObj),
CB_Number = knm_converters:normalize(kapps_config:get(?CCCP_CONFIG_CAT, <<"cccp_cb_number">>)),
CC_Number = knm_converters:normalize(kapps_config:get(?CCCP_CONFIG_CAT, <<"cccp_cc_number">>)),
CB_Number = ?CB_NUMBER,
CC_Number = ?CC_NUMBER,
case knm_converters:normalize(kapps_call:request_user(Call)) of
CB_Number -> park_call(JObj, Props, Call);
CC_Number -> park_call(JObj, Props, Call);
Expand Down Expand Up @@ -62,13 +66,11 @@ handle_config_change(_JObj, _Props) ->

-spec handle_cccp_call(kapps_call:call()) -> 'ok'.
handle_cccp_call(Call) ->
CB_Number = knm_converters:normalize(kapps_config:get(?CCCP_CONFIG_CAT, <<"cccp_cb_number">>)),
CC_Number = knm_converters:normalize(kapps_config:get(?CCCP_CONFIG_CAT, <<"cccp_cc_number">>)),
CB_Number = ?CB_NUMBER,
CC_Number = ?CC_NUMBER,
case knm_converters:normalize(kapps_call:request_user(Call)) of
CB_Number ->
handle_callback(Call);
CC_Number ->
cccp_platform_sup:new(Call)
CB_Number -> handle_callback(Call);
CC_Number -> cccp_platform_sup:new(Call)
end.

-spec handle_callback(kapps_call:call()) -> any().
Expand Down
3 changes: 1 addition & 2 deletions applications/cccp/src/cccp_listener.erl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
%%% OnNet (Kirill Sysoev github.com/onnet)
%%%-------------------------------------------------------------------
-module(cccp_listener).

-behaviour(gen_listener).

-export([start_link/0]).
Expand Down Expand Up @@ -173,7 +172,7 @@ validate_sysconfig() ->

-spec validate_sysconfig(ne_binary()) -> 'ok'.
validate_sysconfig(Key) ->
case kapps_config:get(?CCCP_CONFIG_CAT, Key) of
case kapps_config:get_ne_binary(?CCCP_CONFIG_CAT, Key) of
'undefined' -> lager:warning("cccp hasn't been configured with ~s in system_config/~s; this is necessary", [Key, ?CCCP_CONFIG_CAT]);
Value -> lager:debug("cccp using ~s for ~s", [knm_converters:normalize(Value), Key])
end.
2 changes: 1 addition & 1 deletion applications/cccp/src/cccp_util.erl
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ get_number(Call, 0) ->
kapps_call_command:prompt(<<"hotdesk-invalid_entry">>, Call),
kapps_call_command:queued_hangup(Call);
get_number(Call, Retries) ->
RedialCode = kapps_config:get(?CCCP_CONFIG_CAT, <<"last_number_redial_code">>, <<"*0">>),
RedialCode = kapps_config:get_ne_binary(?CCCP_CONFIG_CAT, <<"last_number_redial_code">>, <<"*0">>),
case kapps_call_command:b_prompt_and_collect_digits(2, 17, <<"cf-enter_number">>, 3, Call) of
{'ok', RedialCode} ->
get_last_dialed_number(Call);
Expand Down
4 changes: 2 additions & 2 deletions applications/cdr/src/cdr_listener.erl
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

-include("cdr.hrl").
-define(VIEW_TO_UPDATE, <<"cdrs/interaction_listing">>).
-define(REFRESH_THRESHOLD, kapps_config:get(?CONFIG_CAT, <<"refresh_view_threshold">>, 10)).
-define(REFRESH_TIMEOUT, kapps_config:get(?CONFIG_CAT, <<"refresh_view_timeout">>, 900)).
-define(REFRESH_THRESHOLD, kapps_config:get_integer(?CONFIG_CAT, <<"refresh_view_threshold">>, 10)).
-define(REFRESH_TIMEOUT, kapps_config:get_integer(?CONFIG_CAT, <<"refresh_view_timeout">>, 900)).
-define(REFRESH_ENABLED, kapps_config:get_is_true(?CONFIG_CAT, <<"refresh_view_enabled">>, 'false')).

-record(state, {counter = #{} :: map()}).
Expand Down
12 changes: 6 additions & 6 deletions applications/conference/src/conf_config_req.erl
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ get_conference_controls(Name, Conference) ->

-spec default_profile() -> kz_json:object().
default_profile() ->
kapps_config:get(?CONFIG_CAT
,[<<"profiles">>, ?DEFAULT_PROFILE_NAME]
,kz_json:from_list(?DEFAULT_PROFILE_CONFIG)
).
kapps_config:get_json(?CONFIG_CAT
,[<<"profiles">>, ?DEFAULT_PROFILE_NAME]
,kz_json:from_list(?DEFAULT_PROFILE_CONFIG)
).

-spec page_profile() -> kz_json:object().
page_profile() ->
Expand Down Expand Up @@ -150,11 +150,11 @@ get_conference(AccountId, ConferenceId) ->
{'ok', JObj} = kz_datamgr:open_cache_doc(kz_util:format_account_db(AccountId), ConferenceId),
kapps_conference:from_conference_doc(JObj).

-spec caller_controls(ne_binary()) -> kz_json:object().
-spec caller_controls(ne_binary()) -> kz_json:objects().
caller_controls(ConfigName) ->
kapps_config:get(?CONFIG_CAT, [<<"caller-controls">>, ConfigName], ?DEFAULT_CONTROLS).

-spec caller_controls(ne_binary(), ne_binary()) -> kz_json:object().
-spec caller_controls(ne_binary(), ne_binary()) -> kz_json:objects().
caller_controls(AccountId, ConfigName) ->
kapps_account_config:get_global(AccountId, ?CONFIG_CAT, [<<"caller-controls">>, ConfigName], ?DEFAULT_CONTROLS).

Expand Down
4 changes: 2 additions & 2 deletions applications/conference/src/conference.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@
-define(DEFAULT_ADVERTISE_CONFIG, 'undefined').
-define(PAGE_ADVERTISE_CONFIG, 'undefined').
-define(ADVERTISE(ConfigName, Default)
,kapps_config:get(?CONFIG_CAT, [<<"advertise">>, ConfigName], Default)
,kapps_config:get_json(?CONFIG_CAT, [<<"advertise">>, ConfigName], Default)
).
-define(ADVERTISE(ConfigName), ?ADVERTISE(ConfigName, 'undefined')).

-define(DEFAULT_CHAT_CONFIG, 'undefined').
-define(PAGE_CHAT_CONFIG, 'undefined').
-define(CHAT_PERMISSIONS(ConfigName, Default)
,kapps_config:get(?CONFIG_CAT, [<<"chat-permissions">>, ConfigName], Default)
,kapps_config:get_json(?CONFIG_CAT, [<<"chat-permissions">>, ConfigName], Default)
).
-define(CHAT_PERMISSIONS(ConfigName), ?CHAT_PERMISSIONS(ConfigName, 'undefined')).

Expand Down
Loading

0 comments on commit 5d393dd

Please sign in to comment.